blob: f2888606e5d866e51d6c888be500e0a80740f86e [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/**
Arif Hussain4d4c8942018-10-17 18:48:29 -07007506 * send_obss_spatial_reuse_set_def_thresh_cmd_tlv - send obss spatial reuse set
7507 * def thresh to fw
7508 * @wmi_handle: wmi handle
7509 * @thresh: pointer to obss_spatial_reuse_def_thresh
7510 *
7511 * Return: QDF_STATUS_SUCCESS for success or error code
7512 */
7513static
7514QDF_STATUS send_obss_spatial_reuse_set_def_thresh_cmd_tlv(
7515 wmi_unified_t wmi_handle,
7516 struct wmi_host_obss_spatial_reuse_set_def_thresh
7517 *thresh)
7518{
7519 wmi_buf_t buf;
7520 wmi_obss_spatial_reuse_set_def_obss_thresh_cmd_fixed_param *cmd;
7521 QDF_STATUS ret;
7522 uint32_t cmd_len;
7523 uint32_t tlv_len;
7524
7525 cmd_len = sizeof(*cmd);
7526
7527 buf = wmi_buf_alloc(wmi_handle, cmd_len);
7528 if (!buf)
7529 return QDF_STATUS_E_NOMEM;
7530
7531 cmd = (wmi_obss_spatial_reuse_set_def_obss_thresh_cmd_fixed_param *)
7532 wmi_buf_data(buf);
7533
7534 tlv_len = WMITLV_GET_STRUCT_TLVLEN(
7535 wmi_obss_spatial_reuse_set_def_obss_thresh_cmd_fixed_param);
7536
7537 WMITLV_SET_HDR(&cmd->tlv_header,
7538 WMITLV_TAG_STRUC_wmi_obss_spatial_reuse_set_def_obss_thresh_cmd_fixed_param,
7539 tlv_len);
7540
7541 cmd->obss_min = thresh->obss_min;
7542 cmd->obss_max = thresh->obss_max;
7543 cmd->vdev_type = thresh->vdev_type;
7544 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
7545 WMI_PDEV_OBSS_PD_SPATIAL_REUSE_SET_DEF_OBSS_THRESH_CMDID);
7546 if (QDF_IS_STATUS_ERROR(ret))
7547 wmi_buf_free(buf);
7548
7549 return ret;
7550}
7551
7552/**
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307553 * send_obss_spatial_reuse_set_cmd_tlv - send obss spatial reuse set cmd to fw
7554 * @wmi_handle: wmi handle
7555 * @obss_spatial_reuse_param: pointer to obss_spatial_reuse_param
7556 *
7557 * Return: QDF_STATUS_SUCCESS for success or error code
7558 */
7559static
7560QDF_STATUS send_obss_spatial_reuse_set_cmd_tlv(wmi_unified_t wmi_handle,
7561 struct wmi_host_obss_spatial_reuse_set_param
7562 *obss_spatial_reuse_param)
7563{
7564 wmi_buf_t buf;
7565 wmi_obss_spatial_reuse_set_cmd_fixed_param *cmd;
7566 QDF_STATUS ret;
7567 uint32_t len;
7568
7569 len = sizeof(*cmd);
7570
7571 buf = wmi_buf_alloc(wmi_handle, len);
7572 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307573 qdf_print("%s: wmi_buf_alloc failed", __func__);
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307574 return QDF_STATUS_E_FAILURE;
7575 }
7576
7577 cmd = (wmi_obss_spatial_reuse_set_cmd_fixed_param *)wmi_buf_data(buf);
7578 WMITLV_SET_HDR(&cmd->tlv_header,
7579 WMITLV_TAG_STRUC_wmi_obss_spatial_reuse_set_cmd_fixed_param,
7580 WMITLV_GET_STRUCT_TLVLEN
7581 (wmi_obss_spatial_reuse_set_cmd_fixed_param));
7582
7583 cmd->enable = obss_spatial_reuse_param->enable;
7584 cmd->obss_min = obss_spatial_reuse_param->obss_min;
7585 cmd->obss_max = obss_spatial_reuse_param->obss_max;
7586 cmd->vdev_id = obss_spatial_reuse_param->vdev_id;
7587
7588 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7589 WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID);
7590
7591 if (QDF_IS_STATUS_ERROR(ret)) {
7592 WMI_LOGE(
7593 "WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID send returned Error %d",
7594 ret);
7595 wmi_buf_free(buf);
7596 }
7597
7598 return ret;
7599}
7600#endif
7601
Naveen Rawat963ee942018-04-13 16:38:36 -07007602#ifdef QCA_SUPPORT_CP_STATS
7603/**
7604 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
7605 * @wmi_handle: wma handle
7606 * @evt_buf: event buffer
7607 * @out_buff: buffer to populated after stats extraction
7608 *
7609 * Return: status of operation
7610 */
7611static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
7612 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
7613{
7614 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
7615 wmi_congestion_stats *congestion_stats;
7616
7617 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
7618 congestion_stats = param_buf->congestion_stats;
7619 if (!congestion_stats) {
7620 WMI_LOGD("%s: no cca stats in event buffer", __func__);
7621 return QDF_STATUS_E_INVAL;
7622 }
7623
7624 out_buff->vdev_id = congestion_stats->vdev_id;
7625 out_buff->congestion = congestion_stats->congestion;
7626
7627 WMI_LOGD("%s: cca stats event processed", __func__);
7628 return QDF_STATUS_SUCCESS;
7629}
7630#endif /* QCA_SUPPORT_CP_STATS */
7631
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +05307632/**
Alok Singh0243e7d2018-09-20 16:07:28 +05307633 * extract_ctl_failsafe_check_ev_param_tlv() - extract ctl data from
7634 * event
7635 * @wmi_handle: wmi handle
7636 * @param evt_buf: pointer to event buffer
7637 * @param param: Pointer to hold peer ctl data
7638 *
7639 * Return: QDF_STATUS_SUCCESS for success or error code
7640 */
7641static QDF_STATUS extract_ctl_failsafe_check_ev_param_tlv(
7642 wmi_unified_t wmi_handle,
7643 void *evt_buf,
7644 struct wmi_host_pdev_ctl_failsafe_event *param)
7645{
7646 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *param_buf;
7647 wmi_pdev_ctl_failsafe_check_fixed_param *fix_param;
7648
7649 param_buf = (WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *)evt_buf;
7650 if (!param_buf) {
7651 WMI_LOGE("Invalid ctl_failsafe event buffer");
7652 return QDF_STATUS_E_INVAL;
7653 }
7654
7655 fix_param = param_buf->fixed_param;
7656 param->ctl_failsafe_status = fix_param->ctl_FailsafeStatus;
7657
7658 return QDF_STATUS_SUCCESS;
7659}
7660
7661/**
Govind Singhe7f2f342016-05-23 12:12:52 +05307662 * save_service_bitmap_tlv() - save service bitmap
7663 * @wmi_handle: wmi handle
7664 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -08007665 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +05307666 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307667 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +05307668 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007669static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307670QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007671 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307672{
7673 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307674 struct wmi_soc *soc = wmi_handle->soc;
7675
Govind Singhe7f2f342016-05-23 12:12:52 +05307676 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7677
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307678 /* If it is already allocated, use that buffer. This can happen
7679 * during target stop/start scenarios where host allocation is skipped.
7680 */
7681 if (!soc->wmi_service_bitmap) {
7682 soc->wmi_service_bitmap =
7683 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
7684 if (!soc->wmi_service_bitmap) {
7685 WMI_LOGE("Failed memory allocation for service bitmap");
7686 return QDF_STATUS_E_NOMEM;
7687 }
7688 }
7689
7690 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +05307691 param_buf->wmi_service_bitmap,
7692 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -08007693
7694 if (bitmap_buf)
7695 qdf_mem_copy(bitmap_buf,
7696 param_buf->wmi_service_bitmap,
7697 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307698
7699 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +05307700}
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307701
7702/**
7703 * save_ext_service_bitmap_tlv() - save extendend service bitmap
7704 * @wmi_handle: wmi handle
7705 * @param evt_buf: pointer to event buffer
7706 * @param bitmap_buf: bitmap buffer, for converged legacy support
7707 *
7708 * Return: QDF_STATUS
7709 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007710static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307711QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007712 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307713{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307714 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
7715 wmi_service_available_event_fixed_param *ev;
7716 struct wmi_soc *soc = wmi_handle->soc;
7717
7718 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
7719
7720 ev = param_buf->fixed_param;
7721
7722 /* If it is already allocated, use that buffer. This can happen
7723 * during target stop/start scenarios where host allocation is skipped.
7724 */
7725 if (!soc->wmi_ext_service_bitmap) {
7726 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
7727 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
7728 if (!soc->wmi_ext_service_bitmap) {
7729 WMI_LOGE("Failed memory allocation for service bitmap");
7730 return QDF_STATUS_E_NOMEM;
7731 }
7732 }
7733
7734 qdf_mem_copy(soc->wmi_ext_service_bitmap,
7735 ev->wmi_service_segment_bitmap,
7736 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307737
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307738 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 +05307739 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
7740 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
7741
Rajeev Kumar77901472017-02-12 02:12:17 -08007742 if (bitmap_buf)
7743 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307744 soc->wmi_ext_service_bitmap,
7745 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307746
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307747 return QDF_STATUS_SUCCESS;
7748}
Govind Singhe7f2f342016-05-23 12:12:52 +05307749/**
7750 * is_service_enabled_tlv() - Check if service enabled
7751 * @param wmi_handle: wmi handle
7752 * @param service_id: service identifier
7753 *
7754 * Return: 1 enabled, 0 disabled
7755 */
Govind Singhe7f2f342016-05-23 12:12:52 +05307756static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
7757 uint32_t service_id)
7758{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307759 struct wmi_soc *soc = wmi_handle->soc;
7760
7761 if (!soc->wmi_service_bitmap) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307762 WMI_LOGE("WMI service bit map is not saved yet");
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307763 return false;
7764 }
7765
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +05307766 /* if wmi_service_enabled was received with extended bitmap,
7767 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307768 */
7769 if (soc->wmi_ext_service_bitmap)
7770 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
7771 soc->wmi_ext_service_bitmap,
7772 service_id);
7773
Zhu Jianmin3ed26de2018-04-19 17:55:30 +08007774 if (service_id >= WMI_MAX_SERVICE) {
7775 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
7776 service_id);
7777 return false;
7778 }
7779
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307780 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
7781 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05307782}
Govind Singhe7f2f342016-05-23 12:12:52 +05307783
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307784static inline void copy_ht_cap_info(uint32_t ev_target_cap,
7785 struct wlan_psoc_target_capability_info *cap)
7786{
7787 /* except LDPC all flags are common betwen legacy and here
7788 * also IBFEER is not defined for TLV
7789 */
7790 cap->ht_cap_info |= ev_target_cap & (
7791 WMI_HT_CAP_ENABLED
7792 | WMI_HT_CAP_HT20_SGI
7793 | WMI_HT_CAP_DYNAMIC_SMPS
7794 | WMI_HT_CAP_TX_STBC
7795 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
7796 | WMI_HT_CAP_RX_STBC
7797 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
7798 | WMI_HT_CAP_LDPC
7799 | WMI_HT_CAP_L_SIG_TXOP_PROT
7800 | WMI_HT_CAP_MPDU_DENSITY
7801 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
7802 | WMI_HT_CAP_HT40_SGI);
7803 if (ev_target_cap & WMI_HT_CAP_LDPC)
7804 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
7805 WMI_HOST_HT_CAP_TX_LDPC;
7806}
Govind Singhe7f2f342016-05-23 12:12:52 +05307807/**
7808 * extract_service_ready_tlv() - extract service ready event
7809 * @wmi_handle: wmi handle
7810 * @param evt_buf: pointer to received event buffer
7811 * @param cap: pointer to hold target capability information extracted from even
7812 *
7813 * Return: QDF_STATUS_SUCCESS for success or error code
7814 */
7815static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007816 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307817{
7818 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7819 wmi_service_ready_event_fixed_param *ev;
7820
7821
7822 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7823
7824 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7825 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307826 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307827 return QDF_STATUS_E_FAILURE;
7828 }
7829
7830 cap->phy_capability = ev->phy_capability;
7831 cap->max_frag_entry = ev->max_frag_entry;
7832 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307833 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +05307834 cap->vht_cap_info = ev->vht_cap_info;
7835 cap->vht_supp_mcs = ev->vht_supp_mcs;
7836 cap->hw_min_tx_power = ev->hw_min_tx_power;
7837 cap->hw_max_tx_power = ev->hw_max_tx_power;
7838 cap->sys_cap_info = ev->sys_cap_info;
7839 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
7840 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
7841 cap->max_num_scan_channels = ev->max_num_scan_channels;
7842 cap->max_supported_macs = ev->max_supported_macs;
7843 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
7844 cap->txrx_chainmask = ev->txrx_chainmask;
7845 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
7846 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05307847 cap->fw_version = ev->fw_build_vers;
7848 /* fw_version_1 is not available in TLV. */
7849 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +05307850
7851 return QDF_STATUS_SUCCESS;
7852}
7853
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307854/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307855 * to host internal WMI_HOST_REGDMN_MODE values.
7856 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
7857 * host currently. Add this in the future if required.
7858 * 11AX (Phase II) : 11ax related values are not currently
7859 * advertised separately by FW. As part of phase II regulatory bring-up,
7860 * finalize the advertisement mechanism.
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307861 * @target_wireless_mode: target wireless mode received in message
7862 *
7863 * Return: returns the host internal wireless mode.
7864 */
7865static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
7866{
7867
7868 uint32_t wireless_modes = 0;
7869
7870 if (target_wireless_mode & REGDMN_MODE_11A)
7871 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
7872
7873 if (target_wireless_mode & REGDMN_MODE_TURBO)
7874 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
7875
7876 if (target_wireless_mode & REGDMN_MODE_11B)
7877 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
7878
7879 if (target_wireless_mode & REGDMN_MODE_PUREG)
7880 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
7881
7882 if (target_wireless_mode & REGDMN_MODE_11G)
7883 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
7884
7885 if (target_wireless_mode & REGDMN_MODE_108G)
7886 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
7887
7888 if (target_wireless_mode & REGDMN_MODE_108A)
7889 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
7890
7891 if (target_wireless_mode & REGDMN_MODE_XR)
7892 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
7893
7894 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
7895 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
7896
7897 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
7898 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
7899
7900 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
7901 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
7902
7903 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
7904 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
7905
7906 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
7907 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
7908
7909 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
7910 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
7911
7912 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
7913 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
7914
7915 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
7916 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
7917
7918 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
7919 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
7920
7921 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
7922 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
7923
7924 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
7925 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
7926
7927 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
7928 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
7929
7930 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
7931 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
7932
7933 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
7934 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
7935
7936 return wireless_modes;
7937}
7938
Govind Singhe7f2f342016-05-23 12:12:52 +05307939/**
7940 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
7941 * @wmi_handle: wmi handle
7942 * @param evt_buf: Pointer to event buffer
7943 * @param cap: pointer to hold HAL reg capabilities
7944 *
7945 * Return: QDF_STATUS_SUCCESS for success or error code
7946 */
7947static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007948 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307949{
7950 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7951
7952 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7953
7954 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
7955 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -08007956 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +05307957
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307958 cap->wireless_modes = convert_wireless_modes_tlv(
7959 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +05307960
Govind Singhe7f2f342016-05-23 12:12:52 +05307961 return QDF_STATUS_SUCCESS;
7962}
7963
7964/**
7965 * extract_host_mem_req_tlv() - Extract host memory request event
7966 * @wmi_handle: wmi handle
7967 * @param evt_buf: pointer to event buffer
7968 * @param num_entries: pointer to hold number of entries requested
7969 *
7970 * Return: Number of entries requested
7971 */
7972static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
7973 void *evt_buf, uint8_t *num_entries)
7974{
7975 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7976 wmi_service_ready_event_fixed_param *ev;
7977
7978 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7979
7980 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7981 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307982 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307983 return NULL;
7984 }
7985
7986 *num_entries = ev->num_mem_reqs;
7987
7988 return (host_mem_req *)param_buf->mem_reqs;
7989}
7990
7991/**
7992 * save_fw_version_in_service_ready_tlv() - Save fw version in service
7993 * ready function
7994 * @wmi_handle: wmi handle
7995 * @param evt_buf: pointer to event buffer
7996 *
7997 * Return: QDF_STATUS_SUCCESS for success or error code
7998 */
7999static QDF_STATUS
8000save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
8001{
8002 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
8003 wmi_service_ready_event_fixed_param *ev;
8004
8005
8006 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
8007
8008 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
8009 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308010 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05308011 return QDF_STATUS_E_FAILURE;
8012 }
8013
8014 /*Save fw version from service ready message */
8015 /*This will be used while sending INIT message */
8016 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
8017 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +05308018
Govind Singhe7f2f342016-05-23 12:12:52 +05308019 return QDF_STATUS_SUCCESS;
8020}
8021
8022/**
8023 * ready_extract_init_status_tlv() - Extract init status from ready event
8024 * @wmi_handle: wmi handle
8025 * @param evt_buf: Pointer to event buffer
8026 *
8027 * Return: ready status
8028 */
8029static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
8030 void *evt_buf)
8031{
8032 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8033 wmi_ready_event_fixed_param *ev = NULL;
8034
Govind Singhe7f2f342016-05-23 12:12:52 +05308035 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8036 ev = param_buf->fixed_param;
8037
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308038 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +05308039
8040 return ev->status;
8041}
8042
8043/**
8044 * ready_extract_mac_addr_tlv() - extract mac address from ready event
8045 * @wmi_handle: wmi handle
8046 * @param evt_buf: pointer to event buffer
8047 * @param macaddr: Pointer to hold MAC address
8048 *
8049 * Return: QDF_STATUS_SUCCESS for success or error code
8050 */
8051static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
8052 void *evt_buf, uint8_t *macaddr)
8053{
8054 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8055 wmi_ready_event_fixed_param *ev = NULL;
8056
8057
8058 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8059 ev = param_buf->fixed_param;
8060
8061 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
8062
8063 return QDF_STATUS_SUCCESS;
8064}
8065
8066/**
Manoj Ekbotedd273902017-07-09 23:28:56 -07008067 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
8068 * @wmi_handle: wmi handle
8069 * @param evt_buf: pointer to event buffer
8070 * @param macaddr: Pointer to hold number of MAC addresses
8071 *
8072 * Return: Pointer to addr list
8073 */
8074static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
8075 void *evt_buf, uint8_t *num_mac)
8076{
8077 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8078 wmi_ready_event_fixed_param *ev = NULL;
8079
8080 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8081 ev = param_buf->fixed_param;
8082
8083 *num_mac = ev->num_extra_mac_addr;
8084
8085 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
8086}
8087
8088/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308089 * extract_ready_params_tlv() - Extract data from ready event apart from
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308090 * status, macaddr and version.
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308091 * @wmi_handle: Pointer to WMI handle.
8092 * @evt_buf: Pointer to Ready event buffer.
8093 * @ev_param: Pointer to host defined struct to copy the data from event.
8094 *
8095 * Return: QDF_STATUS_SUCCESS on success.
8096 */
8097static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
8098 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
8099{
8100 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8101 wmi_ready_event_fixed_param *ev = NULL;
8102
8103 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8104 ev = param_buf->fixed_param;
8105
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308106 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308107 ev_param->num_dscp_table = ev->num_dscp_table;
8108 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
8109 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308110 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308111 /* Agile_cap in ready event is not supported in TLV target */
8112 ev_param->agile_capability = false;
8113
8114 return QDF_STATUS_SUCCESS;
8115}
8116
8117/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308118 * extract_dbglog_data_len_tlv() - extract debuglog data length
8119 * @wmi_handle: wmi handle
8120 * @param evt_buf: pointer to event buffer
8121 *
8122 * Return: length
8123 */
8124static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -08008125 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +05308126{
8127 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
8128
8129 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
8130
8131 *len = param_buf->num_bufp;
8132
8133 return param_buf->bufp;
8134}
8135
Govind Singhe7f2f342016-05-23 12:12:52 +05308136
Jinwei Chenb69924c2018-08-20 11:31:31 +08008137#ifdef CONFIG_MCL
8138#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
8139 ((_status) & WMI_RXERR_DECRYPT)
8140#else
8141#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
8142#endif
8143
Govind Singhe7f2f342016-05-23 12:12:52 +05308144/**
8145 * extract_mgmt_rx_params_tlv() - extract management rx params from event
8146 * @wmi_handle: wmi handle
8147 * @param evt_buf: pointer to event buffer
8148 * @param hdr: Pointer to hold header
8149 * @param bufp: Pointer to hold pointer to rx param buffer
8150 *
8151 * Return: QDF_STATUS_SUCCESS for success or error code
8152 */
8153static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +05308154 void *evt_buf, struct mgmt_rx_event_params *hdr,
8155 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +05308156{
8157 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
8158 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308159 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +05308160
8161 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
8162 if (!param_tlvs) {
8163 WMI_LOGE("Get NULL point message from FW");
8164 return QDF_STATUS_E_INVAL;
8165 }
8166
8167 ev_hdr = param_tlvs->hdr;
8168 if (!hdr) {
8169 WMI_LOGE("Rx event is NULL");
8170 return QDF_STATUS_E_INVAL;
8171 }
8172
Jinwei Chenb69924c2018-08-20 11:31:31 +08008173 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
8174 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
8175 __func__);
8176 return QDF_STATUS_E_INVAL;
8177 }
8178
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308179 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8180 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308181
8182 hdr->channel = ev_hdr->channel;
8183 hdr->snr = ev_hdr->snr;
8184 hdr->rate = ev_hdr->rate;
8185 hdr->phy_mode = ev_hdr->phy_mode;
8186 hdr->buf_len = ev_hdr->buf_len;
8187 hdr->status = ev_hdr->status;
8188 hdr->flags = ev_hdr->flags;
8189 hdr->rssi = ev_hdr->rssi;
8190 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308191 for (i = 0; i < ATH_MAX_ANTENNA; i++)
8192 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +05308193
8194 *bufp = param_tlvs->bufp;
8195
8196 return QDF_STATUS_SUCCESS;
8197}
8198
8199/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308200 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
8201 * @wmi_handle: wmi handle
8202 * @param evt_buf: pointer to event buffer
8203 * @param param: Pointer to hold roam param
8204 *
8205 * Return: QDF_STATUS_SUCCESS for success or error code
8206 */
8207static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
8208 void *evt_buf, wmi_host_roam_event *param)
8209{
8210 WMI_ROAM_EVENTID_param_tlvs *param_buf;
8211 wmi_roam_event_fixed_param *evt;
8212
8213 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
8214 if (!param_buf) {
8215 WMI_LOGE("Invalid roam event buffer");
8216 return QDF_STATUS_E_INVAL;
8217 }
8218
8219 evt = param_buf->fixed_param;
8220 qdf_mem_zero(param, sizeof(*param));
8221
8222 param->vdev_id = evt->vdev_id;
8223 param->reason = evt->reason;
8224 param->rssi = evt->rssi;
8225
8226 return QDF_STATUS_SUCCESS;
8227}
8228
8229/**
8230 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
8231 * @wmi_handle: wmi handle
8232 * @param evt_buf: pointer to event buffer
8233 * @param param: Pointer to hold vdev scan param
8234 *
8235 * Return: QDF_STATUS_SUCCESS for success or error code
8236 */
8237static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308238 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +05308239{
8240 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
8241 wmi_scan_event_fixed_param *evt = NULL;
8242
8243 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
8244 evt = param_buf->fixed_param;
8245
8246 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308247
Govind Singhe7f2f342016-05-23 12:12:52 +05308248 switch (evt->event) {
8249 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308250 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308251 break;
8252 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308253 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308254 break;
8255 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308256 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308257 break;
8258 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308259 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308260 break;
8261 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308262 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308263 break;
8264 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308265 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308266 break;
8267 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308268 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308269 break;
8270 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308271 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308272 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +05308273 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308274 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308275 break;
8276 case WMI_SCAN_EVENT_MAX:
8277 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308278 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308279 break;
8280 };
8281
8282 switch (evt->reason) {
8283 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308284 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308285 break;
8286 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308287 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308288 break;
8289 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308290 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308291 break;
8292 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308293 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308294 break;
8295 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308296 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308297 break;
8298 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308299 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308300 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308301 case WMI_SCAN_REASON_SUSPENDED:
8302 param->reason = SCAN_REASON_SUSPENDED;
8303 break;
Abhijit Pradhanf6694f82018-10-17 10:13:15 +05308304 case WMI_SCAN_REASON_DFS_VIOLATION:
8305 param->reason = SCAN_REASON_DFS_VIOLATION;
8306 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308307 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308308 param->reason = SCAN_REASON_MAX;
8309 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308310 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308311 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308312 break;
8313 };
8314
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308315 param->chan_freq = evt->channel_freq;
8316 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +05308317 param->scan_id = evt->scan_id;
8318 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +05308319 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +05308320
8321 return QDF_STATUS_SUCCESS;
8322}
8323
Govind Singhe7f2f342016-05-23 12:12:52 +05308324/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308325 * extract_all_stats_counts_tlv() - extract all stats count from event
8326 * @wmi_handle: wmi handle
8327 * @param evt_buf: pointer to event buffer
8328 * @param stats_param: Pointer to hold stats count
8329 *
8330 * Return: QDF_STATUS_SUCCESS for success or error code
8331 */
8332static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
8333 void *evt_buf, wmi_host_stats_event *stats_param)
8334{
Govind Singhe7f2f342016-05-23 12:12:52 +05308335 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008336 wmi_per_chain_rssi_stats *rssi_event;
8337 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008338 uint64_t min_data_len;
Govind Singhe7f2f342016-05-23 12:12:52 +05308339
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008340 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +05308341 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +05308342 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008343 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +05308344 if (!ev) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308345 WMI_LOGE("%s: event fixed param NULL", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05308346 return QDF_STATUS_E_FAILURE;
8347 }
8348
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008349 if (param_buf->num_data > WMI_SVC_MSG_MAX_SIZE - sizeof(*ev)) {
8350 WMI_LOGE("num_data : %u is invalid", param_buf->num_data);
8351 return QDF_STATUS_E_FAULT;
8352 }
8353
Govind Singhe7f2f342016-05-23 12:12:52 +05308354 switch (ev->stats_id) {
8355 case WMI_REQUEST_PEER_STAT:
8356 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
8357 break;
8358
8359 case WMI_REQUEST_AP_STAT:
8360 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
8361 break;
8362
8363 case WMI_REQUEST_PDEV_STAT:
8364 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
8365 break;
8366
8367 case WMI_REQUEST_VDEV_STAT:
8368 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
8369 break;
8370
8371 case WMI_REQUEST_BCNFLT_STAT:
8372 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
8373 break;
8374
8375 case WMI_REQUEST_VDEV_RATE_STAT:
8376 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
8377 break;
8378
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308379 case WMI_REQUEST_BCN_STAT:
8380 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
8381 break;
8382
Govind Singhe7f2f342016-05-23 12:12:52 +05308383 default:
8384 stats_param->stats_id = 0;
8385 break;
8386
8387 }
8388
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008389 /* ev->num_*_stats may cause uint32_t overflow, so use uint64_t
8390 * to save total length calculated
8391 */
8392 min_data_len =
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308393 (((uint64_t)ev->num_pdev_stats) * sizeof(wmi_pdev_stats_v2)) +
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008394 (((uint64_t)ev->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8395 (((uint64_t)ev->num_peer_stats) * sizeof(wmi_peer_stats)) +
8396 (((uint64_t)ev->num_bcnflt_stats) *
8397 sizeof(wmi_bcnfilter_stats_t)) +
8398 (((uint64_t)ev->num_chan_stats) * sizeof(wmi_chan_stats)) +
8399 (((uint64_t)ev->num_mib_stats) * sizeof(wmi_mib_stats)) +
8400 (((uint64_t)ev->num_bcn_stats) * sizeof(wmi_bcn_stats)) +
8401 (((uint64_t)ev->num_peer_extd_stats) *
8402 sizeof(wmi_peer_extd_stats));
8403 if (param_buf->num_data != min_data_len) {
8404 WMI_LOGE("data len: %u isn't same as calculated: %llu",
8405 param_buf->num_data, min_data_len);
8406 return QDF_STATUS_E_FAULT;
8407 }
8408
Govind Singhe7f2f342016-05-23 12:12:52 +05308409 stats_param->num_pdev_stats = ev->num_pdev_stats;
8410 stats_param->num_pdev_ext_stats = 0;
8411 stats_param->num_vdev_stats = ev->num_vdev_stats;
8412 stats_param->num_peer_stats = ev->num_peer_stats;
8413 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
8414 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308415 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05308416 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8417 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308418
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008419 /* if chain_stats is not populated */
8420 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
8421 return QDF_STATUS_SUCCESS;
8422
8423 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
8424 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
8425 return QDF_STATUS_SUCCESS;
8426
8427 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -07008428 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008429 return QDF_STATUS_SUCCESS;
8430
Harprit Chhabada4efe1fa2018-09-28 12:06:49 -07008431 if (rssi_event->num_per_chain_rssi_stats >=
8432 WMITLV_GET_TLVLEN(rssi_event->tlv_header)) {
8433 WMI_LOGE("num_per_chain_rssi_stats:%u is out of bounds",
8434 rssi_event->num_per_chain_rssi_stats);
8435 return QDF_STATUS_E_INVAL;
8436 }
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008437 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
8438
Govind Singhe7f2f342016-05-23 12:12:52 +05308439 return QDF_STATUS_SUCCESS;
8440}
8441
8442/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308443 * extract_pdev_tx_stats() - extract pdev tx stats from event
8444 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308445static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx,
8446 struct wlan_dbg_tx_stats_v2 *tx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308447{
8448 /* Tx Stats */
8449 tx->comp_queued = tx_stats->comp_queued;
8450 tx->comp_delivered = tx_stats->comp_delivered;
8451 tx->msdu_enqued = tx_stats->msdu_enqued;
8452 tx->mpdu_enqued = tx_stats->mpdu_enqued;
8453 tx->wmm_drop = tx_stats->wmm_drop;
8454 tx->local_enqued = tx_stats->local_enqued;
8455 tx->local_freed = tx_stats->local_freed;
8456 tx->hw_queued = tx_stats->hw_queued;
8457 tx->hw_reaped = tx_stats->hw_reaped;
8458 tx->underrun = tx_stats->underrun;
8459 tx->tx_abort = tx_stats->tx_abort;
8460 tx->mpdus_requed = tx_stats->mpdus_requed;
8461 tx->data_rc = tx_stats->data_rc;
8462 tx->self_triggers = tx_stats->self_triggers;
8463 tx->sw_retry_failure = tx_stats->sw_retry_failure;
8464 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
8465 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
8466 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
8467 tx->pdev_resets = tx_stats->pdev_resets;
8468 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
8469 tx->phy_underrun = tx_stats->phy_underrun;
8470 tx->txop_ovf = tx_stats->txop_ovf;
8471
8472 return;
8473}
8474
8475
8476/**
8477 * extract_pdev_rx_stats() - extract pdev rx stats from event
8478 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308479static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx,
8480 struct wlan_dbg_rx_stats_v2 *rx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308481{
8482 /* Rx Stats */
8483 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
8484 rx->status_rcvd = rx_stats->status_rcvd;
8485 rx->r0_frags = rx_stats->r0_frags;
8486 rx->r1_frags = rx_stats->r1_frags;
8487 rx->r2_frags = rx_stats->r2_frags;
8488 /* Only TLV */
8489 rx->r3_frags = 0;
8490 rx->htt_msdus = rx_stats->htt_msdus;
8491 rx->htt_mpdus = rx_stats->htt_mpdus;
8492 rx->loc_msdus = rx_stats->loc_msdus;
8493 rx->loc_mpdus = rx_stats->loc_mpdus;
8494 rx->oversize_amsdu = rx_stats->oversize_amsdu;
8495 rx->phy_errs = rx_stats->phy_errs;
8496 rx->phy_err_drop = rx_stats->phy_err_drop;
8497 rx->mpdu_errs = rx_stats->mpdu_errs;
8498
8499 return;
8500}
8501
8502/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308503 * extract_pdev_stats_tlv() - extract pdev stats from event
8504 * @wmi_handle: wmi handle
8505 * @param evt_buf: pointer to event buffer
8506 * @param index: Index into pdev stats
8507 * @param pdev_stats: Pointer to hold pdev stats
8508 *
8509 * Return: QDF_STATUS_SUCCESS for success or error code
8510 */
8511static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
8512 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
8513{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308514 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8515 wmi_stats_event_fixed_param *ev_param;
8516 uint8_t *data;
8517
8518 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8519 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8520
8521 data = param_buf->data;
8522
8523 if (index < ev_param->num_pdev_stats) {
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308524 wmi_pdev_stats_v2 *ev = (wmi_pdev_stats_v2 *) ((data) +
8525 (index * sizeof(wmi_pdev_stats_v2)));
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308526
8527 pdev_stats->chan_nf = ev->chan_nf;
8528 pdev_stats->tx_frame_count = ev->tx_frame_count;
8529 pdev_stats->rx_frame_count = ev->rx_frame_count;
8530 pdev_stats->rx_clear_count = ev->rx_clear_count;
8531 pdev_stats->cycle_count = ev->cycle_count;
8532 pdev_stats->phy_err_count = ev->phy_err_count;
8533 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
8534
8535 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
8536 &(ev->pdev_stats.tx));
8537 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
8538 &(ev->pdev_stats.rx));
8539 }
8540
Govind Singhe7f2f342016-05-23 12:12:52 +05308541 return QDF_STATUS_SUCCESS;
8542}
8543
8544/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008545 * extract_unit_test_tlv() - extract unit test data
8546 * @wmi_handle: wmi handle
8547 * @param evt_buf: pointer to event buffer
8548 * @param unit_test: pointer to hold unit test data
8549 * @param maxspace: Amount of space in evt_buf
8550 *
8551 * Return: QDF_STATUS_SUCCESS for success or error code
8552 */
8553static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
8554 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
8555{
8556 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
8557 wmi_unit_test_event_fixed_param *ev_param;
8558 uint32_t num_bufp;
8559 uint32_t copy_size;
8560 uint8_t *bufp;
8561
8562 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
8563 ev_param = param_buf->fixed_param;
8564 bufp = param_buf->bufp;
8565 num_bufp = param_buf->num_bufp;
8566 unit_test->vdev_id = ev_param->vdev_id;
8567 unit_test->module_id = ev_param->module_id;
8568 unit_test->diag_token = ev_param->diag_token;
8569 unit_test->flag = ev_param->flag;
8570 unit_test->payload_len = ev_param->payload_len;
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308571 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d", __func__,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008572 ev_param->vdev_id,
8573 ev_param->module_id,
8574 ev_param->diag_token,
8575 ev_param->flag);
8576 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
8577 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
8578 bufp, num_bufp);
8579 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
8580 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
8581 unit_test->buffer_len = copy_size;
8582
8583 return QDF_STATUS_SUCCESS;
8584}
8585
8586/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308587 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
8588 * @wmi_handle: wmi handle
8589 * @param evt_buf: pointer to event buffer
8590 * @param index: Index into extended pdev stats
8591 * @param pdev_ext_stats: Pointer to hold extended pdev stats
8592 *
8593 * Return: QDF_STATUS_SUCCESS for success or error code
8594 */
8595static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
8596 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
8597{
8598 return QDF_STATUS_SUCCESS;
8599}
8600
8601/**
8602 * extract_vdev_stats_tlv() - extract vdev stats from event
8603 * @wmi_handle: wmi handle
8604 * @param evt_buf: pointer to event buffer
8605 * @param index: Index into vdev stats
8606 * @param vdev_stats: Pointer to hold vdev stats
8607 *
8608 * Return: QDF_STATUS_SUCCESS for success or error code
8609 */
8610static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
8611 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
8612{
8613 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8614 wmi_stats_event_fixed_param *ev_param;
8615 uint8_t *data;
8616
8617 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8618 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8619 data = (uint8_t *) param_buf->data;
8620
8621 if (index < ev_param->num_vdev_stats) {
8622 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
8623 ((ev_param->num_pdev_stats) *
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308624 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308625 (index * sizeof(wmi_vdev_stats)));
8626
8627 vdev_stats->vdev_id = ev->vdev_id;
8628 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
8629 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
8630
8631 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
8632 sizeof(ev->tx_frm_cnt));
8633 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
8634 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
8635 ev->multiple_retry_cnt,
8636 sizeof(ev->multiple_retry_cnt));
8637 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
8638 sizeof(ev->fail_cnt));
8639 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
8640 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
8641 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
8642 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
8643 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
8644 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
8645 sizeof(ev->tx_rate_history));
8646 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
8647 sizeof(ev->bcn_rssi_history));
8648
8649 }
8650
8651 return QDF_STATUS_SUCCESS;
8652}
8653
8654/**
Naveen Rawatd2115722018-04-12 08:17:55 -07008655 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
8656 * buffer
8657 * @wmi_handle: wmi handle
8658 * @evt_buf: pointer to event buffer
8659 * @index: Index into vdev stats
8660 * @rssi_stats: Pointer to hold rssi stats
8661 *
8662 * Return: QDF_STATUS_SUCCESS for success or error code
8663 */
8664static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
8665 void *evt_buf, uint32_t index,
8666 struct wmi_host_per_chain_rssi_stats *rssi_stats)
8667{
8668 uint8_t *data;
8669 wmi_rssi_stats *fw_rssi_stats;
8670 wmi_per_chain_rssi_stats *rssi_event;
8671 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8672
8673 if (!evt_buf) {
8674 WMI_LOGE("evt_buf is null");
8675 return QDF_STATUS_E_NULL_VALUE;
8676 }
8677
8678 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8679 rssi_event = param_buf->chain_stats;
8680
8681 if (index >= rssi_event->num_per_chain_rssi_stats) {
8682 WMI_LOGE("invalid index");
8683 return QDF_STATUS_E_INVAL;
8684 }
8685
8686 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
8687 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
8688
8689 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
8690 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
8691 fw_rssi_stats->rssi_avg_beacon,
8692 sizeof(fw_rssi_stats->rssi_avg_beacon));
8693 qdf_mem_copy(rssi_stats->rssi_avg_data,
8694 fw_rssi_stats->rssi_avg_data,
8695 sizeof(fw_rssi_stats->rssi_avg_data));
8696 qdf_mem_copy(&rssi_stats->peer_macaddr,
8697 &fw_rssi_stats->peer_macaddr,
8698 sizeof(fw_rssi_stats->peer_macaddr));
8699
8700 return QDF_STATUS_SUCCESS;
8701}
8702
8703
8704
8705/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308706 * extract_bcn_stats_tlv() - extract bcn stats from event
8707 * @wmi_handle: wmi handle
8708 * @param evt_buf: pointer to event buffer
8709 * @param index: Index into vdev stats
8710 * @param bcn_stats: Pointer to hold bcn stats
8711 *
8712 * Return: QDF_STATUS_SUCCESS for success or error code
8713 */
8714static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
8715 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
8716{
8717 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8718 wmi_stats_event_fixed_param *ev_param;
8719 uint8_t *data;
8720
8721 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8722 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8723 data = (uint8_t *) param_buf->data;
8724
8725 if (index < ev_param->num_bcn_stats) {
8726 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308727 ((ev_param->num_pdev_stats) *
8728 sizeof(wmi_pdev_stats_v2)) +
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308729 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8730 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8731 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
8732 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
8733 (index * sizeof(wmi_bcn_stats)));
8734
8735 bcn_stats->vdev_id = ev->vdev_id;
8736 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
8737 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
8738 }
8739
8740 return QDF_STATUS_SUCCESS;
8741}
8742
8743/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308744 * extract_peer_stats_tlv() - extract peer stats from event
8745 * @wmi_handle: wmi handle
8746 * @param evt_buf: pointer to event buffer
8747 * @param index: Index into peer stats
8748 * @param peer_stats: Pointer to hold peer stats
8749 *
8750 * Return: QDF_STATUS_SUCCESS for success or error code
8751 */
8752static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
8753 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
8754{
8755 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8756 wmi_stats_event_fixed_param *ev_param;
8757 uint8_t *data;
8758
8759 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8760 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8761 data = (uint8_t *) param_buf->data;
8762
8763 if (index < ev_param->num_peer_stats) {
8764 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308765 ((ev_param->num_pdev_stats) *
8766 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308767 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8768 (index * sizeof(wmi_peer_stats)));
8769
8770 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
8771
8772 OS_MEMCPY(&(peer_stats->peer_macaddr),
8773 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
8774
8775 peer_stats->peer_rssi = ev->peer_rssi;
8776 peer_stats->peer_tx_rate = ev->peer_tx_rate;
8777 peer_stats->peer_rx_rate = ev->peer_rx_rate;
8778 }
8779
8780 return QDF_STATUS_SUCCESS;
8781}
8782
8783/**
8784 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
8785 * @wmi_handle: wmi handle
8786 * @param evt_buf: pointer to event buffer
8787 * @param index: Index into bcn fault stats
8788 * @param bcnflt_stats: Pointer to hold bcn fault stats
8789 *
8790 * Return: QDF_STATUS_SUCCESS for success or error code
8791 */
8792static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
8793 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
8794{
8795 return QDF_STATUS_SUCCESS;
8796}
8797
8798/**
8799 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
8800 * @wmi_handle: wmi handle
8801 * @param evt_buf: pointer to event buffer
8802 * @param index: Index into extended peer stats
8803 * @param peer_extd_stats: Pointer to hold extended peer stats
8804 *
8805 * Return: QDF_STATUS_SUCCESS for success or error code
8806 */
8807static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
8808 void *evt_buf, uint32_t index,
8809 wmi_host_peer_extd_stats *peer_extd_stats)
8810{
8811 return QDF_STATUS_SUCCESS;
8812}
8813
8814/**
8815 * extract_chan_stats_tlv() - extract chan stats from event
8816 * @wmi_handle: wmi handle
8817 * @param evt_buf: pointer to event buffer
8818 * @param index: Index into chan stats
8819 * @param vdev_extd_stats: Pointer to hold chan stats
8820 *
8821 * Return: QDF_STATUS_SUCCESS for success or error code
8822 */
8823static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
8824 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
8825{
8826 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8827 wmi_stats_event_fixed_param *ev_param;
8828 uint8_t *data;
8829
8830 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8831 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8832 data = (uint8_t *) param_buf->data;
8833
8834 if (index < ev_param->num_chan_stats) {
8835 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308836 ((ev_param->num_pdev_stats) *
8837 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308838 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8839 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8840 (index * sizeof(wmi_chan_stats)));
8841
8842
Jeff Johnson79eaacb2018-05-06 17:53:18 -07008843 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +05308844 chan_stats->chan_mhz = ev->chan_mhz;
8845 chan_stats->sampling_period_us = ev->sampling_period_us;
8846 chan_stats->rx_clear_count = ev->rx_clear_count;
8847 chan_stats->tx_duration_us = ev->tx_duration_us;
8848 chan_stats->rx_duration_us = ev->rx_duration_us;
8849 }
8850
8851 return QDF_STATUS_SUCCESS;
8852}
8853
8854/**
8855 * extract_profile_ctx_tlv() - extract profile context from event
8856 * @wmi_handle: wmi handle
8857 * @param evt_buf: pointer to event buffer
8858 * @idx: profile stats index to extract
8859 * @param profile_ctx: Pointer to hold profile context
8860 *
8861 * Return: QDF_STATUS_SUCCESS for success or error code
8862 */
8863static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
8864 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
8865{
8866 return QDF_STATUS_SUCCESS;
8867}
8868
8869/**
8870 * extract_profile_data_tlv() - extract profile data from event
8871 * @wmi_handle: wmi handle
8872 * @param evt_buf: pointer to event buffer
8873 * @param profile_data: Pointer to hold profile data
8874 *
8875 * Return: QDF_STATUS_SUCCESS for success or error code
8876 */
8877static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
8878 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
8879{
8880
8881 return QDF_STATUS_SUCCESS;
8882}
8883
8884/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308885 * extract_pdev_utf_event_tlv() - extract UTF data info from event
8886 * @wmi_handle: WMI handle
8887 * @param evt_buf: Pointer to event buffer
8888 * @param param: Pointer to hold data
8889 *
8890 * Return : QDF_STATUS_SUCCESS for success or error code
8891 */
8892static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
8893 uint8_t *evt_buf,
8894 struct wmi_host_pdev_utf_event *event)
8895{
8896 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308897 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308898
8899 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
8900 event->data = param_buf->data;
8901 event->datalen = param_buf->num_data;
Pragaspathi Thilagarajd8d0e152018-09-04 14:39:09 +05308902
8903 if (event->datalen < sizeof(struct wmi_host_utf_seg_header_info)) {
8904 WMI_LOGE("%s: Invalid datalen: %d ", __func__, event->datalen);
8905 return QDF_STATUS_E_INVAL;
8906 }
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308907 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +05308908 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308909 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308910 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308911
8912 return QDF_STATUS_SUCCESS;
8913}
Govind Singhe7f2f342016-05-23 12:12:52 +05308914
Kiran Venkatappa06520822016-08-10 23:55:40 +05308915/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308916 * extract_chainmask_tables_tlv() - extract chain mask tables from event
8917 * @wmi_handle: wmi handle
8918 * @param evt_buf: pointer to event buffer
8919 * @param param: Pointer to hold evt buf
8920 *
8921 * Return: QDF_STATUS_SUCCESS for success or error code
8922 */
8923static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
8924 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
8925{
8926 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
8927 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
8928 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
8929 uint8_t i = 0, j = 0;
8930
8931 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
8932 if (!param_buf)
8933 return QDF_STATUS_E_INVAL;
8934
8935 hw_caps = param_buf->soc_hw_mode_caps;
8936 if (!hw_caps)
8937 return QDF_STATUS_E_INVAL;
8938
Wu Gao5d1c9ed2018-10-12 18:16:09 +08008939 if ((!hw_caps->num_chainmask_tables) ||
Pragaspathi Thilagaraj9ad6eca2018-10-24 18:36:47 +05308940 (hw_caps->num_chainmask_tables > PSOC_MAX_CHAINMASK_TABLES) ||
8941 (hw_caps->num_chainmask_tables >
8942 param_buf->num_mac_phy_chainmask_combo))
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308943 return QDF_STATUS_E_INVAL;
8944
8945 chainmask_caps = param_buf->mac_phy_chainmask_caps;
8946
8947 if (chainmask_caps == NULL)
8948 return QDF_STATUS_E_INVAL;
8949
8950 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
8951
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308952 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308953 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
8954
8955 chainmask_table[i].cap_list[j].chainmask =
8956 chainmask_caps->chainmask;
8957
8958 chainmask_table[i].cap_list[j].supports_chan_width_20 =
8959 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
8960
8961 chainmask_table[i].cap_list[j].supports_chan_width_40 =
8962 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
8963
8964 chainmask_table[i].cap_list[j].supports_chan_width_80 =
8965 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
8966
8967 chainmask_table[i].cap_list[j].supports_chan_width_160 =
8968 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
8969
8970 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
8971 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
8972
8973 chainmask_table[i].cap_list[j].chain_mask_2G =
8974 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
8975
8976 chainmask_table[i].cap_list[j].chain_mask_5G =
8977 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
8978
8979 chainmask_table[i].cap_list[j].chain_mask_tx =
8980 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
8981
8982 chainmask_table[i].cap_list[j].chain_mask_rx =
8983 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
8984
8985 chainmask_table[i].cap_list[j].supports_aDFS =
8986 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
8987
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308988 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
8989 chainmask_caps->supported_flags,
8990 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308991 );
8992 chainmask_caps++;
8993 }
8994 }
8995
8996 return QDF_STATUS_SUCCESS;
8997}
8998
8999/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05309000 * extract_service_ready_ext_tlv() - extract basic extended service ready params
9001 * from event
9002 * @wmi_handle: wmi handle
9003 * @param evt_buf: pointer to event buffer
9004 * @param param: Pointer to hold evt buf
9005 *
9006 * Return: QDF_STATUS_SUCCESS for success or error code
9007 */
9008static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009009 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309010{
9011 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9012 wmi_service_ready_ext_event_fixed_param *ev;
9013 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9014 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309015 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
9016 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309017
9018 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9019 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309020 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309021
9022 ev = param_buf->fixed_param;
9023 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309024 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309025
9026 /* Move this to host based bitmap */
9027 param->default_conc_scan_config_bits =
9028 ev->default_conc_scan_config_bits;
9029 param->default_fw_config_bits = ev->default_fw_config_bits;
9030 param->he_cap_info = ev->he_cap_info;
9031 param->mpdu_density = ev->mpdu_density;
9032 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05309033 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +05309034 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07009035 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309036 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
9037
9038 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309039 if (hw_caps)
9040 param->num_hw_modes = hw_caps->num_hw_modes;
9041 else
9042 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309043
9044 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309045 if (reg_caps)
9046 param->num_phy = reg_caps->num_phy;
9047 else
9048 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309049
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309050 if (hw_caps) {
9051 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309052 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309053 } else
9054 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309055
Harprit Chhabada00ef4b72018-10-18 13:27:56 -07009056 if (param->num_chainmask_tables > PSOC_MAX_CHAINMASK_TABLES ||
9057 param->num_chainmask_tables >
9058 param_buf->num_mac_phy_chainmask_combo) {
9059 wmi_err_rl("num_chainmask_tables is OOB: %u",
9060 param->num_chainmask_tables);
9061 return QDF_STATUS_E_INVAL;
9062 }
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309063 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
9064
9065 if (chain_mask_combo == NULL)
9066 return QDF_STATUS_SUCCESS;
9067
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309068 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309069
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309070 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309071
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309072 qdf_print("table_id : %d Num valid chainmasks: %d",
9073 chain_mask_combo->chainmask_table_id,
9074 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309075 );
9076
9077 param->chainmask_table[i].table_id =
9078 chain_mask_combo->chainmask_table_id;
9079 param->chainmask_table[i].num_valid_chainmasks =
9080 chain_mask_combo->num_valid_chainmask;
9081 chain_mask_combo++;
9082 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309083 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309084
Kiran Venkatappa06520822016-08-10 23:55:40 +05309085 return QDF_STATUS_SUCCESS;
9086}
9087
9088/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009089 * extract_sar_cap_service_ready_ext_tlv() -
9090 * extract SAR cap from service ready event
9091 * @wmi_handle: wmi handle
9092 * @event: pointer to event buffer
9093 * @ext_param: extended target info
9094 *
9095 * Return: QDF_STATUS_SUCCESS for success or error code
9096 */
9097static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
9098 wmi_unified_t wmi_handle,
9099 uint8_t *event,
9100 struct wlan_psoc_host_service_ext_param *ext_param)
9101{
9102 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9103 WMI_SAR_CAPABILITIES *sar_caps;
9104
9105 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9106
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009107 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009108 return QDF_STATUS_E_INVAL;
9109
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009110 sar_caps = param_buf->sar_caps;
9111 if (sar_caps)
9112 ext_param->sar_version = sar_caps->active_version;
9113 else
9114 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009115
9116 return QDF_STATUS_SUCCESS;
9117}
9118
9119/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05309120 * extract_hw_mode_cap_service_ready_ext_tlv() -
9121 * extract HW mode cap from service ready event
9122 * @wmi_handle: wmi handle
9123 * @param evt_buf: pointer to event buffer
9124 * @param param: Pointer to hold evt buf
9125 * @param hw_mode_idx: hw mode idx should be less than num_mode
9126 *
9127 * Return: QDF_STATUS_SUCCESS for success or error code
9128 */
9129static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
9130 wmi_unified_t wmi_handle,
9131 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009132 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309133{
9134 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9135 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9136
9137 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9138 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309139 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309140
9141 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309142 if (!hw_caps)
9143 return QDF_STATUS_E_INVAL;
9144
Kiran Venkatappa06520822016-08-10 23:55:40 +05309145 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309146 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309147
9148 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
9149 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
9150
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309151 param->hw_mode_config_type =
9152 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
9153
Kiran Venkatappa06520822016-08-10 23:55:40 +05309154 return QDF_STATUS_SUCCESS;
9155}
9156
9157/**
9158 * extract_mac_phy_cap_service_ready_ext_tlv() -
9159 * extract MAC phy cap from service ready event
9160 * @wmi_handle: wmi handle
9161 * @param evt_buf: pointer to event buffer
9162 * @param param: Pointer to hold evt buf
9163 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309164 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +05309165 *
9166 * Return: QDF_STATUS_SUCCESS for success or error code
9167 */
9168static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
9169 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309170 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009171 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309172{
9173 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309174 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309175 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9176 uint32_t phy_map;
9177 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309178
9179 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9180 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309181 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309182
9183 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309184 if (!hw_caps)
9185 return QDF_STATUS_E_INVAL;
9186
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309187 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
9188 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
9189 break;
9190
9191 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
9192 while (phy_map) {
9193 phy_map >>= 1;
9194 phy_idx++;
9195 }
9196 }
9197
9198 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309199 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309200
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309201 phy_idx += phy_id;
9202 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309203 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309204
9205 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +05309206
9207 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309208 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9209 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309210 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309211 param->supports_11b =
9212 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
9213 param->supports_11g =
9214 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
9215 param->supports_11a =
9216 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
9217 param->supports_11n =
9218 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
9219 param->supports_11ac =
9220 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
9221 param->supports_11ax =
9222 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309223
9224 param->supported_bands = mac_phy_caps->supported_bands;
9225 param->ampdu_density = mac_phy_caps->ampdu_density;
9226 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
9227 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
9228 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
9229 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009230 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD1] =
9231 mac_phy_caps->he_cap_info_2G;
9232 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD2] =
9233 mac_phy_caps->he_cap_info_2G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309234 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
9235 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
9236 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
9237 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
9238 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
9239 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
9240 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009241 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD1] =
9242 mac_phy_caps->he_cap_info_5G;
9243 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD2] =
9244 mac_phy_caps->he_cap_info_5G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309245 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
9246 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
9247 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -08009248 qdf_mem_copy(&param->he_cap_phy_info_2G,
9249 &mac_phy_caps->he_cap_phy_info_2G,
9250 sizeof(param->he_cap_phy_info_2G));
9251 qdf_mem_copy(&param->he_cap_phy_info_5G,
9252 &mac_phy_caps->he_cap_phy_info_5G,
9253 sizeof(param->he_cap_phy_info_5G));
9254 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
9255 sizeof(param->he_ppet2G));
9256 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
9257 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309258 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309259
9260 return QDF_STATUS_SUCCESS;
9261}
9262
9263/**
9264 * extract_reg_cap_service_ready_ext_tlv() -
9265 * extract REG cap from service ready event
9266 * @wmi_handle: wmi handle
9267 * @param evt_buf: pointer to event buffer
9268 * @param param: Pointer to hold evt buf
9269 * @param phy_idx: phy idx should be less than num_mode
9270 *
9271 * Return: QDF_STATUS_SUCCESS for success or error code
9272 */
9273static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
9274 wmi_unified_t wmi_handle,
9275 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009276 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309277{
9278 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9279 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
9280 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
9281
9282 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9283 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309284 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309285
9286 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309287 if (!reg_caps)
9288 return QDF_STATUS_E_INVAL;
9289
Kiran Venkatappa06520822016-08-10 23:55:40 +05309290 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309291 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309292
9293 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
9294
9295 param->phy_id = ext_reg_cap->phy_id;
9296 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
9297 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
9298 param->regcap1 = ext_reg_cap->regcap1;
9299 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05309300 param->wireless_modes = convert_wireless_modes_tlv(
9301 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309302 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
9303 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
9304 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
9305 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
9306
9307 return QDF_STATUS_SUCCESS;
9308}
9309
Sathish Kumarf396c722017-11-17 17:30:41 +05309310static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
9311 wmi_unified_t wmi_handle,
9312 uint8_t *event, uint8_t idx,
9313 struct wlan_psoc_host_dbr_ring_caps *param)
9314{
9315 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9316 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
9317
9318 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9319 if (!param_buf)
9320 return QDF_STATUS_E_INVAL;
9321
9322 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
9323
9324 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9325 dbr_ring_caps->pdev_id);
9326 param->mod_id = dbr_ring_caps->mod_id;
9327 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
9328 param->min_buf_size = dbr_ring_caps->min_buf_size;
9329 param->min_buf_align = dbr_ring_caps->min_buf_align;
9330
9331 return QDF_STATUS_SUCCESS;
9332}
9333
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309334/**
9335 * extract_thermal_stats_tlv() - extract thermal stats from event
9336 * @wmi_handle: wmi handle
9337 * @param evt_buf: Pointer to event buffer
9338 * @param temp: Pointer to hold extracted temperature
9339 * @param level: Pointer to hold extracted level
9340 *
9341 * Return: 0 for success or error code
9342 */
9343static QDF_STATUS
9344extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
9345 void *evt_buf, uint32_t *temp,
9346 uint32_t *level, uint32_t *pdev_id)
9347{
9348 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9349 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
9350
9351 param_buf =
9352 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9353 if (!param_buf)
9354 return QDF_STATUS_E_INVAL;
9355
9356 tt_stats_event = param_buf->fixed_param;
9357
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309358 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9359 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309360 *temp = tt_stats_event->temp;
9361 *level = tt_stats_event->level;
9362
9363 return QDF_STATUS_SUCCESS;
9364}
9365
9366/**
9367 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
9368 * @wmi_handle: wmi handle
9369 * @param evt_buf: pointer to event buffer
9370 * @param idx: Index to level stats
9371 * @param levelcount: Pointer to hold levelcount
9372 * @param dccount: Pointer to hold dccount
9373 *
9374 * Return: 0 for success or error code
9375 */
9376static QDF_STATUS
9377extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
9378 void *evt_buf, uint8_t idx, uint32_t *levelcount,
9379 uint32_t *dccount)
9380{
9381 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9382 wmi_therm_throt_level_stats_info *tt_level_info;
9383
9384 param_buf =
9385 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9386 if (!param_buf)
9387 return QDF_STATUS_E_INVAL;
9388
9389 tt_level_info = param_buf->therm_throt_level_stats_info;
9390
9391 if (idx < THERMAL_LEVELS) {
9392 *levelcount = tt_level_info[idx].level_count;
9393 *dccount = tt_level_info[idx].dc_count;
9394 return QDF_STATUS_SUCCESS;
9395 }
9396
9397 return QDF_STATUS_E_FAILURE;
9398}
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309399#ifdef BIG_ENDIAN_HOST
9400/**
9401 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
9402 * @param data_len - data length
9403 * @param data - pointer to data
9404 *
9405 * Return: QDF_STATUS - success or error status
9406 */
9407static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9408{
9409 uint8_t *data_aligned = NULL;
9410 int c;
9411 unsigned char *data_unaligned;
9412
9413 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
9414 FIPS_ALIGN));
9415 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -07009416 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309417 if (data_unaligned == NULL)
9418 return QDF_STATUS_E_FAILURE;
9419
9420 /* Checking if space is alligned */
9421 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
9422 /* align the data space */
9423 data_aligned =
9424 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
9425 } else {
9426 data_aligned = (u_int8_t *)data_unaligned;
9427 }
9428
9429 /* memset and copy content from data to data aligned */
9430 OS_MEMSET(data_aligned, 0, data_len);
9431 OS_MEMCPY(data_aligned, data, data_len);
9432 /* Endianness to LE */
9433 for (c = 0; c < data_len/4; c++) {
9434 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +05309435 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309436 }
9437
9438 /* Copy content to event->data */
9439 OS_MEMCPY(data, data_aligned, data_len);
9440
9441 /* clean up allocated space */
9442 qdf_mem_free(data_unaligned);
9443 data_aligned = NULL;
9444 data_unaligned = NULL;
9445
9446 /*************************************************************/
9447
9448 return QDF_STATUS_SUCCESS;
9449}
9450#else
9451/**
9452 * fips_conv_data_be() - DUMMY for LE platform
9453 *
9454 * Return: QDF_STATUS - success
9455 */
9456static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9457{
9458 return QDF_STATUS_SUCCESS;
9459}
9460#endif
9461
9462/**
9463 * extract_fips_event_data_tlv() - extract fips event data
9464 * @wmi_handle: wmi handle
9465 * @param evt_buf: pointer to event buffer
9466 * @param param: pointer FIPS event params
9467 *
9468 * Return: 0 for success or error code
9469 */
9470static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
9471 void *evt_buf, struct wmi_host_fips_event_param *param)
9472{
9473 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
9474 wmi_pdev_fips_event_fixed_param *event;
9475
9476 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
9477 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
9478
9479 if (fips_conv_data_be(event->data_len, param_buf->data) !=
9480 QDF_STATUS_SUCCESS)
9481 return QDF_STATUS_E_FAILURE;
9482
9483 param->data = (uint32_t *)param_buf->data;
9484 param->data_len = event->data_len;
9485 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309486 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9487 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309488
9489 return QDF_STATUS_SUCCESS;
9490}
9491
Govind Singhecf03cd2016-05-12 12:45:51 +05309492static bool is_management_record_tlv(uint32_t cmd_id)
9493{
Rajeev Kumar173bef42018-09-18 16:45:39 -07009494 switch (cmd_id) {
9495 case WMI_MGMT_TX_SEND_CMDID:
9496 case WMI_MGMT_TX_COMPLETION_EVENTID:
9497 case WMI_OFFCHAN_DATA_TX_SEND_CMDID:
9498 case WMI_MGMT_RX_EVENTID:
Govind Singhecf03cd2016-05-12 12:45:51 +05309499 return true;
Rajeev Kumar173bef42018-09-18 16:45:39 -07009500 default:
9501 return false;
jiad36c94d22018-01-22 15:37:03 +08009502 }
Govind Singhecf03cd2016-05-12 12:45:51 +05309503}
9504
Rajeev Kumarb64e1282018-09-19 13:02:23 -07009505static bool is_diag_event_tlv(uint32_t event_id)
9506{
9507 if (WMI_DIAG_EVENTID == event_id)
9508 return true;
9509
9510 return false;
9511}
9512
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309513static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9514{
9515 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
9516
9517 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
9518
9519 switch (set_cmd->param_id) {
9520 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
9521 case WMI_VDEV_PARAM_DTIM_POLICY:
9522 return HTC_TX_PACKET_TAG_AUTO_PM;
9523 default:
9524 break;
9525 }
9526
9527 return 0;
9528}
9529
9530static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9531{
9532 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
9533
9534 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
9535
9536 switch (ps_cmd->param) {
9537 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
9538 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
9539 case WMI_STA_PS_ENABLE_QPOWER:
9540 return HTC_TX_PACKET_TAG_AUTO_PM;
9541 default:
9542 break;
9543 }
9544
9545 return 0;
9546}
9547
9548static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
9549 uint32_t cmd_id)
9550{
9551 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
9552 return 0;
9553
9554 switch (cmd_id) {
9555 case WMI_VDEV_SET_PARAM_CMDID:
9556 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
9557 case WMI_STA_POWERSAVE_PARAM_CMDID:
9558 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
9559 default:
9560 break;
9561 }
9562
9563 return 0;
9564}
9565
9566static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
9567{
9568 uint16_t tag = 0;
9569
9570 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309571 pr_err("%s: Target is already suspended, Ignore FW Hang Command",
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309572 __func__);
9573 return tag;
9574 }
9575
9576 if (wmi_handle->tag_crash_inject)
9577 tag = HTC_TX_PACKET_TAG_AUTO_PM;
9578
9579 wmi_handle->tag_crash_inject = false;
9580 return tag;
9581}
9582
9583/**
9584 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
9585 * @wmi_handle: WMI handle
9586 * @buf: WMI buffer
9587 * @cmd_id: WMI command Id
9588 *
9589 * Return htc_tx_tag
9590 */
9591static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
9592 wmi_buf_t buf,
9593 uint32_t cmd_id)
9594{
9595 uint16_t htc_tx_tag = 0;
9596
9597 switch (cmd_id) {
9598 case WMI_WOW_ENABLE_CMDID:
9599 case WMI_PDEV_SUSPEND_CMDID:
9600 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
9601 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
9602 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
9603 case WMI_PDEV_RESUME_CMDID:
9604 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
9605 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
9606#ifdef FEATURE_WLAN_D0WOW
9607 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
9608#endif
9609 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
9610 break;
9611 case WMI_FORCE_FW_HANG_CMDID:
9612 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
9613 break;
9614 case WMI_VDEV_SET_PARAM_CMDID:
9615 case WMI_STA_POWERSAVE_PARAM_CMDID:
9616 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
9617 default:
9618 break;
9619 }
9620
9621 return htc_tx_tag;
9622}
9623
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309624static struct cur_reg_rule
9625*create_reg_rules_from_wmi(uint32_t num_reg_rules,
9626 wmi_regulatory_rule_struct *wmi_reg_rule)
9627{
9628 struct cur_reg_rule *reg_rule_ptr;
9629 uint32_t count;
9630
9631 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
9632
9633 if (NULL == reg_rule_ptr) {
9634 WMI_LOGE("memory allocation failure");
9635 return NULL;
9636 }
9637
9638 for (count = 0; count < num_reg_rules; count++) {
9639 reg_rule_ptr[count].start_freq =
9640 WMI_REG_RULE_START_FREQ_GET(
9641 wmi_reg_rule[count].freq_info);
9642 reg_rule_ptr[count].end_freq =
9643 WMI_REG_RULE_END_FREQ_GET(
9644 wmi_reg_rule[count].freq_info);
9645 reg_rule_ptr[count].max_bw =
9646 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009647 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309648 reg_rule_ptr[count].reg_power =
9649 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009650 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +05309651 reg_rule_ptr[count].ant_gain =
9652 WMI_REG_RULE_ANTENNA_GAIN_GET(
9653 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309654 reg_rule_ptr[count].flags =
9655 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009656 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309657 }
9658
9659 return reg_rule_ptr;
9660}
9661
9662static QDF_STATUS extract_reg_chan_list_update_event_tlv(
9663 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9664 struct cur_regulatory_info *reg_info, uint32_t len)
9665{
9666 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
9667 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
9668 wmi_regulatory_rule_struct *wmi_reg_rule;
9669 uint32_t num_2g_reg_rules, num_5g_reg_rules;
9670
9671 WMI_LOGD("processing regulatory channel list");
9672
9673 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
9674 if (!param_buf) {
9675 WMI_LOGE("invalid channel list event buf");
9676 return QDF_STATUS_E_FAILURE;
9677 }
9678
9679 chan_list_event_hdr = param_buf->fixed_param;
9680
9681 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
9682 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
Jianmin Zhu8a3cccb2018-10-10 17:03:28 +08009683 num_2g_reg_rules = reg_info->num_2g_reg_rules;
9684 num_5g_reg_rules = reg_info->num_5g_reg_rules;
9685 if ((num_2g_reg_rules > MAX_REG_RULES) ||
9686 (num_5g_reg_rules > MAX_REG_RULES) ||
9687 (num_2g_reg_rules + num_5g_reg_rules > MAX_REG_RULES) ||
9688 (num_2g_reg_rules + num_5g_reg_rules !=
9689 param_buf->num_reg_rule_array)) {
9690 wmi_err_rl("Invalid num_2g_reg_rules: %u, num_5g_reg_rules: %u",
9691 num_2g_reg_rules, num_5g_reg_rules);
9692 return QDF_STATUS_E_FAILURE;
9693 }
9694 if (param_buf->num_reg_rule_array >
9695 (WMI_SVC_MSG_MAX_SIZE - sizeof(*chan_list_event_hdr)) /
9696 sizeof(*wmi_reg_rule)) {
9697 wmi_err_rl("Invalid num_reg_rule_array: %u",
9698 param_buf->num_reg_rule_array);
9699 return QDF_STATUS_E_FAILURE;
9700 }
9701
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309702 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +05309703 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309704 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
9705 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -07009706 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -07009707 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +05309708 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -07009709 reg_info->ctry_code = chan_list_event_hdr->country_id;
9710 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
9711 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
9712 reg_info->status_code = REG_SET_CC_STATUS_PASS;
9713 else if (chan_list_event_hdr->status_code ==
9714 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
9715 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
9716 else if (chan_list_event_hdr->status_code ==
9717 WMI_REG_INIT_ALPHA2_NOT_FOUND)
9718 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
9719 else if (chan_list_event_hdr->status_code ==
9720 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
9721 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
9722 else if (chan_list_event_hdr->status_code ==
9723 WMI_REG_SET_CC_STATUS_NO_MEMORY)
9724 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
9725 else if (chan_list_event_hdr->status_code ==
9726 WMI_REG_SET_CC_STATUS_FAIL)
9727 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
9728
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309729 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
9730 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
9731 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
9732 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
9733
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009734 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
9735 __func__, reg_info->alpha2, reg_info->dfs_region,
9736 reg_info->min_bw_2g, reg_info->max_bw_2g,
9737 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309738
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009739 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
9740 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -07009741 wmi_reg_rule =
9742 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
9743 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
9744 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309745 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
9746 wmi_reg_rule);
9747 wmi_reg_rule += num_2g_reg_rules;
9748
9749 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
9750 wmi_reg_rule);
9751
9752 WMI_LOGD("processed regulatory channel list");
9753
9754 return QDF_STATUS_SUCCESS;
9755}
9756
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009757static QDF_STATUS extract_reg_11d_new_country_event_tlv(
9758 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9759 struct reg_11d_new_country *reg_11d_country, uint32_t len)
9760{
9761 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
9762 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
9763
9764 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
9765 if (!param_buf) {
9766 WMI_LOGE("invalid 11d country event buf");
9767 return QDF_STATUS_E_FAILURE;
9768 }
9769
9770 reg_11d_country_event = param_buf->fixed_param;
9771
9772 qdf_mem_copy(reg_11d_country->alpha2,
9773 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
Jianmin Zhuf6d5a652018-10-11 20:30:58 +08009774 reg_11d_country->alpha2[REG_ALPHA2_LEN] = '\0';
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009775
9776 WMI_LOGD("processed 11d country event, new cc %s",
9777 reg_11d_country->alpha2);
9778
9779 return QDF_STATUS_SUCCESS;
9780}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009781
9782static QDF_STATUS extract_reg_ch_avoid_event_tlv(
9783 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9784 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
9785{
9786 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
9787 wmi_avoid_freq_range_desc *afr_desc;
9788 uint32_t num_freq_ranges, freq_range_idx;
9789 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
9790 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
9791
9792 if (!param_buf) {
9793 WMI_LOGE("Invalid channel avoid event buffer");
9794 return QDF_STATUS_E_INVAL;
9795 }
9796
9797 afr_fixed_param = param_buf->fixed_param;
9798 if (!afr_fixed_param) {
9799 WMI_LOGE("Invalid channel avoid event fixed param buffer");
9800 return QDF_STATUS_E_INVAL;
9801 }
9802
9803 if (!ch_avoid_ind) {
9804 WMI_LOGE("Invalid channel avoid indication buffer");
9805 return QDF_STATUS_E_INVAL;
9806 }
Kiran Kumar Lokere7d312042018-09-19 16:55:34 -07009807 if (param_buf->num_avd_freq_range < afr_fixed_param->num_freq_ranges) {
9808 WMI_LOGE(FL("no.of freq ranges exceeded the limit"));
9809 return QDF_STATUS_E_INVAL;
9810 }
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009811 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
9812 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
9813 afr_fixed_param->num_freq_ranges;
9814
9815 WMI_LOGD("Channel avoid event received with %d ranges",
9816 num_freq_ranges);
9817
9818 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
9819 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
9820 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
9821 freq_range_idx++) {
9822 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
9823 afr_desc->start_freq;
9824 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
9825 afr_desc->end_freq;
9826 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
9827 freq_range_idx, afr_desc->tlv_header,
9828 afr_desc->start_freq, afr_desc->end_freq);
9829 afr_desc++;
9830 }
9831
9832 return QDF_STATUS_SUCCESS;
9833}
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309834
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009835#ifdef DFS_COMPONENT_ENABLE
9836/**
9837 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
9838 * @wmi_handle: wma handle
9839 * @evt_buf: event buffer
9840 * @vdev_id: vdev id
9841 * @len: length of buffer
9842 *
9843 * Return: 0 for success or error code
9844 */
9845static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
9846 uint8_t *evt_buf,
9847 uint32_t *vdev_id,
9848 uint32_t len)
9849{
9850 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
9851 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
9852
9853 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
9854 if (!param_tlvs) {
9855 WMI_LOGE("invalid cac complete event buf");
9856 return QDF_STATUS_E_FAILURE;
9857 }
9858
9859 cac_event = param_tlvs->fixed_param;
9860 *vdev_id = cac_event->vdev_id;
9861 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
9862
9863 return QDF_STATUS_SUCCESS;
9864}
9865
9866/**
9867 * extract_dfs_radar_detection_event_tlv() - extract radar found event
9868 * @wmi_handle: wma handle
9869 * @evt_buf: event buffer
9870 * @radar_found: radar found event info
9871 * @len: length of buffer
9872 *
9873 * Return: 0 for success or error code
9874 */
9875static QDF_STATUS extract_dfs_radar_detection_event_tlv(
9876 wmi_unified_t wmi_handle,
9877 uint8_t *evt_buf,
9878 struct radar_found_info *radar_found,
9879 uint32_t len)
9880{
9881 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
9882 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
9883
9884 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
9885 if (!param_tlv) {
9886 WMI_LOGE("invalid radar detection event buf");
9887 return QDF_STATUS_E_FAILURE;
9888 }
9889
9890 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -07009891 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
9892 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009893 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009894 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009895 radar_found->chan_width = radar_event->chan_width;
9896 radar_found->detector_id = radar_event->detector_id;
9897 radar_found->segment_id = radar_event->segment_id;
9898 radar_found->timestamp = radar_event->timestamp;
9899 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009900 radar_found->freq_offset = radar_event->freq_offset;
9901 radar_found->sidx = radar_event->sidx;
9902
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009903 WMI_LOGI("processed radar found event pdev %d,"
9904 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
9905 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
9906 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309907 "is_chirp %d,detection mode %d",
Arif Hussainb522ac92018-06-27 10:51:06 -07009908 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009909 radar_event->timestamp, radar_event->chan_freq,
9910 radar_event->chan_width, radar_event->detector_id,
9911 radar_event->freq_offset, radar_event->segment_id,
9912 radar_event->sidx, radar_event->is_chirp,
9913 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009914
9915 return QDF_STATUS_SUCCESS;
9916}
bings1ea12532017-12-18 16:56:53 +08009917
9918#ifdef QCA_MCL_DFS_SUPPORT
9919/**
9920 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
9921 * @wmi_handle: wma handle
9922 * @evt_buf: event buffer
9923 * @wlan_radar_event: Pointer to struct radar_event_info
9924 * @len: length of buffer
9925 *
9926 * Return: QDF_STATUS
9927 */
9928static QDF_STATUS extract_wlan_radar_event_info_tlv(
9929 wmi_unified_t wmi_handle,
9930 uint8_t *evt_buf,
9931 struct radar_event_info *wlan_radar_event,
9932 uint32_t len)
9933{
9934 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
9935 wmi_dfs_radar_event_fixed_param *radar_event;
9936
9937 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
9938 if (!param_tlv) {
9939 WMI_LOGE("invalid wlan radar event buf");
9940 return QDF_STATUS_E_FAILURE;
9941 }
9942
9943 radar_event = param_tlv->fixed_param;
9944 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
9945 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
9946 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
9947 wlan_radar_event->rssi = radar_event->rssi;
9948 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
9949 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
9950 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
9951 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +08009952 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
9953 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +08009954 if (radar_event->pulse_flags &
9955 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
9956 wlan_radar_event->is_psidx_diff_valid = true;
9957 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
9958 } else {
9959 wlan_radar_event->is_psidx_diff_valid = false;
9960 }
9961
bings1ea12532017-12-18 16:56:53 +08009962 wlan_radar_event->pdev_id = radar_event->pdev_id;
9963
9964 return QDF_STATUS_SUCCESS;
9965}
9966#else
9967static QDF_STATUS extract_wlan_radar_event_info_tlv(
9968 wmi_unified_t wmi_handle,
9969 uint8_t *evt_buf,
9970 struct radar_event_info *wlan_radar_event,
9971 uint32_t len)
9972{
9973 return QDF_STATUS_SUCCESS;
9974}
9975#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009976#endif
9977
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009978/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309979 * send_get_rcpi_cmd_tlv() - send request for rcpi value
9980 * @wmi_handle: wmi handle
9981 * @get_rcpi_param: rcpi params
9982 *
9983 * Return: QDF status
9984 */
9985static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
9986 struct rcpi_req *get_rcpi_param)
9987{
9988 wmi_buf_t buf;
9989 wmi_request_rcpi_cmd_fixed_param *cmd;
9990 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
9991
9992 buf = wmi_buf_alloc(wmi_handle, len);
9993 if (!buf) {
9994 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
9995 return QDF_STATUS_E_NOMEM;
9996 }
9997
9998 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
9999 WMITLV_SET_HDR(&cmd->tlv_header,
10000 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
10001 WMITLV_GET_STRUCT_TLVLEN
10002 (wmi_request_rcpi_cmd_fixed_param));
10003
10004 cmd->vdev_id = get_rcpi_param->vdev_id;
10005 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
10006 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070010007
10008 switch (get_rcpi_param->measurement_type) {
10009
10010 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
10011 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
10012 break;
10013
10014 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
10015 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
10016 break;
10017
10018 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
10019 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
10020 break;
10021
10022 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
10023 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
10024 break;
10025
10026 default:
10027 /*
10028 * invalid rcpi measurement type, fall back to
10029 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
10030 */
10031 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
10032 break;
10033 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053010034 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010035 wmi_mtrace(WMI_REQUEST_RCPI_CMDID, cmd->vdev_id, 0);
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053010036 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10037 WMI_REQUEST_RCPI_CMDID)) {
10038
10039 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
10040 __func__);
10041 wmi_buf_free(buf);
10042 return QDF_STATUS_E_FAILURE;
10043 }
10044
10045 return QDF_STATUS_SUCCESS;
10046}
10047
10048/**
10049 * extract_rcpi_response_event_tlv() - Extract RCPI event params
10050 * @wmi_handle: wmi handle
10051 * @evt_buf: pointer to event buffer
10052 * @res: pointer to hold rcpi response from firmware
10053 *
10054 * Return: QDF_STATUS_SUCCESS for successful event parse
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010055 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053010056 */
10057static QDF_STATUS
10058extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
10059 void *evt_buf, struct rcpi_res *res)
10060{
10061 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
10062 wmi_update_rcpi_event_fixed_param *event;
10063
10064 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
10065 if (!param_buf) {
10066 WMI_LOGE(FL("Invalid rcpi event"));
10067 return QDF_STATUS_E_INVAL;
10068 }
10069
10070 event = param_buf->fixed_param;
10071 res->vdev_id = event->vdev_id;
10072 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
10073
10074 switch (event->measurement_type) {
10075
10076 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
10077 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
10078 break;
10079
10080 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
10081 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
10082 break;
10083
10084 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
10085 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
10086 break;
10087
10088 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
10089 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
10090 break;
10091
10092 default:
10093 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
10094 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
10095 return QDF_STATUS_E_FAILURE;
10096 }
10097
10098 if (event->status)
10099 return QDF_STATUS_E_FAILURE;
10100 else
10101 return QDF_STATUS_SUCCESS;
10102}
10103
10104/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010105 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010106 * host to target defines. For legacy there is not conversion
10107 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010108 * @param pdev_id: host pdev_id to be converted.
10109 * Return: target pdev_id after conversion.
10110 */
10111static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
10112 uint32_t pdev_id)
10113{
10114 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
10115 return WMI_PDEV_ID_SOC;
10116
10117 /*No conversion required*/
10118 return pdev_id;
10119}
10120
10121/**
10122 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010123 * target to host defines. For legacy there is not conversion
10124 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010125 * @param pdev_id: target pdev_id to be converted.
10126 * Return: host pdev_id after conversion.
10127 */
10128static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
10129 uint32_t pdev_id)
10130{
10131 /*No conversion required*/
10132 return pdev_id;
10133}
10134
10135/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010136 * send_set_country_cmd_tlv() - WMI scan channel list function
10137 * @param wmi_handle : handle to WMI.
10138 * @param param : pointer to hold scan channel list parameter
10139 *
10140 * Return: 0 on success and -ve on failure.
10141 */
10142static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
10143 struct set_country *params)
10144{
10145 wmi_buf_t buf;
10146 QDF_STATUS qdf_status;
10147 wmi_set_current_country_cmd_fixed_param *cmd;
10148 uint16_t len = sizeof(*cmd);
10149
10150 buf = wmi_buf_alloc(wmi_handle, len);
10151 if (!buf) {
10152 WMI_LOGE("Failed to allocate memory");
10153 qdf_status = QDF_STATUS_E_NOMEM;
10154 goto end;
10155 }
10156
10157 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
10158 WMITLV_SET_HDR(&cmd->tlv_header,
10159 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
10160 WMITLV_GET_STRUCT_TLVLEN
10161 (wmi_set_current_country_cmd_fixed_param));
10162
10163 WMI_LOGD("setting cuurnet country to %s", params->country);
10164
10165 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
10166
10167 cmd->pdev_id = params->pdev_id;
10168
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010169 wmi_mtrace(WMI_SET_CURRENT_COUNTRY_CMDID, NO_SESSION, 0);
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010170 qdf_status = wmi_unified_cmd_send(wmi_handle,
10171 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
10172
10173 if (QDF_IS_STATUS_ERROR(qdf_status)) {
10174 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
10175 wmi_buf_free(buf);
10176 }
10177
10178end:
10179 return qdf_status;
10180}
10181
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010182#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010183 WMI_SET_BITS(alpha, 0, 8, val0); \
10184 WMI_SET_BITS(alpha, 8, 8, val1); \
10185 WMI_SET_BITS(alpha, 16, 8, val2); \
10186 } while (0)
10187
10188static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
10189 uint8_t pdev_id, struct cc_regdmn_s *rd)
10190{
10191 wmi_set_init_country_cmd_fixed_param *cmd;
10192 uint16_t len;
10193 wmi_buf_t buf;
10194 int ret;
10195
10196 len = sizeof(wmi_set_init_country_cmd_fixed_param);
10197 buf = wmi_buf_alloc(wmi_handle, len);
10198 if (!buf) {
10199 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10200 return QDF_STATUS_E_NOMEM;
10201 }
10202 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
10203 WMITLV_SET_HDR(&cmd->tlv_header,
10204 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
10205 WMITLV_GET_STRUCT_TLVLEN
10206 (wmi_set_init_country_cmd_fixed_param));
10207
10208 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
10209
10210 if (rd->flags == CC_IS_SET) {
10211 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
10212 cmd->country_code.country_id = rd->cc.country_code;
10213 } else if (rd->flags == ALPHA_IS_SET) {
10214 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
10215 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
10216 rd->cc.alpha[0],
10217 rd->cc.alpha[1],
10218 rd->cc.alpha[2]);
10219 } else if (rd->flags == REGDMN_IS_SET) {
10220 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
10221 cmd->country_code.domain_code = rd->cc.regdmn_id;
10222 }
10223
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010224 wmi_mtrace(WMI_SET_INIT_COUNTRY_CMDID, NO_SESSION, 0);
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10226 WMI_SET_INIT_COUNTRY_CMDID);
10227 if (ret) {
10228 WMI_LOGE("Failed to config wow wakeup event");
10229 wmi_buf_free(buf);
10230 return QDF_STATUS_E_FAILURE;
10231 }
10232
10233 return QDF_STATUS_SUCCESS;
10234}
10235
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053010236/**
Arif Hussainc5bfe072017-12-27 16:23:45 -080010237 * send_obss_detection_cfg_cmd_tlv() - send obss detection
10238 * configurations to firmware.
10239 * @wmi_handle: wmi handle
10240 * @obss_cfg_param: obss detection configurations
10241 *
10242 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
10243 *
10244 * Return: QDF_STATUS
10245 */
10246static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
10247 struct wmi_obss_detection_cfg_param *obss_cfg_param)
10248{
10249 wmi_buf_t buf;
10250 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
10251 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
10252
10253 buf = wmi_buf_alloc(wmi_handle, len);
10254 if (!buf) {
10255 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
10256 return QDF_STATUS_E_NOMEM;
10257 }
10258
10259 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
10260 WMITLV_SET_HDR(&cmd->tlv_header,
10261 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
10262 WMITLV_GET_STRUCT_TLVLEN
10263 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
10264
10265 cmd->vdev_id = obss_cfg_param->vdev_id;
10266 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
10267 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
10268 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
10269 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
10270 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
10271 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
10272 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
10273 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080010274
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010275 wmi_mtrace(WMI_SAP_OBSS_DETECTION_CFG_CMDID, cmd->vdev_id, 0);
Arif Hussainc5bfe072017-12-27 16:23:45 -080010276 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10277 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
10278 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
10279 wmi_buf_free(buf);
10280 return QDF_STATUS_E_FAILURE;
10281 }
10282
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053010283 return QDF_STATUS_SUCCESS;
10284}
10285
Arif Hussain33d98502018-01-12 13:15:04 -080010286/**
10287 * extract_obss_detection_info_tlv() - Extract obss detection info
10288 * received from firmware.
10289 * @evt_buf: pointer to event buffer
10290 * @obss_detection: Pointer to hold obss detection info
10291 *
10292 * Return: QDF_STATUS
10293 */
10294static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
10295 struct wmi_obss_detect_info
10296 *obss_detection)
10297{
10298 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
10299 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
10300
10301 if (!obss_detection) {
10302 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
10303 return QDF_STATUS_E_INVAL;
10304 }
10305
10306 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
10307 if (!param_buf) {
10308 WMI_LOGE("%s: Invalid evt_buf", __func__);
10309 return QDF_STATUS_E_INVAL;
10310 }
10311
10312 fix_param = param_buf->fixed_param;
10313 obss_detection->vdev_id = fix_param->vdev_id;
10314 obss_detection->matched_detection_masks =
10315 fix_param->matched_detection_masks;
10316 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
10317 &obss_detection->matched_bssid_addr[0]);
10318 switch (fix_param->reason) {
10319 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
10320 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
10321 break;
10322 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
10323 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
10324 break;
10325 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
10326 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
10327 break;
10328 default:
10329 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
10330 return QDF_STATUS_E_INVAL;
10331 }
10332
10333 return QDF_STATUS_SUCCESS;
10334}
10335
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053010336/**
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010337 * send_roam_scan_stats_cmd_tlv() - Send roam scan stats req command to fw
10338 * @wmi_handle: wmi handle
10339 * @params: pointer to request structure
10340 *
10341 * Return: QDF_STATUS
10342 */
10343static QDF_STATUS
10344send_roam_scan_stats_cmd_tlv(wmi_unified_t wmi_handle,
10345 struct wmi_roam_scan_stats_req *params)
10346{
10347 wmi_buf_t buf;
10348 wmi_request_roam_scan_stats_cmd_fixed_param *cmd;
10349 WMITLV_TAG_ID tag;
10350 uint32_t size;
10351 uint32_t len = sizeof(*cmd);
10352
10353 buf = wmi_buf_alloc(wmi_handle, len);
10354 if (!buf) {
10355 WMI_LOGE(FL("Failed to allocate wmi buffer"));
10356 return QDF_STATUS_E_FAILURE;
10357 }
10358
10359 cmd = (wmi_request_roam_scan_stats_cmd_fixed_param *)wmi_buf_data(buf);
10360
10361 tag = WMITLV_TAG_STRUC_wmi_request_roam_scan_stats_cmd_fixed_param;
10362 size = WMITLV_GET_STRUCT_TLVLEN(
10363 wmi_request_roam_scan_stats_cmd_fixed_param);
10364 WMITLV_SET_HDR(&cmd->tlv_header, tag, size);
10365
10366 cmd->vdev_id = params->vdev_id;
10367
10368 WMI_LOGD(FL("Roam Scan Stats Req vdev_id: %u"), cmd->vdev_id);
10369 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10370 WMI_REQUEST_ROAM_SCAN_STATS_CMDID)) {
10371 WMI_LOGE("%s: Failed to send WMI_REQUEST_ROAM_SCAN_STATS_CMDID",
10372 __func__);
10373 wmi_buf_free(buf);
10374 return QDF_STATUS_E_FAILURE;
10375 }
10376
10377 return QDF_STATUS_SUCCESS;
10378}
10379
10380/**
10381 * extract_roam_scan_stats_res_evt_tlv() - Extract roam scan stats event
10382 * @wmi_handle: wmi handle
10383 * @evt_buf: pointer to event buffer
10384 * @vdev_id: output pointer to hold vdev id
10385 * @res_param: output pointer to hold the allocated response
10386 *
10387 * Return: QDF_STATUS
10388 */
10389static QDF_STATUS
10390extract_roam_scan_stats_res_evt_tlv(wmi_unified_t wmi_handle, void *evt_buf,
10391 uint32_t *vdev_id,
10392 struct wmi_roam_scan_stats_res **res_param)
10393{
10394 WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *param_buf;
10395 wmi_roam_scan_stats_event_fixed_param *fixed_param;
10396 uint32_t *client_id = NULL;
10397 wmi_roaming_timestamp *timestamp = NULL;
10398 uint32_t *num_channels = NULL;
10399 uint32_t *chan_info = NULL;
10400 wmi_mac_addr *old_bssid = NULL;
10401 uint32_t *is_roaming_success = NULL;
10402 wmi_mac_addr *new_bssid = NULL;
10403 uint32_t *num_roam_candidates = NULL;
10404 wmi_roam_scan_trigger_reason *roam_reason = NULL;
10405 wmi_mac_addr *bssid = NULL;
10406 uint32_t *score = NULL;
10407 uint32_t *channel = NULL;
10408 uint32_t *rssi = NULL;
10409 int chan_idx = 0, cand_idx = 0;
10410 uint32_t total_len;
10411 struct wmi_roam_scan_stats_res *res;
10412 uint32_t i, j;
Arif Hussain100fabf2018-10-17 09:36:11 -070010413 uint32_t num_scans, scan_param_size;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010414
10415 *res_param = NULL;
10416 *vdev_id = 0xFF; /* Initialize to invalid vdev id */
10417 param_buf = (WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *)evt_buf;
10418 if (!param_buf) {
10419 WMI_LOGE(FL("Invalid roam scan stats event"));
10420 return QDF_STATUS_E_INVAL;
10421 }
10422
10423 fixed_param = param_buf->fixed_param;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010424
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010425 num_scans = fixed_param->num_roam_scans;
Arif Hussain100fabf2018-10-17 09:36:11 -070010426 scan_param_size = sizeof(struct wmi_roam_scan_stats_params);
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010427 *vdev_id = fixed_param->vdev_id;
10428 if (num_scans > WMI_ROAM_SCAN_STATS_MAX) {
10429 wmi_err_rl("%u exceeded maximum roam scan stats: %u",
10430 num_scans, WMI_ROAM_SCAN_STATS_MAX);
Arif Hussain100fabf2018-10-17 09:36:11 -070010431 return QDF_STATUS_E_INVAL;
10432 }
10433
10434 total_len = sizeof(*res) + num_scans * scan_param_size;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010435
10436 res = qdf_mem_malloc(total_len);
10437 if (!res) {
10438 WMI_LOGE("Failed to allocate roam scan stats response memory");
10439 return QDF_STATUS_E_NOMEM;
10440 }
10441
10442 if (!num_scans) {
10443 *res_param = res;
10444 return QDF_STATUS_SUCCESS;
10445 }
10446
10447 if (param_buf->client_id &&
10448 param_buf->num_client_id == num_scans)
10449 client_id = param_buf->client_id;
10450
10451 if (param_buf->timestamp &&
10452 param_buf->num_timestamp == num_scans)
10453 timestamp = param_buf->timestamp;
10454
10455 if (param_buf->old_bssid &&
10456 param_buf->num_old_bssid == num_scans)
10457 old_bssid = param_buf->old_bssid;
10458
10459 if (param_buf->new_bssid &&
10460 param_buf->num_new_bssid == num_scans)
10461 new_bssid = param_buf->new_bssid;
10462
10463 if (param_buf->is_roaming_success &&
10464 param_buf->num_is_roaming_success == num_scans)
10465 is_roaming_success = param_buf->is_roaming_success;
10466
10467 if (param_buf->roam_reason &&
10468 param_buf->num_roam_reason == num_scans)
10469 roam_reason = param_buf->roam_reason;
10470
10471 if (param_buf->num_channels &&
10472 param_buf->num_num_channels == num_scans) {
10473 uint32_t count, chan_info_sum = 0;
10474
10475 num_channels = param_buf->num_channels;
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010476 for (count = 0; count < param_buf->num_num_channels; count++) {
10477 if (param_buf->num_channels[count] >
10478 WMI_ROAM_SCAN_STATS_CHANNELS_MAX) {
10479 wmi_err_rl("%u exceeded max scan channels %u",
10480 param_buf->num_channels[count],
10481 WMI_ROAM_SCAN_STATS_CHANNELS_MAX);
10482 goto error;
10483 }
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010484 chan_info_sum += param_buf->num_channels[count];
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010485 }
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010486
10487 if (param_buf->chan_info &&
10488 param_buf->num_chan_info == chan_info_sum)
10489 chan_info = param_buf->chan_info;
10490 }
10491
10492 if (param_buf->num_roam_candidates &&
10493 param_buf->num_num_roam_candidates == num_scans) {
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010494 uint32_t cnt, roam_cand_sum = 0;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010495
10496 num_roam_candidates = param_buf->num_roam_candidates;
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010497 for (cnt = 0; cnt < param_buf->num_num_roam_candidates; cnt++) {
10498 if (param_buf->num_roam_candidates[cnt] >
10499 WMI_ROAM_SCAN_STATS_CANDIDATES_MAX) {
10500 wmi_err_rl("%u exceeded max scan cand %u",
10501 param_buf->num_roam_candidates[cnt],
10502 WMI_ROAM_SCAN_STATS_CANDIDATES_MAX);
10503 goto error;
10504 }
10505 roam_cand_sum += param_buf->num_roam_candidates[cnt];
10506 }
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010507
10508 if (param_buf->bssid &&
10509 param_buf->num_bssid == roam_cand_sum)
10510 bssid = param_buf->bssid;
10511
10512 if (param_buf->score &&
10513 param_buf->num_score == roam_cand_sum)
10514 score = param_buf->score;
10515
10516 if (param_buf->channel &&
10517 param_buf->num_channel == roam_cand_sum)
10518 channel = param_buf->channel;
10519
10520 if (param_buf->rssi &&
10521 param_buf->num_rssi == roam_cand_sum)
10522 rssi = param_buf->rssi;
10523 }
10524
10525 res->num_roam_scans = num_scans;
10526 for (i = 0; i < num_scans; i++) {
10527 struct wmi_roam_scan_stats_params *roam = &res->roam_scan[i];
10528
10529 if (timestamp)
10530 roam->time_stamp = timestamp[i].lower32bit |
10531 (timestamp[i].upper32bit << 31);
10532
10533 if (client_id)
10534 roam->client_id = client_id[i];
10535
10536 if (num_channels) {
10537 roam->num_scan_chans = num_channels[i];
10538 if (chan_info) {
10539 for (j = 0; j < num_channels[i]; j++)
10540 roam->scan_freqs[j] =
10541 chan_info[chan_idx++];
10542 }
10543 }
10544
10545 if (is_roaming_success)
10546 roam->is_roam_successful = is_roaming_success[i];
10547
10548 if (roam_reason) {
10549 roam->trigger_id = roam_reason[i].trigger_id;
10550 roam->trigger_value = roam_reason[i].trigger_value;
10551 }
10552
10553 if (num_roam_candidates) {
10554 roam->num_roam_candidates = num_roam_candidates[i];
10555
10556 for (j = 0; j < num_roam_candidates[i]; j++) {
10557 if (score)
10558 roam->cand[j].score = score[cand_idx];
10559 if (rssi)
10560 roam->cand[j].rssi = rssi[cand_idx];
10561 if (channel)
10562 roam->cand[j].freq =
10563 channel[cand_idx];
10564
10565 if (bssid)
10566 WMI_MAC_ADDR_TO_CHAR_ARRAY(
10567 &bssid[cand_idx],
10568 roam->cand[j].bssid);
10569
10570 cand_idx++;
10571 }
10572 }
10573
10574 if (old_bssid)
10575 WMI_MAC_ADDR_TO_CHAR_ARRAY(&old_bssid[i],
10576 roam->old_bssid);
10577
10578 if (new_bssid)
10579 WMI_MAC_ADDR_TO_CHAR_ARRAY(&new_bssid[i],
10580 roam->new_bssid);
10581 }
10582
10583 *res_param = res;
10584
10585 return QDF_STATUS_SUCCESS;
Rajeev Kumar Sirasanagandlad7b48472018-10-23 16:00:11 +053010586error:
10587 qdf_mem_free(res);
10588 return QDF_STATUS_E_FAILURE;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010589}
10590
10591/**
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070010592 * extract_offload_bcn_tx_status_evt() - Extract beacon-tx status event
10593 * @wmi_handle: wmi handle
10594 * @evt_buf: pointer to event buffer
10595 * @vdev_id: output pointer to hold vdev id
10596 * @tx_status: output pointer to hold the tx_status
10597 *
10598 * Return: QDF_STATUS
10599 */
10600static QDF_STATUS extract_offload_bcn_tx_status_evt(wmi_unified_t wmi_handle,
10601 void *evt_buf,
10602 uint32_t *vdev_id,
10603 uint32_t *tx_status) {
10604 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *param_buf;
10605 wmi_offload_bcn_tx_status_event_fixed_param *bcn_tx_status_event;
10606
10607 param_buf = (WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *)evt_buf;
10608 if (!param_buf) {
10609 WMI_LOGE("Invalid offload bcn tx status event buffer");
10610 return QDF_STATUS_E_INVAL;
10611 }
10612
10613 bcn_tx_status_event = param_buf->fixed_param;
10614 *vdev_id = bcn_tx_status_event->vdev_id;
10615 *tx_status = bcn_tx_status_event->tx_status;
10616
10617 return QDF_STATUS_SUCCESS;
10618}
10619
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010620#ifdef WLAN_SUPPORT_GREEN_AP
10621static QDF_STATUS extract_green_ap_egap_status_info_tlv(
10622 uint8_t *evt_buf,
10623 struct wlan_green_ap_egap_status_info *egap_status_info_params)
10624{
10625 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
10626 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
10627 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
10628
10629 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
10630 if (!param_buf) {
10631 WMI_LOGE("Invalid EGAP Info status event buffer");
10632 return QDF_STATUS_E_INVAL;
10633 }
10634
10635 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
10636 param_buf->fixed_param;
10637 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
10638 param_buf->chainmask_list;
10639
Ashish Kumar Dhanotiyaa90d8112018-10-17 16:45:54 +053010640 if (!egap_info_event || !chainmask_event) {
10641 WMI_LOGE("Invalid EGAP Info event or chainmask event");
10642 return QDF_STATUS_E_INVAL;
10643 }
10644
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010645 egap_status_info_params->status = egap_info_event->status;
10646 egap_status_info_params->mac_id = chainmask_event->mac_id;
10647 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
10648 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
10649
10650 return QDF_STATUS_SUCCESS;
10651}
10652#endif
10653
Arif Hussainec5cd3c2018-01-22 01:19:36 -080010654/*
Arif Hussaine0eb7302018-03-01 14:40:59 -080010655 * extract_comb_phyerr_tlv() - extract comb phy error from event
10656 * @wmi_handle: wmi handle
10657 * @evt_buf: pointer to event buffer
10658 * @datalen: data length of event buffer
10659 * @buf_offset: Pointer to hold value of current event buffer offset
10660 * post extraction
10661 * @phyerr: Pointer to hold phyerr
10662 *
10663 * Return: QDF_STATUS
10664 */
10665static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
10666 void *evt_buf,
10667 uint16_t datalen,
10668 uint16_t *buf_offset,
10669 wmi_host_phyerr_t *phyerr)
10670{
10671 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
10672 wmi_comb_phyerr_rx_hdr *pe_hdr;
10673
10674 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
10675 if (!param_tlvs) {
10676 WMI_LOGD("%s: Received null data from FW", __func__);
10677 return QDF_STATUS_E_FAILURE;
10678 }
10679
10680 pe_hdr = param_tlvs->hdr;
10681 if (!pe_hdr) {
10682 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
10683 return QDF_STATUS_E_FAILURE;
10684 }
10685
10686 /* Ensure it's at least the size of the header */
10687 if (datalen < sizeof(*pe_hdr)) {
10688 WMI_LOGD("%s: Expected minimum size %zu, received %d",
10689 __func__, sizeof(*pe_hdr), datalen);
10690 return QDF_STATUS_E_FAILURE;
10691 }
10692
10693 phyerr->pdev_id = wmi_handle->ops->
10694 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
10695 phyerr->tsf64 = pe_hdr->tsf_l32;
10696 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
10697 phyerr->bufp = param_tlvs->bufp;
Yeshwanth Sriram Guntuka19e51be2018-09-25 15:40:08 +053010698
10699 if (pe_hdr->buf_len > param_tlvs->num_bufp) {
10700 WMI_LOGD("Invalid buf_len %d, num_bufp %d",
10701 pe_hdr->buf_len, param_tlvs->num_bufp);
10702 return QDF_STATUS_E_FAILURE;
10703 }
10704
Arif Hussaine0eb7302018-03-01 14:40:59 -080010705 phyerr->buf_len = pe_hdr->buf_len;
10706 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
10707 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
10708 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
10709
10710 return QDF_STATUS_SUCCESS;
10711}
10712
10713/**
10714 * extract_single_phyerr_tlv() - extract single phy error from event
10715 * @wmi_handle: wmi handle
10716 * @evt_buf: pointer to event buffer
10717 * @datalen: data length of event buffer
10718 * @buf_offset: Pointer to hold value of current event buffer offset
10719 * post extraction
10720 * @phyerr: Pointer to hold phyerr
10721 *
10722 * Return: QDF_STATUS
10723 */
10724static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
10725 void *evt_buf,
10726 uint16_t datalen,
10727 uint16_t *buf_offset,
10728 wmi_host_phyerr_t *phyerr)
10729{
10730 wmi_single_phyerr_rx_event *ev;
10731 uint16_t n = *buf_offset;
10732 uint8_t *data = (uint8_t *)evt_buf;
10733
10734 if (n < datalen) {
10735 if ((datalen - n) < sizeof(ev->hdr)) {
10736 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
10737 __func__, datalen, n, sizeof(ev->hdr));
10738 return QDF_STATUS_E_FAILURE;
10739 }
10740
10741 /*
10742 * Obtain a pointer to the beginning of the current event.
10743 * data[0] is the beginning of the WMI payload.
10744 */
10745 ev = (wmi_single_phyerr_rx_event *)&data[n];
10746
10747 /*
10748 * Sanity check the buffer length of the event against
10749 * what we currently have.
10750 *
10751 * Since buf_len is 32 bits, we check if it overflows
10752 * a large 32 bit value. It's not 0x7fffffff because
10753 * we increase n by (buf_len + sizeof(hdr)), which would
10754 * in itself cause n to overflow.
10755 *
10756 * If "int" is 64 bits then this becomes a moot point.
10757 */
10758 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
10759 WMI_LOGD("%s: buf_len is garbage 0x%x",
10760 __func__, ev->hdr.buf_len);
10761 return QDF_STATUS_E_FAILURE;
10762 }
10763
10764 if ((n + ev->hdr.buf_len) > datalen) {
10765 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
10766 __func__, n, ev->hdr.buf_len, datalen);
10767 return QDF_STATUS_E_FAILURE;
10768 }
10769
10770 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
10771 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
10772 phyerr->bufp = &ev->bufp[0];
10773 phyerr->buf_len = ev->hdr.buf_len;
10774 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
10775
10776 /*
10777 * Advance the buffer pointer to the next PHY error.
10778 * buflen is the length of this payload, so we need to
10779 * advance past the current header _AND_ the payload.
10780 */
10781 n += sizeof(*ev) + ev->hdr.buf_len;
10782 }
10783 *buf_offset = n;
10784
10785 return QDF_STATUS_SUCCESS;
10786}
10787
Subrat Mishraa667b1c2018-08-02 15:02:04 +053010788/**
10789 * extract_esp_estimation_ev_param_tlv() - extract air time from event
10790 * @wmi_handle: wmi handle
10791 * @evt_buf: pointer to event buffer
10792 * @param: Pointer to hold esp event
10793 *
10794 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
10795 */
10796static QDF_STATUS
10797extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
10798 void *evt_buf,
10799 struct esp_estimation_event *param)
10800{
10801 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
10802 wmi_esp_estimate_event_fixed_param *esp_event;
10803
10804 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
10805 if (!param_buf) {
10806 WMI_LOGE("Invalid ESP Estimate Event buffer");
10807 return QDF_STATUS_E_INVAL;
10808 }
10809 esp_event = param_buf->fixed_param;
10810 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
10811 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
10812 esp_event->pdev_id);
10813
10814 return QDF_STATUS_SUCCESS;
10815}
10816
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080010817/*
10818 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
10819 * updating bss color change within firmware when AP announces bss color change.
10820 * @wmi_handle: wmi handle
10821 * @vdev_id: vdev ID
10822 * @enable: enable bss color change within firmware
10823 *
10824 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
10825 *
10826 * Return: QDF_STATUS
10827 */
10828static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
10829 uint32_t vdev_id,
10830 bool enable)
10831{
10832 wmi_buf_t buf;
10833 wmi_bss_color_change_enable_fixed_param *cmd;
10834 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
10835
10836 buf = wmi_buf_alloc(wmi_handle, len);
10837 if (!buf) {
10838 return QDF_STATUS_E_NOMEM;
10839 }
10840
10841 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
10842 WMITLV_SET_HDR(&cmd->tlv_header,
10843 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
10844 WMITLV_GET_STRUCT_TLVLEN
10845 (wmi_bss_color_change_enable_fixed_param));
10846 cmd->vdev_id = vdev_id;
10847 cmd->enable = enable;
10848 wmi_mtrace(WMI_BSS_COLOR_CHANGE_ENABLE_CMDID, cmd->vdev_id, 0);
10849 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10850 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
10851 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
10852 wmi_buf_free(buf);
10853 return QDF_STATUS_E_FAILURE;
10854 }
10855
10856 return QDF_STATUS_SUCCESS;
10857}
10858
10859/**
10860 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
10861 * configurations to firmware.
10862 * @wmi_handle: wmi handle
10863 * @cfg_param: obss detection configurations
10864 *
10865 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
10866 *
10867 * Return: QDF_STATUS
10868 */
10869static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
10870 wmi_unified_t wmi_handle,
10871 struct wmi_obss_color_collision_cfg_param *cfg_param)
10872{
10873 wmi_buf_t buf;
10874 wmi_obss_color_collision_det_config_fixed_param *cmd;
10875 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
10876
10877 buf = wmi_buf_alloc(wmi_handle, len);
10878 if (!buf) {
10879 return QDF_STATUS_E_NOMEM;
10880 }
10881
10882 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
10883 buf);
10884 WMITLV_SET_HDR(&cmd->tlv_header,
10885 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
10886 WMITLV_GET_STRUCT_TLVLEN
10887 (wmi_obss_color_collision_det_config_fixed_param));
10888 cmd->vdev_id = cfg_param->vdev_id;
10889 cmd->flags = cfg_param->flags;
10890 cmd->current_bss_color = cfg_param->current_bss_color;
10891 cmd->detection_period_ms = cfg_param->detection_period_ms;
10892 cmd->scan_period_ms = cfg_param->scan_period_ms;
10893 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
10894
10895 switch (cfg_param->evt_type) {
10896 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
10897 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
10898 break;
10899 case OBSS_COLOR_COLLISION_DETECTION:
10900 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
10901 break;
10902 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10903 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10904 break;
10905 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
10906 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
10907 break;
10908 default:
10909 WMI_LOGE("%s: invalid event type: %d",
10910 __func__, cfg_param->evt_type);
10911 wmi_buf_free(buf);
10912 return QDF_STATUS_E_FAILURE;
10913 }
10914
10915 WMI_LOGD("%s: evt_type: %d vdev id: %d current_bss_color: %d\n"
10916 "detection_period_ms: %d scan_period_ms: %d\n"
10917 "free_slot_expiry_timer_ms: %d",
10918 __func__, cmd->evt_type, cmd->vdev_id, cmd->current_bss_color,
10919 cmd->detection_period_ms, cmd->scan_period_ms,
10920 cmd->free_slot_expiry_time_ms);
10921
10922 wmi_mtrace(WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID, cmd->vdev_id, 0);
10923 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10924 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
10925 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
10926 __func__, cfg_param->vdev_id);
10927 wmi_buf_free(buf);
10928 return QDF_STATUS_E_FAILURE;
10929 }
10930
10931 return QDF_STATUS_SUCCESS;
10932}
10933
10934/**
10935 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
10936 * received from firmware.
10937 * @evt_buf: pointer to event buffer
10938 * @info: Pointer to hold bss collision info
10939 *
10940 * Return: QDF_STATUS
10941 */
10942static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
10943 struct wmi_obss_color_collision_info *info)
10944{
10945 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
10946 wmi_obss_color_collision_evt_fixed_param *fix_param;
10947
10948 if (!info) {
10949 WMI_LOGE("%s: Invalid obss color buffer", __func__);
10950 return QDF_STATUS_E_INVAL;
10951 }
10952
10953 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
10954 evt_buf;
10955 if (!param_buf) {
10956 WMI_LOGE("%s: Invalid evt_buf", __func__);
10957 return QDF_STATUS_E_INVAL;
10958 }
10959
10960 fix_param = param_buf->fixed_param;
10961 info->vdev_id = fix_param->vdev_id;
10962 info->obss_color_bitmap_bit0to31 =
10963 fix_param->bss_color_bitmap_bit0to31;
10964 info->obss_color_bitmap_bit32to63 =
10965 fix_param->bss_color_bitmap_bit32to63;
10966
10967 switch (fix_param->evt_type) {
10968 case WMI_BSS_COLOR_COLLISION_DISABLE:
10969 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
10970 break;
10971 case WMI_BSS_COLOR_COLLISION_DETECTION:
10972 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
10973 break;
10974 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10975 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10976 break;
10977 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
10978 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
10979 break;
10980 default:
10981 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
10982 __func__, fix_param->evt_type, fix_param->vdev_id);
10983 return QDF_STATUS_E_FAILURE;
10984 }
10985
10986 return QDF_STATUS_SUCCESS;
10987}
10988
10989static void wmi_11ax_bss_color_attach_tlv(struct wmi_unified *wmi_handle)
10990{
10991 struct wmi_ops *ops = wmi_handle->ops;
10992
10993 ops->send_obss_color_collision_cfg_cmd =
10994 send_obss_color_collision_cfg_cmd_tlv;
10995 ops->extract_obss_color_collision_info =
10996 extract_obss_color_collision_info_tlv;
10997}
10998
Govind Singh5eb51532016-03-09 11:34:12 +053010999struct wmi_ops tlv_ops = {
11000 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
11001 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
11002 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053011003 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
11004 .send_hidden_ssid_vdev_restart_cmd =
11005 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011006 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
11007 .send_peer_param_cmd = send_peer_param_cmd_tlv,
11008 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011009 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011010 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011011 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070011012 .send_peer_rx_reorder_queue_setup_cmd =
11013 send_peer_rx_reorder_queue_setup_cmd_tlv,
11014 .send_peer_rx_reorder_queue_remove_cmd =
11015 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011016 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
11017 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
11018 .send_suspend_cmd = send_suspend_cmd_tlv,
11019 .send_resume_cmd = send_resume_cmd_tlv,
11020 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
11021 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
11022 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
11023 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080011024#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053011025 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080011026#endif
Govind Singh5eb51532016-03-09 11:34:12 +053011027 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
11028 .send_stats_request_cmd = send_stats_request_cmd_tlv,
11029 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053011030 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070011031 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053011032 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011033 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
11034 .send_scan_start_cmd = send_scan_start_cmd_tlv,
11035 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
11036 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011037 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053011038 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011039 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
11040 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011041 .send_set_sta_uapsd_auto_trig_cmd =
11042 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011043 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053011044 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
11045 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053011046 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
11047 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053011048 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011049 .send_probe_rsp_tmpl_send_cmd =
11050 send_probe_rsp_tmpl_send_cmd_tlv,
11051 .send_p2p_go_set_beacon_ie_cmd =
11052 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053011053 .send_setup_install_key_cmd =
11054 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053011055 .send_scan_probe_setoui_cmd =
11056 send_scan_probe_setoui_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053011057#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053011058 .send_ipa_offload_control_cmd =
11059 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053011060#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053011061 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
11062 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070011063 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080011064#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053011065 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
11066 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
11067 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080011068#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053011069 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011070 .send_snr_request_cmd = send_snr_request_cmd_tlv,
11071 .send_snr_cmd = send_snr_cmd_tlv,
11072 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011073#ifdef CONFIG_MCL
Govind Singh87542482016-06-08 19:40:11 +053011074 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053011075#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053011076 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053011077#endif
Govind Singh87542482016-06-08 19:40:11 +053011078#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053011079#ifdef WLAN_SUPPORT_GREEN_AP
11080 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
11081 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053011082 .extract_green_ap_egap_status_info =
11083 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053011084#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053011085 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011086 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070011087#ifdef WLAN_FEATURE_CIF_CFR
11088 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
11089#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053011090 .send_dfs_phyerr_filter_offload_en_cmd =
11091 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011092 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011093 .send_process_dhcpserver_offload_cmd =
11094 send_process_dhcpserver_offload_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053011095 .send_pdev_set_regdomain_cmd =
11096 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011097 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053011098 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011099 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053011100 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011101 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
11102 .send_enable_specific_fw_logs_cmd =
11103 send_enable_specific_fw_logs_cmd_tlv,
11104 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011105 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011106 .send_unit_test_cmd = send_unit_test_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011107#ifdef FEATURE_WLAN_APF
11108 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
11109 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
11110 .send_apf_write_work_memory_cmd =
11111 wmi_send_apf_write_work_memory_cmd_tlv,
11112 .send_apf_read_work_memory_cmd =
11113 wmi_send_apf_read_work_memory_cmd_tlv,
11114 .extract_apf_read_memory_resp_event =
11115 wmi_extract_apf_read_memory_resp_event_tlv,
11116#endif /* FEATURE_WLAN_APF */
Govind Singhe7f2f342016-05-23 12:12:52 +053011117 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053011118 .send_vdev_set_custom_aggr_size_cmd =
11119 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011120 .send_vdev_set_qdepth_thresh_cmd =
11121 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053011122 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053011123 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011124 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
11125 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011126 .send_periodic_chan_stats_config_cmd =
11127 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011128 .send_vdev_spectral_configure_cmd =
11129 send_vdev_spectral_configure_cmd_tlv,
11130 .send_vdev_spectral_enable_cmd =
11131 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011132 .send_thermal_mitigation_param_cmd =
11133 send_thermal_mitigation_param_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053011134 .send_process_update_edca_param_cmd =
11135 send_process_update_edca_param_cmd_tlv,
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080011136 .send_bss_color_change_enable_cmd =
11137 send_bss_color_change_enable_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053011138 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070011139 .send_set_country_cmd = send_set_country_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080011140 .send_addba_send_cmd = send_addba_send_cmd_tlv,
11141 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080011142 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011143 .get_target_cap_from_service_ready = extract_service_ready_tlv,
11144 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
11145 .extract_host_mem_req = extract_host_mem_req_tlv,
11146 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011147 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011148 .is_service_enabled = is_service_enabled_tlv,
11149 .save_fw_version = save_fw_version_in_service_ready_tlv,
11150 .ready_extract_init_status = ready_extract_init_status_tlv,
11151 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070011152 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053011153 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011154 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011155 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011156 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
11157 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011158 .extract_all_stats_count = extract_all_stats_counts_tlv,
11159 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011160 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011161 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
11162 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070011163 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011164 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053011165 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011166 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
11167 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
11168 .extract_chan_stats = extract_chan_stats_tlv,
11169 .extract_profile_ctx = extract_profile_ctx_tlv,
11170 .extract_profile_data = extract_profile_data_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053011171 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053011172 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053011173 .extract_service_ready_ext = extract_service_ready_ext_tlv,
11174 .extract_hw_mode_cap_service_ready_ext =
11175 extract_hw_mode_cap_service_ready_ext_tlv,
11176 .extract_mac_phy_cap_service_ready_ext =
11177 extract_mac_phy_cap_service_ready_ext_tlv,
11178 .extract_reg_cap_service_ready_ext =
11179 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053011180 .extract_dbr_ring_cap_service_ready_ext =
11181 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011182 .extract_sar_cap_service_ready_ext =
11183 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053011184 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053011185 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053011186 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011187 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053011188 .is_management_record = is_management_record_tlv,
Rajeev Kumarb64e1282018-09-19 13:02:23 -070011189 .is_diag_event = is_diag_event_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053011190#ifdef WLAN_FEATURE_ACTION_OUI
11191 .send_action_oui_cmd = send_action_oui_cmd_tlv,
11192#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080011193 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
11194 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011195 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053011196 extract_reg_chan_list_update_event_tlv,
11197 .extract_chainmask_tables =
11198 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011199 .extract_thermal_stats = extract_thermal_stats_tlv,
11200 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011201 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
11202 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011203#ifdef DFS_COMPONENT_ENABLE
11204 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
11205 .extract_dfs_radar_detection_event =
11206 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080011207 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011208#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011209 .convert_pdev_id_host_to_target =
11210 convert_host_pdev_id_to_target_pdev_id_legacy,
11211 .convert_pdev_id_target_to_host =
11212 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070011213
11214 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
11215 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
11216 .extract_reg_11d_new_country_event =
11217 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053011218 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070011219 .extract_reg_ch_avoid_event =
11220 extract_reg_ch_avoid_event_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080011221 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080011222 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053011223 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
11224 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
11225 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
11226 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussaine0eb7302018-03-01 14:40:59 -080011227 .extract_comb_phyerr = extract_comb_phyerr_tlv,
11228 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070011229#ifdef QCA_SUPPORT_CP_STATS
11230 .extract_cca_stats = extract_cca_stats_tlv,
11231#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011232 .extract_esp_estimation_ev_param =
11233 extract_esp_estimation_ev_param_tlv,
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011234 .send_roam_scan_stats_cmd = send_roam_scan_stats_cmd_tlv,
11235 .extract_roam_scan_stats_res_evt = extract_roam_scan_stats_res_evt_tlv,
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011236#ifdef OBSS_PD
11237 .send_obss_spatial_reuse_set = send_obss_spatial_reuse_set_cmd_tlv,
Arif Hussain4d4c8942018-10-17 18:48:29 -070011238 .send_obss_spatial_reuse_set_def_thresh =
11239 send_obss_spatial_reuse_set_def_thresh_cmd_tlv,
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011240#endif
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070011241 .extract_offload_bcn_tx_status_evt = extract_offload_bcn_tx_status_evt,
Alok Singh0243e7d2018-09-20 16:07:28 +053011242 .extract_ctl_failsafe_check_ev_param =
11243 extract_ctl_failsafe_check_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011244};
11245
Govind Singhe7f2f342016-05-23 12:12:52 +053011246/**
11247 * populate_tlv_event_id() - populates wmi event ids
11248 *
11249 * @param event_ids: Pointer to hold event ids
11250 * Return: None
11251 */
11252static void populate_tlv_events_id(uint32_t *event_ids)
11253{
11254 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
11255 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
11256 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
11257 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11258 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
11259 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
11260 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
11261 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
11262 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
11263 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
11264 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
11265 event_ids[wmi_service_ready_ext_event_id] =
11266 WMI_SERVICE_READY_EXT_EVENTID;
11267 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
11268 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
11269 event_ids[wmi_vdev_install_key_complete_event_id] =
11270 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
11271 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
11272 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
11273
11274 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
11275 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
11276 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
11277 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
11278 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
11279 event_ids[wmi_peer_estimated_linkspeed_event_id] =
11280 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
11281 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053011282 event_ids[wmi_peer_delete_response_event_id] =
11283 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011284 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
11285 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
11286 event_ids[wmi_tbttoffset_update_event_id] =
11287 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053011288 event_ids[wmi_ext_tbttoffset_update_event_id] =
11289 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011290 event_ids[wmi_offload_bcn_tx_status_event_id] =
11291 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
11292 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
11293 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
11294 event_ids[wmi_mgmt_tx_completion_event_id] =
11295 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080011296 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
11297 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011298 event_ids[wmi_tx_delba_complete_event_id] =
11299 WMI_TX_DELBA_COMPLETE_EVENTID;
11300 event_ids[wmi_tx_addba_complete_event_id] =
11301 WMI_TX_ADDBA_COMPLETE_EVENTID;
11302 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
11303
11304 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
11305
11306 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
11307 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
11308
11309 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053011310 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011311
11312 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
11313
11314 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080011315 event_ids[wmi_p2p_lo_stop_event_id] =
11316 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Liangwei Dong510b8652018-09-19 23:35:14 -040011317 event_ids[wmi_vdev_add_macaddr_rx_filter_event_id] =
11318 WMI_VDEV_ADD_MAC_ADDR_TO_RX_FILTER_STATUS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011319 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
11320 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080011321 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053011322 WMI_D0_WOW_DISABLE_ACK_EVENTID;
11323 event_ids[wmi_wow_initial_wakeup_event_id] =
11324 WMI_WOW_INITIAL_WAKEUP_EVENTID;
11325
11326 event_ids[wmi_rtt_meas_report_event_id] =
11327 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
11328 event_ids[wmi_tsf_meas_report_event_id] =
11329 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
11330 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
11331 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
11332 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
11333 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
11334 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011335 event_ids[wmi_diag_event_id_log_supported_event_id] =
11336 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
11337 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
11338 event_ids[wmi_nlo_scan_complete_event_id] =
11339 WMI_NLO_SCAN_COMPLETE_EVENTID;
11340 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
11341 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
11342
11343 event_ids[wmi_gtk_offload_status_event_id] =
11344 WMI_GTK_OFFLOAD_STATUS_EVENTID;
11345 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
11346 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
11347 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
11348
11349 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
11350
11351 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
11352
11353 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
11354 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
11355 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
11356 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
11357 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
11358 event_ids[wmi_wlan_profile_data_event_id] =
11359 WMI_WLAN_PROFILE_DATA_EVENTID;
11360 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
11361 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
11362 event_ids[wmi_vdev_get_keepalive_event_id] =
11363 WMI_VDEV_GET_KEEPALIVE_EVENTID;
11364 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
11365
11366 event_ids[wmi_diag_container_event_id] =
11367 WMI_DIAG_DATA_CONTAINER_EVENTID;
11368
11369 event_ids[wmi_host_auto_shutdown_event_id] =
11370 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
11371
11372 event_ids[wmi_update_whal_mib_stats_event_id] =
11373 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
11374
11375 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
11376 event_ids[wmi_update_vdev_rate_stats_event_id] =
11377 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
11378
11379 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011380 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011381
11382 /** Set OCB Sched Response, deprecated */
11383 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
11384
11385 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
11386 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
11387 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
11388
11389 /* GPIO Event */
11390 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
11391 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
11392
11393 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
11394 event_ids[wmi_rfkill_state_change_event_id] =
11395 WMI_RFKILL_STATE_CHANGE_EVENTID;
11396
11397 /* TDLS Event */
11398 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
11399
11400 event_ids[wmi_batch_scan_enabled_event_id] =
11401 WMI_BATCH_SCAN_ENABLED_EVENTID;
11402 event_ids[wmi_batch_scan_result_event_id] =
11403 WMI_BATCH_SCAN_RESULT_EVENTID;
11404 /* OEM Event */
11405 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
11406 event_ids[wmi_oem_meas_report_event_id] =
11407 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
11408 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
11409
11410 /* NAN Event */
11411 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
11412
11413 /* LPI Event */
11414 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
11415 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
11416 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
11417
11418 /* ExtScan events */
11419 event_ids[wmi_extscan_start_stop_event_id] =
11420 WMI_EXTSCAN_START_STOP_EVENTID;
11421 event_ids[wmi_extscan_operation_event_id] =
11422 WMI_EXTSCAN_OPERATION_EVENTID;
11423 event_ids[wmi_extscan_table_usage_event_id] =
11424 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
11425 event_ids[wmi_extscan_cached_results_event_id] =
11426 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
11427 event_ids[wmi_extscan_wlan_change_results_event_id] =
11428 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
11429 event_ids[wmi_extscan_hotlist_match_event_id] =
11430 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
11431 event_ids[wmi_extscan_capabilities_event_id] =
11432 WMI_EXTSCAN_CAPABILITIES_EVENTID;
11433 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
11434 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
11435
11436 /* mDNS offload events */
11437 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
11438
11439 /* SAP Authentication offload events */
11440 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
11441 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
11442
11443 /** Out-of-context-of-bss (OCB) events */
11444 event_ids[wmi_ocb_set_config_resp_event_id] =
11445 WMI_OCB_SET_CONFIG_RESP_EVENTID;
11446 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
11447 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
11448 event_ids[wmi_dcc_get_stats_resp_event_id] =
11449 WMI_DCC_GET_STATS_RESP_EVENTID;
11450 event_ids[wmi_dcc_update_ndl_resp_event_id] =
11451 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
11452 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
11453 /* System-On-Chip events */
11454 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
11455 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
11456 event_ids[wmi_soc_hw_mode_transition_event_id] =
11457 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
11458 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
11459 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011460 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053011461 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
11462 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011463 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053011464 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
11465 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11466 event_ids[wmi_peer_sta_ps_statechg_event_id] =
11467 WMI_PEER_STA_PS_STATECHG_EVENTID;
11468 event_ids[wmi_pdev_channel_hopping_event_id] =
11469 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053011470 event_ids[wmi_offchan_data_tx_completion_event] =
11471 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011472 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
11473 event_ids[wmi_dfs_radar_detection_event_id] =
11474 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011475 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070011476 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011477 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053011478 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011479 event_ids[wmi_service_available_event_id] =
11480 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011481 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053011482 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011483 /* NDP events */
11484 event_ids[wmi_ndp_initiator_rsp_event_id] =
11485 WMI_NDP_INITIATOR_RSP_EVENTID;
11486 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
11487 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
11488 event_ids[wmi_ndp_responder_rsp_event_id] =
11489 WMI_NDP_RESPONDER_RSP_EVENTID;
11490 event_ids[wmi_ndp_end_indication_event_id] =
11491 WMI_NDP_END_INDICATION_EVENTID;
11492 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080011493 event_ids[wmi_ndl_schedule_update_event_id] =
11494 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011495
11496 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
11497 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
11498 event_ids[wmi_pdev_chip_power_stats_event_id] =
11499 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
11500 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
11501 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
11502 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011503 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011504 WMI_BPF_CAPABILIY_INFO_EVENTID;
11505 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
11506 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
11507 event_ids[wmi_report_rx_aggr_failure_event_id] =
11508 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
11509 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
11510 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
11511 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
11512 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
11513 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
11514 event_ids[wmi_pdev_hw_mode_transition_event_id] =
11515 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
11516 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
11517 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
11518 event_ids[wmi_coex_bt_activity_event_id] =
11519 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
11520 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
11521 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
11522 event_ids[wmi_radio_tx_power_level_stats_event_id] =
11523 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
11524 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053011525 event_ids[wmi_dma_buf_release_event_id] =
11526 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080011527 event_ids[wmi_sap_obss_detection_report_event_id] =
11528 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053011529 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080011530 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080011531 event_ids[wmi_obss_color_collision_report_event_id] =
11532 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080011533 event_ids[wmi_pdev_div_rssi_antid_event_id] =
11534 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070011535 event_ids[wmi_twt_enable_complete_event_id] =
11536 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011537 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
11538 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011539 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011540 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011541 event_ids[wmi_roam_scan_stats_event_id] = WMI_ROAM_SCAN_STATS_EVENTID;
Kiran Venkatappad73f4eb2018-07-19 22:22:29 +053011542#ifdef AST_HKV1_WORKAROUND
11543 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
11544#endif
Alok Singh0243e7d2018-09-20 16:07:28 +053011545 event_ids[wmi_pdev_ctl_failsafe_check_event_id] =
11546 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011547}
11548
Soumya Bhat488092d2017-03-22 14:41:01 +053011549/**
11550 * populate_tlv_service() - populates wmi services
11551 *
11552 * @param wmi_service: Pointer to hold wmi_service
11553 * Return: None
11554 */
11555static void populate_tlv_service(uint32_t *wmi_service)
11556{
11557 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053011558 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011559 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
11560 wmi_service[wmi_service_roam_scan_offload] =
11561 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
11562 wmi_service[wmi_service_bcn_miss_offload] =
11563 WMI_SERVICE_BCN_MISS_OFFLOAD;
11564 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
11565 wmi_service[wmi_service_sta_advanced_pwrsave] =
11566 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
11567 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
11568 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
11569 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
11570 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
11571 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
11572 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
11573 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
11574 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
11575 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
11576 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
11577 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
11578 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
11579 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
11580 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
11581 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
11582 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
11583 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
11584 wmi_service[wmi_service_packet_power_save] =
11585 WMI_SERVICE_PACKET_POWER_SAVE;
11586 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
11587 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
11588 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
11589 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
11590 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
11591 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
11592 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
11593 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
11594 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
11595 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
11596 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
11597 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
11598 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
11599 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
11600 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
11601 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
11602 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
11603 wmi_service[wmi_service_mcc_bcn_interval_change] =
11604 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
11605 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
11606 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
11607 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
11608 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
11609 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
11610 wmi_service[wmi_service_lte_ant_share_support] =
11611 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
11612 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
11613 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
11614 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
11615 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
11616 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
11617 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
11618 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
11619 wmi_service[wmi_service_bcn_txrate_override] =
11620 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
11621 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
11622 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
11623 wmi_service[wmi_service_estimate_linkspeed] =
11624 WMI_SERVICE_ESTIMATE_LINKSPEED;
11625 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
11626 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
11627 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
11628 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
11629 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
11630 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
11631 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
11632 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
11633 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
11634 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
11635 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
11636 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
11637 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
11638 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
11639 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
11640 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
11641 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
11642 wmi_service[wmi_service_sap_auth_offload] =
11643 WMI_SERVICE_SAP_AUTH_OFFLOAD;
11644 wmi_service[wmi_service_dual_band_simultaneous_support] =
11645 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
11646 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
11647 wmi_service[wmi_service_ap_arpns_offload] =
11648 WMI_SERVICE_AP_ARPNS_OFFLOAD;
11649 wmi_service[wmi_service_per_band_chainmask_support] =
11650 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
11651 wmi_service[wmi_service_packet_filter_offload] =
11652 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
11653 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
11654 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
11655 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
11656 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
11657 wmi_service[wmi_service_multiple_vdev_restart] =
11658 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
11659
11660 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
11661 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
11662 wmi_service[wmi_service_smart_antenna_sw_support] =
11663 WMI_SERVICE_UNAVAILABLE;
11664 wmi_service[wmi_service_smart_antenna_hw_support] =
11665 WMI_SERVICE_UNAVAILABLE;
11666 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053011667 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011668 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053011669 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
11670 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
11671 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
11672 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
11673 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
11674 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
11675 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
11676 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053011677 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
11678 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
11679 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011680 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011681 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
11682 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
11683 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
11684 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
11685 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
11686 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011687 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
11688 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
11689 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
11690 wmi_service[wmi_service_unified_wow_capability] =
11691 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
11692 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011693 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011694 wmi_service[wmi_service_sync_delete_cmds] =
11695 WMI_SERVICE_SYNC_DELETE_CMDS;
11696 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
11697 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
11698 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
11699 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
11700 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
11701 wmi_service[wmi_service_deprecated_replace] =
11702 WMI_SERVICE_DEPRECATED_REPLACE;
11703 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
11704 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
11705 wmi_service[wmi_service_enhanced_mcast_filter] =
11706 WMI_SERVICE_ENHANCED_MCAST_FILTER;
11707 wmi_service[wmi_service_half_rate_quarter_rate_support] =
11708 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
11709 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
11710 wmi_service[wmi_service_p2p_listen_offload_support] =
11711 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
11712 wmi_service[wmi_service_mark_first_wakeup_packet] =
11713 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
11714 wmi_service[wmi_service_multiple_mcast_filter_set] =
11715 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
11716 wmi_service[wmi_service_host_managed_rx_reorder] =
11717 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
11718 wmi_service[wmi_service_flash_rdwr_support] =
11719 WMI_SERVICE_FLASH_RDWR_SUPPORT;
11720 wmi_service[wmi_service_wlan_stats_report] =
11721 WMI_SERVICE_WLAN_STATS_REPORT;
11722 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
11723 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
11724 wmi_service[wmi_service_dfs_phyerr_offload] =
11725 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
11726 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
11727 wmi_service[wmi_service_fw_mem_dump_support] =
11728 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
11729 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
11730 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
11731 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
11732 wmi_service[wmi_service_hw_data_filtering] =
11733 WMI_SERVICE_HW_DATA_FILTERING;
11734 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
11735 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053011736 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053011737 wmi_service[wmi_service_extended_nss_support] =
11738 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053011739 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053011740 wmi_service[wmi_service_bcn_offload_start_stop_support] =
11741 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053011742 wmi_service[wmi_service_offchan_data_tid_support] =
11743 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053011744 wmi_service[wmi_service_support_dma] =
11745 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011746 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
11747 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
11748 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080011749 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
11750 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053011751 wmi_service[wmi_service_11k_neighbour_report_support] =
11752 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080011753 wmi_service[wmi_service_ap_obss_detection_offload] =
11754 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
11755 wmi_service[wmi_service_bss_color_offload] =
11756 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053011757 wmi_service[wmi_service_gmac_offload_support] =
11758 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080011759 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
11760 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
11761 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
11762 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070011763 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
11764 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053011765 wmi_service[wmi_service_listen_interval_offload_support] =
11766 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053011767 wmi_service[wmi_service_esp_support] = WMI_SERVICE_ESP_SUPPORT;
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011768 wmi_service[wmi_service_obss_spatial_reuse] =
11769 WMI_SERVICE_OBSS_SPATIAL_REUSE;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011770
Soumya Bhat488092d2017-03-22 14:41:01 +053011771}
11772
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011773#ifndef CONFIG_MCL
11774
Govind Singhe7f2f342016-05-23 12:12:52 +053011775/**
11776 * populate_pdev_param_tlv() - populates pdev params
11777 *
11778 * @param pdev_param: Pointer to hold pdev params
11779 * Return: None
11780 */
11781static void populate_pdev_param_tlv(uint32_t *pdev_param)
11782{
11783 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
11784 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
11785 pdev_param[wmi_pdev_param_txpower_limit2g] =
11786 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
11787 pdev_param[wmi_pdev_param_txpower_limit5g] =
11788 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
11789 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
11790 pdev_param[wmi_pdev_param_beacon_gen_mode] =
11791 WMI_PDEV_PARAM_BEACON_GEN_MODE;
11792 pdev_param[wmi_pdev_param_beacon_tx_mode] =
11793 WMI_PDEV_PARAM_BEACON_TX_MODE;
11794 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
11795 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
11796 pdev_param[wmi_pdev_param_protection_mode] =
11797 WMI_PDEV_PARAM_PROTECTION_MODE;
11798 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
11799 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
11800 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
11801 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
11802 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
11803 pdev_param[wmi_pdev_param_sta_kickout_th] =
11804 WMI_PDEV_PARAM_STA_KICKOUT_TH;
11805 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
11806 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
11807 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
11808 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
11809 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
11810 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
11811 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
11812 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
11813 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
11814 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
11815 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
11816 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
11817 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
11818 pdev_param[wmi_pdev_param_ltr_sleep_override] =
11819 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
11820 pdev_param[wmi_pdev_param_ltr_rx_override] =
11821 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
11822 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
11823 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
11824 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
11825 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
11826 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
11827 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
11828 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
11829 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
11830 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
11831 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
11832 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
11833 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
11834 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
11835 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
11836 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
11837 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
11838 pdev_param[wmi_pdev_param_peer_stats_update_period] =
11839 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
11840 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
11841 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
11842 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
11843 pdev_param[wmi_pdev_param_arp_ac_override] =
11844 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
11845 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
11846 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
11847 pdev_param[wmi_pdev_param_ani_poll_period] =
11848 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
11849 pdev_param[wmi_pdev_param_ani_listen_period] =
11850 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
11851 pdev_param[wmi_pdev_param_ani_ofdm_level] =
11852 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
11853 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
11854 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
11855 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
11856 pdev_param[wmi_pdev_param_idle_ps_config] =
11857 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
11858 pdev_param[wmi_pdev_param_power_gating_sleep] =
11859 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
11860 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
11861 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
11862 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
11863 pdev_param[wmi_pdev_param_hw_rfkill_config] =
11864 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
11865 pdev_param[wmi_pdev_param_low_power_rf_enable] =
11866 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
11867 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
11868 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
11869 pdev_param[wmi_pdev_param_power_collapse_enable] =
11870 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
11871 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
11872 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
11873 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
11874 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
11875 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
11876 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
11877 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
11878 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
11879 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
11880 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
11881 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
11882 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
11883 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
11884 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
11885 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
11886 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
11887 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
11888 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
11889 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
11890 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
11891 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
11892 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
11893 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
11894 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
11895 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
11896 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
11897 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
11898 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
11899 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
11900 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
11901 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
11902 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
11903 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
11904 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
11905 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
11906 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
11907 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
11908 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
11909 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
11910 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
11911 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
11912 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
11913 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
11914 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011915 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
11916 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
11917 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053011918 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
11919 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011920 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053011921 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011922 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
11923 pdev_param[wmi_pdev_param_proxy_sta_mode] =
11924 WMI_PDEV_PARAM_PROXY_STA_MODE;
11925 pdev_param[wmi_pdev_param_mu_group_policy] =
11926 WMI_PDEV_PARAM_MU_GROUP_POLICY;
11927 pdev_param[wmi_pdev_param_noise_detection] =
11928 WMI_PDEV_PARAM_NOISE_DETECTION;
11929 pdev_param[wmi_pdev_param_noise_threshold] =
11930 WMI_PDEV_PARAM_NOISE_THRESHOLD;
11931 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
11932 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
11933 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011934 pdev_param[wmi_pdev_param_atf_strict_sch] =
11935 WMI_PDEV_PARAM_ATF_STRICT_SCH;
11936 pdev_param[wmi_pdev_param_atf_sched_duration] =
11937 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011938 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
11939 pdev_param[wmi_pdev_param_sensitivity_level] =
11940 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
11941 pdev_param[wmi_pdev_param_signed_txpower_2g] =
11942 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
11943 pdev_param[wmi_pdev_param_signed_txpower_5g] =
11944 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070011945 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
11946 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
11947 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
11948 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011949 pdev_param[wmi_pdev_param_cca_threshold] =
11950 WMI_PDEV_PARAM_CCA_THRESHOLD;
11951 pdev_param[wmi_pdev_param_rts_fixed_rate] =
11952 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011953 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011954 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
11955 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
11956 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
11957 pdev_param[wmi_pdev_param_arp_srcaddr] =
11958 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
11959 pdev_param[wmi_pdev_param_arp_dstaddr] =
11960 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
11961 pdev_param[wmi_pdev_param_txpower_decr_db] =
11962 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053011963 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
11964 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011965 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
11966 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053011967 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011968 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011969 pdev_param[wmi_pdev_param_cust_txpower_scale] =
11970 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011971 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
11972 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011973 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
11974 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053011975 pdev_param[wmi_pdev_param_igmpmld_override] =
11976 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
11977 pdev_param[wmi_pdev_param_igmpmld_tid] =
11978 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011979 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
11980 pdev_param[wmi_pdev_param_block_interbss] =
11981 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053011982 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011983 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
11984 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
11985 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011986 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011987 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053011988 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
11989 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011990 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053011991 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
11992 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053011993 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
11994 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
11995 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
11996 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053011997 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
11998 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
11999 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
12000 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
12001 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
12002 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
12003 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
12004 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
12005 pdev_param[wmi_pdev_param_fast_channel_reset] =
12006 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
12007 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053012008 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053012009 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053012010 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
12011 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053012012 pdev_param[wmi_pdev_param_esp_indication_period] =
12013 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053012014 pdev_param[wmi_pdev_param_esp_ba_window] = WMI_PDEV_PARAM_ESP_BA_WINDOW;
12015 pdev_param[wmi_pdev_param_esp_airtime_fraction] =
12016 WMI_PDEV_PARAM_ESP_AIRTIME_FRACTION;
12017 pdev_param[wmi_pdev_param_esp_ppdu_duration] =
12018 WMI_PDEV_PARAM_ESP_PPDU_DURATION;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053012019#ifdef WLAN_RU26_SUPPORT
12020 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
12021#endif
Abhijit Pradhanf6694f82018-10-17 10:13:15 +053012022 pdev_param[wmi_pdev_param_use_nol] = WMI_PDEV_PARAM_USE_NOL;
Rhythm Patwa24e238e2018-08-11 10:23:53 -070012023 /* Trigger interval for all trigger types. */
12024 pdev_param[wmi_pdev_param_ul_trig_int] =
12025 WMI_PDEV_PARAM_SET_UL_BSR_TRIG_INTERVAL;
Govind Singhe7f2f342016-05-23 12:12:52 +053012026}
12027
12028/**
12029 * populate_vdev_param_tlv() - populates vdev params
12030 *
12031 * @param vdev_param: Pointer to hold vdev params
12032 * Return: None
12033 */
12034static void populate_vdev_param_tlv(uint32_t *vdev_param)
12035{
12036 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
12037 vdev_param[wmi_vdev_param_fragmentation_threshold] =
12038 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
12039 vdev_param[wmi_vdev_param_beacon_interval] =
12040 WMI_VDEV_PARAM_BEACON_INTERVAL;
12041 vdev_param[wmi_vdev_param_listen_interval] =
12042 WMI_VDEV_PARAM_LISTEN_INTERVAL;
12043 vdev_param[wmi_vdev_param_multicast_rate] =
12044 WMI_VDEV_PARAM_MULTICAST_RATE;
12045 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
12046 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
12047 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
12048 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
12049 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
12050 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
12051 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
12052 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
12053 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
12054 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
12055 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
12056 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
12057 vdev_param[wmi_vdev_param_bmiss_count_max] =
12058 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
12059 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
12060 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
12061 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
12062 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
12063 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
12064 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
12065 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
12066 vdev_param[wmi_vdev_param_disable_htprotection] =
12067 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
12068 vdev_param[wmi_vdev_param_sta_quickkickout] =
12069 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
12070 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
12071 vdev_param[wmi_vdev_param_protection_mode] =
12072 WMI_VDEV_PARAM_PROTECTION_MODE;
12073 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
12074 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
12075 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
12076 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
12077 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
12078 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
12079 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
12080 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
12081 vdev_param[wmi_vdev_param_bcast_data_rate] =
12082 WMI_VDEV_PARAM_BCAST_DATA_RATE;
12083 vdev_param[wmi_vdev_param_mcast_data_rate] =
12084 WMI_VDEV_PARAM_MCAST_DATA_RATE;
12085 vdev_param[wmi_vdev_param_mcast_indicate] =
12086 WMI_VDEV_PARAM_MCAST_INDICATE;
12087 vdev_param[wmi_vdev_param_dhcp_indicate] =
12088 WMI_VDEV_PARAM_DHCP_INDICATE;
12089 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
12090 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
12091 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
12092 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
12093 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
12094 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
12095 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
12096 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
12097 vdev_param[wmi_vdev_param_ap_enable_nawds] =
12098 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
12099 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
12100 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
12101 vdev_param[wmi_vdev_param_packet_powersave] =
12102 WMI_VDEV_PARAM_PACKET_POWERSAVE;
12103 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
12104 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
12105 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
12106 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
12107 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
12108 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
12109 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
12110 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
12111 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
12112 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
12113 vdev_param[wmi_vdev_param_early_rx_slop_step] =
12114 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
12115 vdev_param[wmi_vdev_param_early_rx_init_slop] =
12116 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
12117 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
12118 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
12119 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
12120 vdev_param[wmi_vdev_param_snr_num_for_cal] =
12121 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
12122 vdev_param[wmi_vdev_param_roam_fw_offload] =
12123 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
12124 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
12125 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
12126 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
12127 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
12128 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
12129 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
12130 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
12131 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
12132 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
12133 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
12134 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
12135 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
12136 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
12137 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
12138 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
12139 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
12140 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
12141 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
12142 vdev_param[wmi_vdev_param_inactivity_cnt] =
12143 WMI_VDEV_PARAM_INACTIVITY_CNT;
12144 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
12145 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
12146 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
12147 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
12148 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
12149 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
12150 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
12151 vdev_param[wmi_vdev_param_rx_leak_window] =
12152 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
12153 vdev_param[wmi_vdev_param_stats_avg_factor] =
12154 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
12155 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
12156 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
12157 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
12158 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
12159 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
12160 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053012161 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
12162 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053012163 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080012164 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
12165 vdev_param[wmi_vdev_param_he_range_ext_enable] =
12166 WMI_VDEV_PARAM_HE_RANGE_EXT;
12167 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
12168 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070012169 vdev_param[wmi_vdev_param_set_he_sounding_mode]
12170 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070012171 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053012172 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
12173 vdev_param[wmi_vdev_param_dtim_enable_cts] =
12174 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
12175 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
12176 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
12177 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
12178 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053012179 vdev_param[wmi_vdev_param_mcast2ucast_set] =
12180 WMI_VDEV_PARAM_MCAST2UCAST_SET;
12181 vdev_param[wmi_vdev_param_rc_num_retries] =
12182 WMI_VDEV_PARAM_RC_NUM_RETRIES;
12183 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
12184 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
12185 vdev_param[wmi_vdev_param_rts_fixed_rate] =
12186 WMI_VDEV_PARAM_RTS_FIXED_RATE;
12187 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
12188 vdev_param[wmi_vdev_param_vht80_ratemask] =
12189 WMI_VDEV_PARAM_VHT80_RATEMASK;
12190 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
12191 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
12192 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012193 vdev_param[wmi_vdev_param_set_he_ltf] =
12194 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053012195 vdev_param[wmi_vdev_param_disable_cabq] =
12196 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053012197 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
12198 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080012199 vdev_param[wmi_vdev_param_set_ba_mode] =
12200 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080012201 vdev_param[wmi_vdev_param_capabilities] =
12202 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012203 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
12204 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Rhythm Patwa24e238e2018-08-11 10:23:53 -070012205 vdev_param[wmi_vdev_param_ul_shortgi] = WMI_VDEV_PARAM_UL_GI;
12206 vdev_param[wmi_vdev_param_ul_he_ltf] = WMI_VDEV_PARAM_UL_HE_LTF;
12207 vdev_param[wmi_vdev_param_ul_nss] = WMI_VDEV_PARAM_UL_NSS;
12208 vdev_param[wmi_vdev_param_ul_ppdu_bw] = WMI_VDEV_PARAM_UL_PPDU_BW;
12209 vdev_param[wmi_vdev_param_ul_ldpc] = WMI_VDEV_PARAM_UL_LDPC;
12210 vdev_param[wmi_vdev_param_ul_stbc] = WMI_VDEV_PARAM_UL_STBC;
12211 vdev_param[wmi_vdev_param_ul_fixed_rate] = WMI_VDEV_PARAM_UL_FIXED_RATE;
12212
Govind Singhe7f2f342016-05-23 12:12:52 +053012213}
12214#endif
12215
Govind Singh5eb51532016-03-09 11:34:12 +053012216/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012217 * populate_target_defines_tlv() - Populate target defines and params
12218 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053012219 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012220 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053012221 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012222#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012223static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053012224{
Govind Singhe7f2f342016-05-23 12:12:52 +053012225 populate_pdev_param_tlv(wmi_handle->pdev_param);
12226 populate_vdev_param_tlv(wmi_handle->vdev_param);
12227}
12228#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012229static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
12230{ }
12231#endif
12232
12233/**
Zhang Qian537fca62018-01-03 16:33:24 +080012234 * wmi_ocb_ut_attach() - Attach OCB test framework
12235 * @wmi_handle: wmi handle
12236 *
12237 * Return: None
12238 */
12239#ifdef WLAN_OCB_UT
12240void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
12241#else
12242static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
12243{
12244 return;
12245}
12246#endif
12247
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012248/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012249 * wmi_tlv_attach() - Attach TLV APIs
12250 *
12251 * Return: None
12252 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012253void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053012254{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012255 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080012256 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053012257 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053012258#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053012259 /* Skip saving WMI_CMD_HDR and TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012260 wmi_handle->soc->buf_offset_command = 8;
Rakesh Pillai05110462017-12-27 14:08:59 +053012261 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012262 wmi_handle->soc->buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053012263#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053012264 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053012265 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012266 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053012267 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080012268 wmi_extscan_attach_tlv(wmi_handle);
Sathish Kumarefb25bf2018-10-02 11:03:59 +053012269 wmi_smart_ant_attach_tlv(wmi_handle);
12270 wmi_dbr_attach_tlv(wmi_handle);
12271 wmi_atf_attach_tlv(wmi_handle);
12272 wmi_ap_attach_tlv(wmi_handle);
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080012273 wmi_ocb_attach_tlv(wmi_handle);
12274 wmi_nan_attach_tlv(wmi_handle);
12275 wmi_p2p_attach_tlv(wmi_handle);
12276 wmi_roam_attach_tlv(wmi_handle);
12277 wmi_concurrency_attach_tlv(wmi_handle);
12278 wmi_pmo_attach_tlv(wmi_handle);
12279 wmi_sta_attach_tlv(wmi_handle);
12280 wmi_11ax_bss_color_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053012281}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080012282qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053012283
12284/**
12285 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
12286 *
12287 * Return: None
12288 */
12289void wmi_tlv_init(void)
12290{
12291 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
12292}