blob: 80efb598190de1a67e9195f3701d4f8c768e29a4 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -08002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
Govind Singh5eb51532016-03-09 11:34:12 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Govind Singh5eb51532016-03-09 11:34:12 +053019#include "wmi_unified_api.h"
20#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053021#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053022#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053023#include "wmi_version_whitelist.h"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080024#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053025#include <wlan_defs.h>
Wu Gao5d1c9ed2018-10-12 18:16:09 +080026#include <wlan_cmn.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053027#include <htc_services.h>
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053028#ifdef FEATURE_WLAN_APF
Nachiket Kukade7d4f04b2018-05-21 17:28:32 +053029#include "wmi_unified_apf_tlv.h"
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053030#endif
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053031#ifdef WLAN_FEATURE_ACTION_OUI
32#include "wmi_unified_action_oui_tlv.h"
33#endif
Wu Gao52c0b772018-05-17 16:14:00 +080034#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070035#include "wlan_pmo_hw_filter_public_struct.h"
36#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053037#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053038#ifdef WLAN_SUPPORT_GREEN_AP
39#include "wlan_green_ap_api.h"
40#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053041
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070042#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080043
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080044#ifdef WLAN_POLICY_MGR_ENABLE
45#include "wlan_policy_mgr_public_struct.h"
46#endif
47
Sathish Kumarefb25bf2018-10-02 11:03:59 +053048#ifdef WMI_SMART_ANT_SUPPORT
49#include "wmi_unified_smart_ant_api.h"
50#endif
51
52#ifdef WMI_DBR_SUPPORT
53#include "wmi_unified_dbr_api.h"
54#endif
55
56#ifdef WMI_ATF_SUPPORT
57#include "wmi_unified_atf_api.h"
58#endif
59
60#ifdef WMI_AP_SUPPORT
61#include "wmi_unified_ap_api.h"
62#endif
63
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053064/* HTC service ids for WMI for multi-radio */
65static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
66 WMI_CONTROL_SVC_WMAC1,
67 WMI_CONTROL_SVC_WMAC2};
68
Arif Hussainb522ac92018-06-27 10:51:06 -070069/**
70 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053071 * host to target defines.
Arif Hussainb522ac92018-06-27 10:51:06 -070072 * @param pdev_id: host pdev_id to be converted.
73 * Return: target pdev_id after conversion.
74 */
75static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
76{
77 switch (pdev_id) {
78 case WMI_HOST_PDEV_ID_SOC:
79 return WMI_PDEV_ID_SOC;
80 case WMI_HOST_PDEV_ID_0:
81 return WMI_PDEV_ID_1ST;
82 case WMI_HOST_PDEV_ID_1:
83 return WMI_PDEV_ID_2ND;
84 case WMI_HOST_PDEV_ID_2:
85 return WMI_PDEV_ID_3RD;
86 }
87
88 QDF_ASSERT(0);
89
90 return WMI_PDEV_ID_SOC;
91}
92
93/**
94 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053095 * target to host defines.
Arif Hussainb522ac92018-06-27 10:51:06 -070096 * @param pdev_id: target pdev_id to be converted.
97 * Return: host pdev_id after conversion.
98 */
99static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
100{
101 switch (pdev_id) {
102 case WMI_PDEV_ID_SOC:
103 return WMI_HOST_PDEV_ID_SOC;
104 case WMI_PDEV_ID_1ST:
105 return WMI_HOST_PDEV_ID_0;
106 case WMI_PDEV_ID_2ND:
107 return WMI_HOST_PDEV_ID_1;
108 case WMI_PDEV_ID_3RD:
109 return WMI_HOST_PDEV_ID_2;
110 }
111
112 QDF_ASSERT(0);
113
114 return WMI_HOST_PDEV_ID_SOC;
115}
116
117/**
118 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
119 *
120 * Return None.
121 */
122static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
123{
124 wmi_handle->ops->convert_pdev_id_host_to_target =
125 convert_host_pdev_id_to_target_pdev_id;
126 wmi_handle->ops->convert_pdev_id_target_to_host =
127 convert_target_pdev_id_to_host_pdev_id;
128}
129
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530130/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530131 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530132 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530133 * @cmd: pointer target vdev create command buffer
134 * @param: pointer host params for vdev create
135 *
136 * Return: None
137 */
138#ifdef CONFIG_MCL
139static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530140 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530141 wmi_vdev_create_cmd_fixed_param * cmd,
142 struct vdev_create_params *param)
143{
144 cmd->pdev_id = WMI_PDEV_ID_SOC;
145}
146#else
147static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530148 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530149 wmi_vdev_create_cmd_fixed_param * cmd,
150 struct vdev_create_params *param)
151{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530152 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
153 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530154}
155#endif
156
Qiwei Cai2aacaff2018-09-13 16:17:46 +0800157void wmi_mtrace(uint32_t message_id, uint16_t vdev_id, uint32_t data)
Ashish Kumar Dhanotiyac8b83e52018-08-02 14:26:53 +0530158{
159 uint16_t mtrace_message_id;
160
161 mtrace_message_id = QDF_WMI_MTRACE_CMD_ID(message_id) |
162 (QDF_WMI_MTRACE_GRP_ID(message_id) <<
163 QDF_WMI_MTRACE_CMD_NUM_BITS);
164 qdf_mtrace(QDF_MODULE_ID_WMI, QDF_MODULE_ID_TARGET,
165 mtrace_message_id, vdev_id, data);
166}
167
Qiwei Cai2aacaff2018-09-13 16:17:46 +0800168qdf_export_symbol(wmi_mtrace);
169
Ashish Kumar Dhanotiyac8b83e52018-08-02 14:26:53 +0530170/**
Govind Singh5eb51532016-03-09 11:34:12 +0530171 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
172 * @wmi_handle: wmi handle
173 * @param: pointer to hold vdev create parameter
174 * @macaddr: vdev mac address
175 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530176 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530177 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530178static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530179 uint8_t macaddr[IEEE80211_ADDR_LEN],
180 struct vdev_create_params *param)
181{
182 wmi_vdev_create_cmd_fixed_param *cmd;
183 wmi_buf_t buf;
184 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530185 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700186 int num_bands = 2;
187 uint8_t *buf_ptr;
188 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530189
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700190 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530191 buf = wmi_buf_alloc(wmi_handle, len);
192 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530193 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530194 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530195 }
196 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
197 WMITLV_SET_HDR(&cmd->tlv_header,
198 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
199 WMITLV_GET_STRUCT_TLVLEN
200 (wmi_vdev_create_cmd_fixed_param));
201 cmd->vdev_id = param->if_id;
202 cmd->vdev_type = param->type;
203 cmd->vdev_subtype = param->subtype;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700204 cmd->flags = param->mbssid_flags;
205 cmd->vdevid_trans = param->vdevid_trans;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700206 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530207 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530208 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700209 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
210 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530211 macaddr[0], macaddr[1], macaddr[2],
212 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700213 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
214 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
215 (num_bands * sizeof(wmi_vdev_txrx_streams)));
216 buf_ptr += WMI_TLV_HDR_SIZE;
217
Govind Singh224a7312016-06-21 14:33:26 +0530218 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700219 param->type, param->subtype,
220 param->nss_2g, param->nss_5g);
221 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
222 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
223 txrx_streams->supported_tx_streams = param->nss_2g;
224 txrx_streams->supported_rx_streams = param->nss_2g;
225 WMITLV_SET_HDR(&txrx_streams->tlv_header,
226 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
227 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
228
229 txrx_streams++;
230 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
231 txrx_streams->supported_tx_streams = param->nss_5g;
232 txrx_streams->supported_rx_streams = param->nss_5g;
233 WMITLV_SET_HDR(&txrx_streams->tlv_header,
234 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
235 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530236 wmi_mtrace(WMI_VDEV_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530237 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530238 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530239 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530240 wmi_buf_free(buf);
241 }
242
243 return ret;
244}
245
246/**
247 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
248 * @wmi_handle: wmi handle
249 * @if_id: vdev id
250 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530251 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530252 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530253static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530254 uint8_t if_id)
255{
256 wmi_vdev_delete_cmd_fixed_param *cmd;
257 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530258 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530259
260 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
261 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530262 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530263 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530264 }
265
266 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
267 WMITLV_SET_HDR(&cmd->tlv_header,
268 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
269 WMITLV_GET_STRUCT_TLVLEN
270 (wmi_vdev_delete_cmd_fixed_param));
271 cmd->vdev_id = if_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530272 wmi_mtrace(WMI_VDEV_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530273 ret = wmi_unified_cmd_send(wmi_handle, buf,
274 sizeof(wmi_vdev_delete_cmd_fixed_param),
275 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530276 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530277 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530278 wmi_buf_free(buf);
279 }
Govind Singhb53420c2016-03-09 14:32:57 +0530280 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530281
282 return ret;
283}
284
285/**
286 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
287 * @wmi: wmi handle
288 * @vdev_id: vdev id
289 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530290 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530291 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530292static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530293 uint8_t vdev_id)
294{
295 wmi_vdev_stop_cmd_fixed_param *cmd;
296 wmi_buf_t buf;
297 int32_t len = sizeof(*cmd);
298
299 buf = wmi_buf_alloc(wmi, len);
300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530301 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530302 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530303 }
304 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
305 WMITLV_SET_HDR(&cmd->tlv_header,
306 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
307 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
308 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530309 wmi_mtrace(WMI_VDEV_STOP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530310 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530311 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530312 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530313 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530314 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530315 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530316
317 return 0;
318}
319
320/**
321 * send_vdev_down_cmd_tlv() - send vdev down command to fw
322 * @wmi: wmi handle
323 * @vdev_id: vdev id
324 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530325 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530326 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530327static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530328{
329 wmi_vdev_down_cmd_fixed_param *cmd;
330 wmi_buf_t buf;
331 int32_t len = sizeof(*cmd);
332
333 buf = wmi_buf_alloc(wmi, len);
334 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530335 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530336 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530337 }
338 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
339 WMITLV_SET_HDR(&cmd->tlv_header,
340 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
341 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
342 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530343 wmi_mtrace(WMI_VDEV_DOWN_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530344 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530345 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530346 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530347 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530348 }
Govind Singhb53420c2016-03-09 14:32:57 +0530349 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530350
351 return 0;
352}
353
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530354#ifdef CONFIG_MCL
355static inline void copy_channel_info(
356 wmi_vdev_start_request_cmd_fixed_param * cmd,
357 wmi_channel *chan,
358 struct vdev_start_params *req)
359{
360 chan->mhz = req->chan_freq;
361
362 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
363
364 chan->band_center_freq1 = req->band_center_freq1;
365 chan->band_center_freq2 = req->band_center_freq2;
366
367 if (req->is_half_rate)
368 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
369 else if (req->is_quarter_rate)
370 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
371
Naveen Rawat44f2f432016-12-01 12:58:57 -0800372 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530373 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
374 cmd->disable_hw_ack = req->dis_hw_ack;
375 }
376
377 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
378 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
379
380}
381#else
382static inline void copy_channel_info(
383 wmi_vdev_start_request_cmd_fixed_param * cmd,
384 wmi_channel *chan,
385 struct vdev_start_params *req)
386{
387 chan->mhz = req->channel.mhz;
388
389 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
390
391 chan->band_center_freq1 = req->channel.cfreq1;
392 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800393 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530394
395 if (req->channel.half_rate)
396 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
397 else if (req->channel.quarter_rate)
398 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
399
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800400 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
401
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530402 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530403 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530404 cmd->disable_hw_ack = req->disable_hw_ack;
405 }
406
Krishna Rao0b952ea2017-03-20 13:30:10 +0530407 if (req->channel.dfs_set_cfreq2)
408 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
409
Kai Chen4710d462017-12-15 14:06:06 -0800410 /* According to firmware both reg power and max tx power
411 * on set channel power is used and set it to max reg
412 * power from regulatory.
413 */
414 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
415 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530416 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800417 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
418 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
419 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530420
421}
422#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530423/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530424 * send_vdev_start_cmd_tlv() - send vdev start request to fw
425 * @wmi_handle: wmi handle
426 * @req: vdev start params
427 *
428 * Return: QDF status
429 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530430static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431 struct vdev_start_params *req)
432{
433 wmi_vdev_start_request_cmd_fixed_param *cmd;
434 wmi_buf_t buf;
435 wmi_channel *chan;
436 int32_t len, ret;
437 uint8_t *buf_ptr;
438
439 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
440 buf = wmi_buf_alloc(wmi_handle, len);
441 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530442 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530443 return QDF_STATUS_E_NOMEM;
444 }
445 buf_ptr = (uint8_t *) wmi_buf_data(buf);
446 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
447 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
448 WMITLV_SET_HDR(&cmd->tlv_header,
449 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
450 WMITLV_GET_STRUCT_TLVLEN
451 (wmi_vdev_start_request_cmd_fixed_param));
452 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
453 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
454 cmd->vdev_id = req->vdev_id;
455
456 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530457 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530458
459 cmd->beacon_interval = req->beacon_intval;
460 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530461
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800462 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
463 if (req->bcn_tx_rate_code)
464 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
465
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530466 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530467 cmd->beacon_interval = req->beacon_intval;
468 cmd->dtim_period = req->dtim_period;
469
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530470 /* Copy the SSID */
471 if (req->ssid.length) {
472 if (req->ssid.length < sizeof(cmd->ssid.ssid))
473 cmd->ssid.ssid_len = req->ssid.length;
474 else
475 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
476 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
477 cmd->ssid.ssid_len);
478 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530479
480 if (req->hidden_ssid)
481 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
482
483 if (req->pmf_enabled)
484 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530485 }
486
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700487 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530488 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530489 cmd->preferred_rx_streams = req->preferred_rx_streams;
490 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700491 cmd->cac_duration_ms = req->cac_duration_ms;
492 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700493 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530494
495 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
496 sizeof(wmi_channel));
497 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
498 cmd->num_noa_descriptors *
499 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800500 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530501 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
502 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800503 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
504 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
505 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530506 req->is_dfs, req->beacon_intval, cmd->dtim_period,
507 chan->band_center_freq1, chan->band_center_freq2,
508 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700509 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700510 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800511 req->regdomain, req->he_ops,
512 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530513
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530514 if (req->is_restart) {
515 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530516 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
517 WMI_VDEV_RESTART_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530518 } else {
519 wmi_mtrace(WMI_VDEV_START_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530520 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
521 WMI_VDEV_START_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530522 }
523 if (ret) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530524 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530525 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530526 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530527 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530528
529 return QDF_STATUS_SUCCESS;
530}
531
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530532/**
533 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
534 * @wmi_handle: wmi handle
535 * @restart_params: vdev restart params
536 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530537 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530538 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530539static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530540 struct hidden_ssid_vdev_restart_params *restart_params)
541{
542 wmi_vdev_start_request_cmd_fixed_param *cmd;
543 wmi_buf_t buf;
544 wmi_channel *chan;
545 int32_t len;
546 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530547 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530548
549 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
550 buf = wmi_buf_alloc(wmi_handle, len);
551 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530552 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530553 return QDF_STATUS_E_NOMEM;
554 }
555 buf_ptr = (uint8_t *) wmi_buf_data(buf);
556 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
557 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
558
559 WMITLV_SET_HDR(&cmd->tlv_header,
560 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
561 WMITLV_GET_STRUCT_TLVLEN
562 (wmi_vdev_start_request_cmd_fixed_param));
563
564 WMITLV_SET_HDR(&chan->tlv_header,
565 WMITLV_TAG_STRUC_wmi_channel,
566 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
567
568 cmd->vdev_id = restart_params->session_id;
569 cmd->ssid.ssid_len = restart_params->ssid_len;
570 qdf_mem_copy(cmd->ssid.ssid,
571 restart_params->ssid,
572 cmd->ssid.ssid_len);
573 cmd->flags = restart_params->flags;
574 cmd->requestor_id = restart_params->requestor_id;
575 cmd->disable_hw_ack = restart_params->disable_hw_ack;
576
577 chan->mhz = restart_params->mhz;
578 chan->band_center_freq1 =
579 restart_params->band_center_freq1;
580 chan->band_center_freq2 =
581 restart_params->band_center_freq2;
582 chan->info = restart_params->info;
583 chan->reg_info_1 = restart_params->reg_info_1;
584 chan->reg_info_2 = restart_params->reg_info_2;
585
586 cmd->num_noa_descriptors = 0;
587 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
588 sizeof(wmi_channel));
589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
590 cmd->num_noa_descriptors *
591 sizeof(wmi_p2p_noa_descriptor));
592
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530593 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530594 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
595 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530596 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530597 wmi_buf_free(buf);
598 return QDF_STATUS_E_FAILURE;
599 }
600 return QDF_STATUS_SUCCESS;
601}
602
603
604/**
Govind Singh5eb51532016-03-09 11:34:12 +0530605 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
606 * @wmi: wmi handle
607 * @peer_addr: peer mac address
608 * @param: pointer to hold peer flush tid parameter
609 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700610 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530611 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530612static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530613 uint8_t peer_addr[IEEE80211_ADDR_LEN],
614 struct peer_flush_params *param)
615{
616 wmi_peer_flush_tids_cmd_fixed_param *cmd;
617 wmi_buf_t buf;
618 int32_t len = sizeof(*cmd);
619
620 buf = wmi_buf_alloc(wmi, len);
621 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530622 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530623 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530624 }
625 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
626 WMITLV_SET_HDR(&cmd->tlv_header,
627 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
628 WMITLV_GET_STRUCT_TLVLEN
629 (wmi_peer_flush_tids_cmd_fixed_param));
630 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
631 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
632 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530633 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530634 peer_addr, param->vdev_id,
635 param->peer_tid_bitmap);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530636 wmi_mtrace(WMI_PEER_FLUSH_TIDS_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530637 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530638 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530639 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530640 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530641 }
642
643 return 0;
644}
645
646/**
647 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
648 * @wmi: wmi handle
649 * @peer_addr: peer mac addr
650 * @vdev_id: vdev id
651 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530652 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530653 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530654static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530655 uint8_t peer_addr[IEEE80211_ADDR_LEN],
656 uint8_t vdev_id)
657{
658 wmi_peer_delete_cmd_fixed_param *cmd;
659 wmi_buf_t buf;
660 int32_t len = sizeof(*cmd);
661 buf = wmi_buf_alloc(wmi, len);
662 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530663 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530664 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530665 }
666 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
667 WMITLV_SET_HDR(&cmd->tlv_header,
668 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
669 WMITLV_GET_STRUCT_TLVLEN
670 (wmi_peer_delete_cmd_fixed_param));
671 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
672 cmd->vdev_id = vdev_id;
673
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800674 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530675 wmi_mtrace(WMI_PEER_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530676 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530677 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530678 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530679 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530680 }
Govind Singh5eb51532016-03-09 11:34:12 +0530681
682 return 0;
683}
684
685/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530686 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
687 * to target id.
688 * @targ_paramid: Target parameter id to hold the result.
689 * @peer_param_id: host param id.
690 *
691 * Return: QDF_STATUS_SUCCESS for success
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530692 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530693 */
694#ifdef CONFIG_MCL
695static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
696 uint32_t *targ_paramid,
697 uint32_t peer_param_id)
698{
699 *targ_paramid = peer_param_id;
700 return QDF_STATUS_SUCCESS;
701}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700702
703/**
704 * crash_on_send_peer_rx_reorder_queue_remove_cmd() - crash on reorder queue cmd
705 *
706 * On MCL side, we are suspecting this cmd to trigger drop of ARP
707 * response frames from REO by the FW. This function causes a crash if this
708 * command is sent out by the host, so we can track this issue. Ideally no one
709 * should be calling this API from the MCL side
710 *
711 * Return: None
712 */
713static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
714{
715 QDF_BUG(0);
716}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530717#else
718static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
719 uint32_t *targ_paramid,
720 uint32_t peer_param_id)
721{
722 switch (peer_param_id) {
723 case WMI_HOST_PEER_MIMO_PS_STATE:
724 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
725 break;
726 case WMI_HOST_PEER_AMPDU:
727 *targ_paramid = WMI_PEER_AMPDU;
728 break;
729 case WMI_HOST_PEER_AUTHORIZE:
730 *targ_paramid = WMI_PEER_AUTHORIZE;
731 break;
732 case WMI_HOST_PEER_CHWIDTH:
733 *targ_paramid = WMI_PEER_CHWIDTH;
734 break;
735 case WMI_HOST_PEER_NSS:
736 *targ_paramid = WMI_PEER_NSS;
737 break;
738 case WMI_HOST_PEER_USE_4ADDR:
739 *targ_paramid = WMI_PEER_USE_4ADDR;
740 break;
741 case WMI_HOST_PEER_MEMBERSHIP:
742 *targ_paramid = WMI_PEER_MEMBERSHIP;
743 break;
744 case WMI_HOST_PEER_USERPOS:
745 *targ_paramid = WMI_PEER_USERPOS;
746 break;
747 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
748 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
749 break;
750 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
751 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
752 break;
753 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
754 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
755 break;
756 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
757 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
758 break;
759 case WMI_HOST_PEER_PHYMODE:
760 *targ_paramid = WMI_PEER_PHYMODE;
761 break;
762 case WMI_HOST_PEER_USE_FIXED_PWR:
763 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
764 break;
765 case WMI_HOST_PEER_PARAM_FIXED_RATE:
766 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
767 break;
768 case WMI_HOST_PEER_SET_MU_WHITELIST:
769 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
770 break;
771 case WMI_HOST_PEER_SET_MAC_TX_RATE:
772 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
773 break;
774 case WMI_HOST_PEER_SET_MIN_TX_RATE:
775 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
776 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530777 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
778 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
779 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530780 case WMI_HOST_PEER_NSS_VHT160:
781 *targ_paramid = WMI_PEER_NSS_VHT160;
782 break;
783 case WMI_HOST_PEER_NSS_VHT80_80:
784 *targ_paramid = WMI_PEER_NSS_VHT80_80;
785 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530786 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
787 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
788 break;
789 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
790 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
791 break;
792 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
793 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
794 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530795 case WMI_HOST_PEER_PARAM_MU_ENABLE:
796 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
797 break;
798 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
799 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
800 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530801 default:
802 return QDF_STATUS_E_NOSUPPORT;
803 }
804
805 return QDF_STATUS_SUCCESS;
806}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700807
808static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
809{
810 /* No-OP */
811}
812
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530813#endif
814/**
Govind Singh5eb51532016-03-09 11:34:12 +0530815 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530816 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530817 * @peer_addr: peer mac address
818 * @param : pointer to hold peer set parameter
819 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530820 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530821 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530822static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530823 uint8_t peer_addr[IEEE80211_ADDR_LEN],
824 struct peer_set_params *param)
825{
826 wmi_peer_set_param_cmd_fixed_param *cmd;
827 wmi_buf_t buf;
828 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530829 uint32_t param_id;
830
831 if (convert_host_peer_id_to_target_id_tlv(&param_id,
832 param->param_id) != QDF_STATUS_SUCCESS)
833 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530834
835 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
836 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530837 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530838 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530839 }
840 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
841 WMITLV_SET_HDR(&cmd->tlv_header,
842 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
843 WMITLV_GET_STRUCT_TLVLEN
844 (wmi_peer_set_param_cmd_fixed_param));
845 cmd->vdev_id = param->vdev_id;
846 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530847 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530848 cmd->param_value = param->param_value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530849 wmi_mtrace(WMI_PEER_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530850 err = wmi_unified_cmd_send(wmi, buf,
851 sizeof(wmi_peer_set_param_cmd_fixed_param),
852 WMI_PEER_SET_PARAM_CMDID);
853 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530854 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530855 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530856 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530857 }
858
859 return 0;
860}
861
862/**
863 * send_vdev_up_cmd_tlv() - send vdev up command in fw
864 * @wmi: wmi handle
865 * @bssid: bssid
866 * @vdev_up_params: pointer to hold vdev up parameter
867 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530868 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530869 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530870static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530871 uint8_t bssid[IEEE80211_ADDR_LEN],
872 struct vdev_up_params *params)
873{
874 wmi_vdev_up_cmd_fixed_param *cmd;
875 wmi_buf_t buf;
876 int32_t len = sizeof(*cmd);
877
Govind Singhb53420c2016-03-09 14:32:57 +0530878 WMI_LOGD("%s: VDEV_UP", __func__);
879 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530880 params->vdev_id, params->assoc_id, bssid);
881 buf = wmi_buf_alloc(wmi, len);
882 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530883 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530884 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530885 }
886 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
887 WMITLV_SET_HDR(&cmd->tlv_header,
888 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
889 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
890 cmd->vdev_id = params->vdev_id;
891 cmd->vdev_assoc_id = params->assoc_id;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700892 cmd->profile_idx = params->profile_idx;
893 cmd->profile_num = params->profile_num;
894 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->trans_bssid, &cmd->trans_bssid);
Govind Singh5eb51532016-03-09 11:34:12 +0530895 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530896 wmi_mtrace(WMI_VDEV_UP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530897 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530898 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530899 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530900 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530901 }
902
903 return 0;
904}
905
906/**
907 * send_peer_create_cmd_tlv() - send peer create command to fw
908 * @wmi: wmi handle
909 * @peer_addr: peer mac address
910 * @peer_type: peer type
911 * @vdev_id: vdev id
912 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530913 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530914 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530915static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530916 struct peer_create_params *param)
917{
918 wmi_peer_create_cmd_fixed_param *cmd;
919 wmi_buf_t buf;
920 int32_t len = sizeof(*cmd);
921
922 buf = wmi_buf_alloc(wmi, len);
923 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530924 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530925 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530926 }
927 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
928 WMITLV_SET_HDR(&cmd->tlv_header,
929 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
930 WMITLV_GET_STRUCT_TLVLEN
931 (wmi_peer_create_cmd_fixed_param));
932 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
933 cmd->peer_type = param->peer_type;
934 cmd->vdev_id = param->vdev_id;
935
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530936 wmi_mtrace(WMI_PEER_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530937 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530938 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530939 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530940 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530941 }
Govind Singhb53420c2016-03-09 14:32:57 +0530942 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530943 param->vdev_id);
944
945 return 0;
946}
947
948/**
Leo Changeee40872016-09-28 13:43:36 -0700949 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
950 * command to fw
951 * @wmi: wmi handle
952 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
953 *
954 * Return: 0 for success or error code
955 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700956static
Leo Changeee40872016-09-28 13:43:36 -0700957QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
958 struct rx_reorder_queue_setup_params *param)
959{
960 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
961 wmi_buf_t buf;
962 int32_t len = sizeof(*cmd);
963
964 buf = wmi_buf_alloc(wmi, len);
965 if (!buf) {
966 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
967 return QDF_STATUS_E_NOMEM;
968 }
969 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
970 WMITLV_SET_HDR(&cmd->tlv_header,
971 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
972 WMITLV_GET_STRUCT_TLVLEN
973 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
974 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
975 cmd->vdev_id = param->vdev_id;
976 cmd->tid = param->tid;
977 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
978 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
979 cmd->queue_no = param->queue_no;
Gyanranjan Hazarikad6c4d782018-07-25 23:26:16 -0700980 cmd->ba_window_size_valid = param->ba_window_size_valid;
981 cmd->ba_window_size = param->ba_window_size;
982
Leo Changeee40872016-09-28 13:43:36 -0700983
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530984 wmi_mtrace(WMI_PEER_REORDER_QUEUE_SETUP_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -0700985 if (wmi_unified_cmd_send(wmi, buf, len,
986 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
987 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
988 __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +0530989 wmi_buf_free(buf);
Leo Changeee40872016-09-28 13:43:36 -0700990 return QDF_STATUS_E_FAILURE;
991 }
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530992 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d", __func__,
Leo Changeee40872016-09-28 13:43:36 -0700993 param->peer_macaddr, param->vdev_id, param->tid);
994
995 return QDF_STATUS_SUCCESS;
996}
997
998/**
999 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
1000 * command to fw
1001 * @wmi: wmi handle
1002 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
1003 *
1004 * Return: 0 for success or error code
1005 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07001006static
Leo Changeee40872016-09-28 13:43:36 -07001007QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
1008 struct rx_reorder_queue_remove_params *param)
1009{
1010 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
1011 wmi_buf_t buf;
1012 int32_t len = sizeof(*cmd);
1013
Mohit Khannab9e1e542018-07-24 15:28:04 -07001014 crash_on_send_peer_rx_reorder_queue_remove_cmd();
1015
Leo Changeee40872016-09-28 13:43:36 -07001016 buf = wmi_buf_alloc(wmi, len);
1017 if (!buf) {
1018 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
1019 return QDF_STATUS_E_NOMEM;
1020 }
1021 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
1022 wmi_buf_data(buf);
1023 WMITLV_SET_HDR(&cmd->tlv_header,
1024 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
1025 WMITLV_GET_STRUCT_TLVLEN
1026 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
1027 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
1028 cmd->vdev_id = param->vdev_id;
1029 cmd->tid_mask = param->peer_tid_bitmap;
1030
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301031 wmi_mtrace(WMI_PEER_REORDER_QUEUE_REMOVE_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -07001032 if (wmi_unified_cmd_send(wmi, buf, len,
1033 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
1034 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
1035 __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +05301036 wmi_buf_free(buf);
Leo Changeee40872016-09-28 13:43:36 -07001037 return QDF_STATUS_E_FAILURE;
1038 }
1039 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
1040 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
1041
1042 return QDF_STATUS_SUCCESS;
1043}
1044
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301045#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301046/**
Govind Singh5eb51532016-03-09 11:34:12 +05301047 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1048 * @wmi_handle: wmi handle
1049 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301050 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301051 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301052 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301054static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301055 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301056{
1057 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1058 wmi_buf_t buf;
1059 int32_t len = sizeof(*cmd);
1060
Govind Singhb53420c2016-03-09 14:32:57 +05301061 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301062
1063 buf = wmi_buf_alloc(wmi_handle, len);
1064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301065 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301066 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301067 }
1068
1069 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1070 WMITLV_SET_HDR(&cmd->tlv_header,
1071 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1072 WMITLV_GET_STRUCT_TLVLEN
1073 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301074 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301075 cmd->enable = value;
1076
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301077 wmi_mtrace(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301078 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1079 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301081 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301082 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301083 }
1084
1085 return 0;
1086}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301087#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301088
1089/**
1090 * send_pdev_utf_cmd_tlv() - send utf command to fw
1091 * @wmi_handle: wmi handle
1092 * @param: pointer to pdev_utf_params
1093 * @mac_id: mac id to have radio context
1094 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301095 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301096 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301097static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301098send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1099 struct pdev_utf_params *param,
1100 uint8_t mac_id)
1101{
1102 wmi_buf_t buf;
1103 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001104 /* if param->len is 0 no data is sent, return error */
1105 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301106 static uint8_t msgref = 1;
1107 uint8_t segNumber = 0, segInfo, numSegments;
1108 uint16_t chunk_len, total_bytes;
1109 uint8_t *bufpos;
1110 struct seg_hdr_info segHdrInfo;
1111
1112 bufpos = param->utf_payload;
1113 total_bytes = param->len;
1114 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1115 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1116 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1117
1118 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1119 numSegments++;
1120
1121 while (param->len) {
1122 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001123 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301124 else
1125 chunk_len = param->len;
1126
1127 buf = wmi_buf_alloc(wmi_handle,
1128 (chunk_len + sizeof(segHdrInfo) +
1129 WMI_TLV_HDR_SIZE));
1130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301131 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301132 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301133 }
1134
1135 cmd = (uint8_t *) wmi_buf_data(buf);
1136
1137 segHdrInfo.len = total_bytes;
1138 segHdrInfo.msgref = msgref;
1139 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1140 segHdrInfo.segmentInfo = segInfo;
1141 segHdrInfo.pad = 0;
1142
Govind Singhb53420c2016-03-09 14:32:57 +05301143 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301144 " segHdrInfo.segmentInfo = %d",
1145 __func__, segHdrInfo.len, segHdrInfo.msgref,
1146 segHdrInfo.segmentInfo);
1147
Govind Singhb53420c2016-03-09 14:32:57 +05301148 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301149 "chunk len %d", __func__, total_bytes, segNumber,
1150 numSegments, chunk_len);
1151
1152 segNumber++;
1153
1154 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1155 (chunk_len + sizeof(segHdrInfo)));
1156 cmd += WMI_TLV_HDR_SIZE;
1157 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1158 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1159
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301160 wmi_mtrace(WMI_PDEV_UTF_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301161 ret = wmi_unified_cmd_send(wmi_handle, buf,
1162 (chunk_len + sizeof(segHdrInfo) +
1163 WMI_TLV_HDR_SIZE),
1164 WMI_PDEV_UTF_CMDID);
1165
Govind Singh67922e82016-04-01 16:48:57 +05301166 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301167 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301168 wmi_buf_free(buf);
1169 break;
1170 }
1171
1172 param->len -= chunk_len;
1173 bufpos += chunk_len;
1174 }
1175
1176 msgref++;
1177
1178 return ret;
1179}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301180#ifdef CONFIG_MCL
1181static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1182 uint32_t host_param)
1183{
1184 return host_param;
1185}
1186#else
1187static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1188 uint32_t host_param)
1189{
1190 if (host_param < wmi_pdev_param_max)
1191 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301192
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301193 return WMI_UNAVAILABLE_PARAM;
1194}
1195#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301196/**
1197 * send_pdev_param_cmd_tlv() - set pdev parameters
1198 * @wmi_handle: wmi handle
1199 * @param: pointer to pdev parameter
1200 * @mac_id: radio context
1201 *
1202 * Return: 0 on success, errno on failure
1203 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301204static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301205send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1206 struct pdev_params *param,
1207 uint8_t mac_id)
1208{
Govind Singh67922e82016-04-01 16:48:57 +05301209 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301210 wmi_pdev_set_param_cmd_fixed_param *cmd;
1211 wmi_buf_t buf;
1212 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301213 uint32_t pdev_param;
1214
1215 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1216 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301217 WMI_LOGW("%s: Unavailable param %d",
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301218 __func__, param->param_id);
1219 return QDF_STATUS_E_INVAL;
1220 }
Govind Singh5eb51532016-03-09 11:34:12 +05301221
1222 buf = wmi_buf_alloc(wmi_handle, len);
1223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301224 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301225 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301226 }
1227 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1228 WMITLV_SET_HDR(&cmd->tlv_header,
1229 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1230 WMITLV_GET_STRUCT_TLVLEN
1231 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301232 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301233 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301234 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301235 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301236 param->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301237 wmi_mtrace(WMI_PDEV_SET_PARAM_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301238 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1239 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301240 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301241 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301242 wmi_buf_free(buf);
1243 }
1244 return ret;
1245}
1246
1247/**
1248 * send_suspend_cmd_tlv() - WMI suspend function
1249 * @param wmi_handle : handle to WMI.
1250 * @param param : pointer to hold suspend parameter
1251 * @mac_id: radio context
1252 *
1253 * Return 0 on success and -ve on failure.
1254 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301255static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301256 struct suspend_params *param,
1257 uint8_t mac_id)
1258{
1259 wmi_pdev_suspend_cmd_fixed_param *cmd;
1260 wmi_buf_t wmibuf;
1261 uint32_t len = sizeof(*cmd);
1262 int32_t ret;
1263
1264 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001265 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301266 * PCIE reset so as to ensure that Host and target
1267 * states are in sync
1268 */
1269 wmibuf = wmi_buf_alloc(wmi_handle, len);
1270 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301271 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301272
1273 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1274 WMITLV_SET_HDR(&cmd->tlv_header,
1275 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1276 WMITLV_GET_STRUCT_TLVLEN
1277 (wmi_pdev_suspend_cmd_fixed_param));
1278 if (param->disable_target_intr)
1279 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1280 else
1281 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301282
1283 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1284
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301285 wmi_mtrace(WMI_PDEV_SUSPEND_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301286 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1287 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301288 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301289 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301290 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301291 }
1292
1293 return ret;
1294}
1295
1296/**
1297 * send_resume_cmd_tlv() - WMI resume function
1298 * @param wmi_handle : handle to WMI.
1299 * @mac_id: radio context
1300 *
1301 * Return: 0 on success and -ve on failure.
1302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301303static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301304 uint8_t mac_id)
1305{
1306 wmi_buf_t wmibuf;
1307 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301308 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301309
1310 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1311 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301312 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301313 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1314 WMITLV_SET_HDR(&cmd->tlv_header,
1315 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1316 WMITLV_GET_STRUCT_TLVLEN
1317 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301318 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301319 wmi_mtrace(WMI_PDEV_RESUME_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301320 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1321 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301322 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301323 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301324 wmi_buf_free(wmibuf);
1325 }
1326
1327 return ret;
1328}
1329
1330/**
1331 * send_wow_enable_cmd_tlv() - WMI wow enable function
1332 * @param wmi_handle : handle to WMI.
1333 * @param param : pointer to hold wow enable parameter
1334 * @mac_id: radio context
1335 *
1336 * Return: 0 on success and -ve on failure.
1337 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301338static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301339 struct wow_cmd_params *param,
1340 uint8_t mac_id)
1341{
1342 wmi_wow_enable_cmd_fixed_param *cmd;
1343 wmi_buf_t buf;
1344 int32_t len;
1345 int32_t ret;
1346
1347 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1348
1349 buf = wmi_buf_alloc(wmi_handle, len);
1350 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301351 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1352 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301353 }
1354 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1355 WMITLV_SET_HDR(&cmd->tlv_header,
1356 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1357 WMITLV_GET_STRUCT_TLVLEN
1358 (wmi_wow_enable_cmd_fixed_param));
1359 cmd->enable = param->enable;
1360 if (param->can_suspend_link)
1361 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1362 else
1363 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001364 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301365
Govind Singhb53420c2016-03-09 14:32:57 +05301366 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301367 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1368 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1369
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301370 wmi_mtrace(WMI_WOW_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301371 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1372 WMI_WOW_ENABLE_CMDID);
1373 if (ret)
1374 wmi_buf_free(buf);
1375
1376 return ret;
1377}
1378
1379/**
1380 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301381 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301382 * @peer_addr: peer mac address
1383 * @param: pointer to ap_ps parameter structure
1384 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301385 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301386 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301387static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301388 uint8_t *peer_addr,
1389 struct ap_ps_params *param)
1390{
1391 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1392 wmi_buf_t buf;
1393 int32_t err;
1394
1395 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1396 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301397 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301398 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301399 }
1400 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1401 WMITLV_SET_HDR(&cmd->tlv_header,
1402 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1403 WMITLV_GET_STRUCT_TLVLEN
1404 (wmi_ap_ps_peer_cmd_fixed_param));
1405 cmd->vdev_id = param->vdev_id;
1406 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1407 cmd->param = param->param;
1408 cmd->value = param->value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301409 wmi_mtrace(WMI_AP_PS_PEER_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301410 err = wmi_unified_cmd_send(wmi_handle, buf,
1411 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1412 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301413 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301414 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301415 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301416 }
1417
1418 return 0;
1419}
1420
1421/**
1422 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301423 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301424 * @peer_addr: peer mac address
1425 * @param: pointer to sta_ps parameter structure
1426 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301427 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301428 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301429static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301430 struct sta_ps_params *param)
1431{
1432 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1433 wmi_buf_t buf;
1434 int32_t len = sizeof(*cmd);
1435
1436 buf = wmi_buf_alloc(wmi_handle, len);
1437 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301438 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301439 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301440 }
1441
1442 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1443 WMITLV_SET_HDR(&cmd->tlv_header,
1444 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1445 WMITLV_GET_STRUCT_TLVLEN
1446 (wmi_sta_powersave_param_cmd_fixed_param));
1447 cmd->vdev_id = param->vdev_id;
1448 cmd->param = param->param;
1449 cmd->value = param->value;
1450
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301451 wmi_mtrace(WMI_STA_POWERSAVE_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301452 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1453 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301454 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301455 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301456 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301457 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301458 }
1459
1460 return 0;
1461}
1462
1463/**
1464 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301465 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001466 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301467 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301468 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301469 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301470static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301471 struct crash_inject *param)
1472{
1473 int32_t ret = 0;
1474 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1475 uint16_t len = sizeof(*cmd);
1476 wmi_buf_t buf;
1477
1478 buf = wmi_buf_alloc(wmi_handle, len);
1479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301480 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301481 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301482 }
1483
1484 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1485 WMITLV_SET_HDR(&cmd->tlv_header,
1486 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1487 WMITLV_GET_STRUCT_TLVLEN
1488 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1489 cmd->type = param->type;
1490 cmd->delay_time_ms = param->delay_time_ms;
1491
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301492 wmi_mtrace(WMI_FORCE_FW_HANG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301493 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1494 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301495 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301496 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301497 __func__, ret);
1498 wmi_buf_free(buf);
1499 }
1500
1501 return ret;
1502}
1503
Wen Gongca174012018-04-20 16:56:28 +08001504#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301505/**
1506 * send_dbglog_cmd_tlv() - set debug log level
1507 * @param wmi_handle : handle to WMI.
1508 * @param param : pointer to hold dbglog level parameter
1509 *
1510 * Return: 0 on success and -ve on failure.
1511 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301512 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301513send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1514 struct dbglog_params *dbglog_param)
1515{
1516 wmi_buf_t buf;
1517 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001518 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301519 int32_t i;
1520 int32_t len;
1521 int8_t *buf_ptr;
1522 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1523
Alok Kumar240afea2017-08-30 14:45:34 +05301524 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301525
1526 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1527 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1528 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1529 buf = wmi_buf_alloc(wmi_handle, len);
1530 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001531 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301532
1533 configmsg =
1534 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1535 buf_ptr = (int8_t *) configmsg;
1536 WMITLV_SET_HDR(&configmsg->tlv_header,
1537 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1538 WMITLV_GET_STRUCT_TLVLEN
1539 (wmi_debug_log_config_cmd_fixed_param));
1540 configmsg->dbg_log_param = dbglog_param->param;
1541 configmsg->value = dbglog_param->val;
1542 /* Filling in the data part of second tlv -- should
1543 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301544 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301545 sizeof
1546 (wmi_debug_log_config_cmd_fixed_param)
1547 + WMI_TLV_HDR_SIZE);
1548 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1549 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301550 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301551 if (dbglog_param->module_id_bitmap) {
1552 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1553 module_id_bitmap_array[i] =
1554 dbglog_param->module_id_bitmap[i];
1555 }
1556 }
1557
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301558 wmi_mtrace(WMI_DBGLOG_CFG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301559 status = wmi_unified_cmd_send(wmi_handle, buf,
1560 len, WMI_DBGLOG_CFG_CMDID);
1561
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001562 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301563 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301564
1565 return status;
1566}
Wen Gongca174012018-04-20 16:56:28 +08001567#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301568
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301569#ifdef CONFIG_MCL
1570static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1571 uint32_t host_param)
1572{
1573 return host_param;
1574}
1575#else
1576static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1577 uint32_t host_param)
1578{
1579 if (host_param < wmi_vdev_param_max)
1580 return wmi_handle->vdev_param[host_param];
1581
1582 return WMI_UNAVAILABLE_PARAM;
1583}
1584#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301585/**
1586 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1587 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301588 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301589 * @param param : pointer to hold vdev set parameter
1590 *
1591 * Return: 0 on success and -ve on failure.
1592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301593static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301594 struct vdev_set_params *param)
1595{
Govind Singh67922e82016-04-01 16:48:57 +05301596 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301597 wmi_vdev_set_param_cmd_fixed_param *cmd;
1598 wmi_buf_t buf;
1599 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301600 uint32_t vdev_param;
1601
1602 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1603 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1604 WMI_LOGW("%s:Vdev param %d not available", __func__,
1605 param->param_id);
1606 return QDF_STATUS_E_INVAL;
1607
1608 }
Govind Singh5eb51532016-03-09 11:34:12 +05301609
1610 buf = wmi_buf_alloc(wmi_handle, len);
1611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301612 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301613 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301614 }
1615 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1616 WMITLV_SET_HDR(&cmd->tlv_header,
1617 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1618 WMITLV_GET_STRUCT_TLVLEN
1619 (wmi_vdev_set_param_cmd_fixed_param));
1620 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301621 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301622 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301623 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001624 cmd->vdev_id, cmd->param_id, cmd->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301625 wmi_mtrace(WMI_VDEV_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1627 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301628 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301629 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301630 wmi_buf_free(buf);
1631 }
1632
1633 return ret;
1634}
1635
1636/**
1637 * send_stats_request_cmd_tlv() - WMI request stats function
1638 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301639 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301640 * @param param : pointer to hold stats request parameter
1641 *
1642 * Return: 0 on success and -ve on failure.
1643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301644static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301645 uint8_t macaddr[IEEE80211_ADDR_LEN],
1646 struct stats_request_params *param)
1647{
Govind Singhd3156eb2016-02-26 17:50:39 +05301648 int32_t ret;
1649 wmi_request_stats_cmd_fixed_param *cmd;
1650 wmi_buf_t buf;
1651 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1652
1653 buf = wmi_buf_alloc(wmi_handle, len);
1654 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301655 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1656 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301657 }
1658
1659 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1660 WMITLV_SET_HDR(&cmd->tlv_header,
1661 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1662 WMITLV_GET_STRUCT_TLVLEN
1663 (wmi_request_stats_cmd_fixed_param));
1664 cmd->stats_id = param->stats_id;
1665 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301666 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1667 param->pdev_id);
1668 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001669
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301670 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1671 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001672
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301673 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001674 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1675 WMI_REQUEST_STATS_CMDID);
1676
Govind Singhd3156eb2016-02-26 17:50:39 +05301677 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301678 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301679 wmi_buf_free(buf);
1680 }
1681
1682 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301683}
1684
Govind Singh87542482016-06-08 19:40:11 +05301685#ifdef CONFIG_WIN
1686/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001687 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301688 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001689 * @param PKTLOG_EVENT : packet log event
1690 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301691 *
1692 * Return: 0 on success and -ve on failure.
1693 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301694static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001695 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301696{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001697 int32_t ret;
1698 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1699 wmi_buf_t buf;
1700 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1701
1702 buf = wmi_buf_alloc(wmi_handle, len);
1703 if (!buf) {
1704 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1705 return -QDF_STATUS_E_NOMEM;
1706 }
1707
1708 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1709 WMITLV_SET_HDR(&cmd->tlv_header,
1710 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1711 WMITLV_GET_STRUCT_TLVLEN
1712 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1713 cmd->evlist = PKTLOG_EVENT;
1714 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301715 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001716 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1717 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1718 if (ret) {
1719 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1720 wmi_buf_free(buf);
1721 }
1722
1723 return ret;
1724}
1725
1726/**
1727 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1728 * @param wmi_handle : handle to WMI.
1729 * @mac_id: mac id to have radio context
1730 *
1731 * Return: 0 on success and -ve on failure.
1732 */
1733static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001734 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001735{
1736 int32_t ret;
1737 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1738 wmi_buf_t buf;
1739 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1740
1741 buf = wmi_buf_alloc(wmi_handle, len);
1742 if (!buf) {
1743 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1744 return -QDF_STATUS_E_NOMEM;
1745 }
1746
1747 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1748 WMITLV_SET_HDR(&cmd->tlv_header,
1749 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1750 WMITLV_GET_STRUCT_TLVLEN
1751 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1752 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301753 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001754 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1755 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1756 if (ret) {
1757 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1758 wmi_buf_free(buf);
1759 }
1760
1761 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301762}
1763#else
Govind Singh5eb51532016-03-09 11:34:12 +05301764/**
Keyur Parekhde522342017-08-18 14:01:05 -07001765 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1766 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301767 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301768 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301769 * @param param : pointer to hold stats request parameter
1770 *
1771 * Return: 0 on success and -ve on failure.
1772 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301773static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301774 uint8_t macaddr[IEEE80211_ADDR_LEN],
1775 struct packet_enable_params *param)
1776{
1777 return 0;
1778}
Keyur Parekhde522342017-08-18 14:01:05 -07001779/**
1780 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1781 * packet-log
1782 * @param wmi_handle : handle to WMI.
1783 * @mac_id: mac id to have radio context
1784 *
1785 * Return: 0 on success and -ve on failure.
1786 */
1787static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1788 uint8_t mac_id)
1789{
1790 return 0;
1791}
Govind Singh87542482016-06-08 19:40:11 +05301792#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301793
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301794#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1795/**
1796 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1797 * sync time between bwtween host and firmware
1798 * @param wmi_handle : handle to WMI.
1799 *
1800 * Return: None
1801 */
1802static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1803{
1804 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001805 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301806 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1807 int32_t len;
1808 qdf_time_t time_ms;
1809
1810 len = sizeof(*time_stamp);
1811 buf = wmi_buf_alloc(wmi_handle, len);
1812
1813 if (!buf) {
1814 WMI_LOGP(FL("wmi_buf_alloc failed"));
1815 return;
1816 }
1817 time_stamp =
1818 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1819 (wmi_buf_data(buf));
1820 WMITLV_SET_HDR(&time_stamp->tlv_header,
1821 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1822 WMITLV_GET_STRUCT_TLVLEN(
1823 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1824
1825 time_ms = qdf_get_time_of_the_day_ms();
1826 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1827 time_stamp->time_stamp_low = time_ms &
1828 WMI_FW_TIME_STAMP_LOW_MASK;
1829 /*
1830 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1831 * wont exceed 27 bit
1832 */
1833 time_stamp->time_stamp_high = 0;
1834 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1835 time_stamp->mode, time_stamp->time_stamp_low,
1836 time_stamp->time_stamp_high);
1837
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301838 wmi_mtrace(WMI_DBGLOG_TIME_STAMP_SYNC_CMDID, NO_SESSION, 0);
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301839 status = wmi_unified_cmd_send(wmi_handle, buf,
1840 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1841 if (status) {
1842 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1843 wmi_buf_free(buf);
1844 }
1845
1846}
1847
Govind Singh87542482016-06-08 19:40:11 +05301848/**
1849 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1850 * @param wmi_handle : handle to WMI.
1851 * @param param : pointer to hold beacon send cmd parameter
1852 *
1853 * Return: 0 on success and -ve on failure.
1854 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301855static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301856 struct beacon_tmpl_params *param)
1857{
1858 int32_t ret;
1859 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1860 wmi_bcn_prb_info *bcn_prb_info;
1861 wmi_buf_t wmi_buf;
1862 uint8_t *buf_ptr;
1863 uint32_t wmi_buf_len;
1864
1865 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1866 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1867 param->tmpl_len_aligned;
1868 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1869 if (!wmi_buf) {
1870 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1871 return QDF_STATUS_E_NOMEM;
1872 }
1873 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1874 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1875 WMITLV_SET_HDR(&cmd->tlv_header,
1876 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1877 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1878 cmd->vdev_id = param->vdev_id;
1879 cmd->tim_ie_offset = param->tim_ie_offset;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07001880 cmd->mbssid_ie_offset = param->mbssid_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301881 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1882 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Subrat Mishraa667b1c2018-08-02 15:02:04 +05301883 cmd->esp_ie_offset = param->esp_ie_offset;
Govind Singh87542482016-06-08 19:40:11 +05301884 cmd->buf_len = param->tmpl_len;
1885 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1886
1887 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1888 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1889 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1890 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1891 bcn_prb_info->caps = 0;
1892 bcn_prb_info->erp = 0;
1893 buf_ptr += sizeof(wmi_bcn_prb_info);
1894
1895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1896 buf_ptr += WMI_TLV_HDR_SIZE;
1897 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1898
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301899 wmi_mtrace(WMI_BCN_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh87542482016-06-08 19:40:11 +05301900 ret = wmi_unified_cmd_send(wmi_handle,
1901 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1902 if (ret) {
1903 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1904 wmi_buf_free(wmi_buf);
1905 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301906
Govind Singh87542482016-06-08 19:40:11 +05301907 return 0;
1908}
Govind Singh5eb51532016-03-09 11:34:12 +05301909
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301910#ifdef CONFIG_MCL
1911static inline void copy_peer_flags_tlv(
1912 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1913 struct peer_assoc_params *param)
1914{
1915 cmd->peer_flags = param->peer_flags;
1916}
1917#else
1918static inline void copy_peer_flags_tlv(
1919 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1920 struct peer_assoc_params *param)
1921{
1922 /*
1923 * The target only needs a subset of the flags maintained in the host.
1924 * Just populate those flags and send it down
1925 */
1926 cmd->peer_flags = 0;
1927
1928 /*
1929 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1930 */
1931 if (param->is_wme_set) {
1932
1933 if (param->qos_flag)
1934 cmd->peer_flags |= WMI_PEER_QOS;
1935 if (param->apsd_flag)
1936 cmd->peer_flags |= WMI_PEER_APSD;
1937 if (param->ht_flag)
1938 cmd->peer_flags |= WMI_PEER_HT;
1939 if (param->bw_40)
1940 cmd->peer_flags |= WMI_PEER_40MHZ;
1941 if (param->bw_80)
1942 cmd->peer_flags |= WMI_PEER_80MHZ;
1943 if (param->bw_160)
1944 cmd->peer_flags |= WMI_PEER_160MHZ;
1945
1946 /* Typically if STBC is enabled for VHT it should be enabled
1947 * for HT as well
1948 **/
1949 if (param->stbc_flag)
1950 cmd->peer_flags |= WMI_PEER_STBC;
1951
1952 /* Typically if LDPC is enabled for VHT it should be enabled
1953 * for HT as well
1954 **/
1955 if (param->ldpc_flag)
1956 cmd->peer_flags |= WMI_PEER_LDPC;
1957
1958 if (param->static_mimops_flag)
1959 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1960 if (param->dynamic_mimops_flag)
1961 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1962 if (param->spatial_mux_flag)
1963 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1964 if (param->vht_flag)
1965 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001966 if (param->he_flag)
1967 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301968 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001969
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301970 if (param->is_pmf_enabled)
1971 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301972 /*
1973 * Suppress authorization for all AUTH modes that need 4-way handshake
1974 * (during re-association).
1975 * Authorization will be done for these modes on key installation.
1976 */
1977 if (param->auth_flag)
1978 cmd->peer_flags |= WMI_PEER_AUTH;
1979 if (param->need_ptk_4_way)
1980 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1981 else
1982 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1983 if (param->need_gtk_2_way)
1984 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1985 /* safe mode bypass the 4-way handshake */
1986 if (param->safe_mode_enabled)
1987 cmd->peer_flags &=
1988 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1989 /* Disable AMSDU for station transmit, if user configures it */
1990 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1991 * it
1992 * if (param->amsdu_disable) Add after FW support
1993 **/
1994
1995 /* Target asserts if node is marked HT and all MCS is set to 0.
1996 * Mark the node as non-HT if all the mcs rates are disabled through
1997 * iwpriv
1998 **/
1999 if (param->peer_ht_rates.num_rates == 0)
2000 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302001
2002 if (param->twt_requester)
2003 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2004
2005 if (param->twt_responder)
2006 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302007}
2008#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302009
2010#ifdef CONFIG_MCL
2011static inline void copy_peer_mac_addr_tlv(
2012 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2013 struct peer_assoc_params *param)
2014{
2015 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2016 sizeof(param->peer_macaddr));
2017}
2018#else
2019static inline void copy_peer_mac_addr_tlv(
2020 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2021 struct peer_assoc_params *param)
2022{
2023 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2024}
2025#endif
2026
Govind Singh5eb51532016-03-09 11:34:12 +05302027/**
2028 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2029 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302030 * @param param : pointer to peer assoc parameter
2031 *
2032 * Return: 0 on success and -ve on failure.
2033 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302034static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302035 struct peer_assoc_params *param)
2036{
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2038 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002039 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302040 wmi_buf_t buf;
2041 int32_t len;
2042 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302043 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302044 uint32_t peer_legacy_rates_align;
2045 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002046 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302047
2048
2049 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2050 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302051
2052 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002053 (peer_legacy_rates_align * sizeof(uint8_t)) +
2054 WMI_TLV_HDR_SIZE +
2055 (peer_ht_rates_align * sizeof(uint8_t)) +
2056 sizeof(wmi_vht_rate_set) +
2057 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2058 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302059
2060 buf = wmi_buf_alloc(wmi_handle, len);
2061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302062 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302063 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302064 }
2065
2066 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2067 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2068 WMITLV_SET_HDR(&cmd->tlv_header,
2069 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2070 WMITLV_GET_STRUCT_TLVLEN
2071 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302072
Govind Singhd3156eb2016-02-26 17:50:39 +05302073 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302074
Govind Singhd3156eb2016-02-26 17:50:39 +05302075 cmd->peer_new_assoc = param->peer_new_assoc;
2076 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302077
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302078 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302079 copy_peer_mac_addr_tlv(cmd, param);
2080
Govind Singhd3156eb2016-02-26 17:50:39 +05302081 cmd->peer_rate_caps = param->peer_rate_caps;
2082 cmd->peer_caps = param->peer_caps;
2083 cmd->peer_listen_intval = param->peer_listen_intval;
2084 cmd->peer_ht_caps = param->peer_ht_caps;
2085 cmd->peer_max_mpdu = param->peer_max_mpdu;
2086 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302087 cmd->peer_vht_caps = param->peer_vht_caps;
2088 cmd->peer_phymode = param->peer_phymode;
2089
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002090 /* Update 11ax capabilities */
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002091 cmd->peer_he_cap_info =
2092 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD1];
2093 cmd->peer_he_cap_info_ext =
2094 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD2];
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002095 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002096 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2097 sizeof(param->peer_he_cap_phyinfo));
2098 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2099 sizeof(param->peer_ppet));
2100
Govind Singhd3156eb2016-02-26 17:50:39 +05302101 /* Update peer legacy rate information */
2102 buf_ptr += sizeof(*cmd);
2103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302104 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302105 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302106 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302107 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302108 param->peer_legacy_rates.num_rates);
2109
2110 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002111 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302112 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302113 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302114 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302115 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302116 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302117 param->peer_ht_rates.num_rates);
2118
2119 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002120 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302121 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2122 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2123
2124 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302125
2126 /* Update bandwidth-NSS mapping */
2127 cmd->peer_bw_rxnss_override = 0;
2128 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2129
Govind Singhd3156eb2016-02-26 17:50:39 +05302130 mcs = (wmi_vht_rate_set *) buf_ptr;
2131 if (param->vht_capable) {
2132 mcs->rx_max_rate = param->rx_max_rate;
2133 mcs->rx_mcs_set = param->rx_mcs_set;
2134 mcs->tx_max_rate = param->tx_max_rate;
2135 mcs->tx_mcs_set = param->tx_mcs_set;
2136 }
2137
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002138 /* HE Rates */
2139 cmd->peer_he_mcs = param->peer_he_mcs_count;
2140 buf_ptr += sizeof(wmi_vht_rate_set);
2141 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2142 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2143 buf_ptr += WMI_TLV_HDR_SIZE;
2144
2145 /* Loop through the HE rate set */
2146 for (i = 0; i < param->peer_he_mcs_count; i++) {
2147 he_mcs = (wmi_he_rate_set *) buf_ptr;
2148 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2149 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2150
2151 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2152 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2153 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2154 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2155 buf_ptr += sizeof(wmi_he_rate_set);
2156 }
2157
2158
Govind Singhb53420c2016-03-09 14:32:57 +05302159 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302160 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2161 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002162 "cmd->peer_vht_caps %x "
2163 "HE cap_info %x ops %x "
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002164 "HE cap_info_ext %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302165 "HE phy %x %x %x "
2166 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302167 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2168 cmd->peer_rate_caps, cmd->peer_caps,
2169 cmd->peer_listen_intval, cmd->peer_ht_caps,
2170 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2171 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002172 cmd->peer_vht_caps, cmd->peer_he_cap_info,
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002173 cmd->peer_he_ops, cmd->peer_he_cap_info_ext,
2174 cmd->peer_he_cap_phy[0], cmd->peer_he_cap_phy[1],
2175 cmd->peer_he_cap_phy[2],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302176 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302177
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302178 wmi_mtrace(WMI_PEER_ASSOC_CMDID, cmd->vdev_id, 0);
Govind Singhd3156eb2016-02-26 17:50:39 +05302179 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2180 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302181 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302182 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302183 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302184 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302185 }
2186
2187 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302188}
2189
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302190/* copy_scan_notify_events() - Helper routine to copy scan notify events
2191 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302192static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302193 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302194 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302195{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302196
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302197 /* Scan events subscription */
2198 if (param->scan_ev_started)
2199 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2200 if (param->scan_ev_completed)
2201 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2202 if (param->scan_ev_bss_chan)
2203 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2204 if (param->scan_ev_foreign_chan)
2205 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2206 if (param->scan_ev_dequeued)
2207 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2208 if (param->scan_ev_preempted)
2209 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2210 if (param->scan_ev_start_failed)
2211 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2212 if (param->scan_ev_restarted)
2213 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2214 if (param->scan_ev_foreign_chn_exit)
2215 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2216 if (param->scan_ev_suspended)
2217 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2218 if (param->scan_ev_resumed)
2219 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302220
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302221 /** Set scan control flags */
2222 cmd->scan_ctrl_flags = 0;
2223 if (param->scan_f_passive)
2224 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2225 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302226 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302227 if (param->scan_f_promisc_mode)
2228 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2229 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302230 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302231 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302232 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302233 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302234 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302235 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302236 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302237 if (param->scan_f_ofdm_rates)
2238 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2239 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302240 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302241 if (param->scan_f_filter_prb_req)
2242 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2243 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302244 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302245 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302246 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302247 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302248 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302249 if (param->scan_f_force_active_dfs_chn)
2250 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2251 if (param->scan_f_add_tpc_ie_in_probe)
2252 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2253 if (param->scan_f_add_ds_ie_in_probe)
2254 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2255 if (param->scan_f_add_spoofed_mac_in_probe)
2256 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2257 if (param->scan_f_add_rand_seq_in_probe)
2258 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2259 if (param->scan_f_en_ie_whitelist_in_probe)
2260 cmd->scan_ctrl_flags |=
2261 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302262
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302263 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2264 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2265 param->adaptive_dwell_time_mode);
2266}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302267
2268/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302269static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302270 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302271{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302272 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302273}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302274
Govind Singh5eb51532016-03-09 11:34:12 +05302275/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302276 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2277 * @mac: random mac addr
2278 * @mask: random mac mask
2279 * @mac_addr: wmi random mac
2280 * @mac_mask: wmi random mac mask
2281 *
2282 * Return None.
2283 */
2284static inline
2285void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2286 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2287{
2288 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2289 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2290}
2291
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302292/*
2293 * wmi_fill_vendor_oui() - fill vendor OUIs
2294 * @buf_ptr: pointer to wmi tlv buffer
2295 * @num_vendor_oui: number of vendor OUIs to be filled
2296 * @param_voui: pointer to OUI buffer
2297 *
2298 * This function populates the wmi tlv buffer when vendor specific OUIs are
2299 * present.
2300 *
2301 * Return: None
2302 */
2303static inline
2304void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2305 uint32_t *pvoui)
2306{
2307 wmi_vendor_oui *voui = NULL;
2308 uint32_t i;
2309
2310 voui = (wmi_vendor_oui *)buf_ptr;
2311
2312 for (i = 0; i < num_vendor_oui; i++) {
2313 WMITLV_SET_HDR(&voui[i].tlv_header,
2314 WMITLV_TAG_STRUC_wmi_vendor_oui,
2315 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2316 voui[i].oui_type_subtype = pvoui[i];
2317 }
2318}
2319
2320/*
2321 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2322 * @ie_bitmap: output pointer to ie bit map in cmd
2323 * @num_vendor_oui: output pointer to num vendor OUIs
2324 * @ie_whitelist: input parameter
2325 *
2326 * This function populates the IE whitelist attrs of scan, pno and
2327 * scan oui commands for ie_whitelist parameter.
2328 *
2329 * Return: None
2330 */
2331static inline
2332void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2333 uint32_t *num_vendor_oui,
2334 struct probe_req_whitelist_attr *ie_whitelist)
2335{
2336 uint32_t i = 0;
2337
2338 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2339 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2340
2341 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2342}
2343
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302344/**
Govind Singh5eb51532016-03-09 11:34:12 +05302345 * send_scan_start_cmd_tlv() - WMI scan start function
2346 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302347 * @param param : pointer to hold scan start cmd parameter
2348 *
2349 * Return: 0 on success and -ve on failure.
2350 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302351static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302352 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302353{
Govind Singhd3156eb2016-02-26 17:50:39 +05302354 int32_t ret = 0;
2355 int32_t i;
2356 wmi_buf_t wmi_buf;
2357 wmi_start_scan_cmd_fixed_param *cmd;
2358 uint8_t *buf_ptr;
2359 uint32_t *tmp_ptr;
2360 wmi_ssid *ssid = NULL;
2361 wmi_mac_addr *bssid;
2362 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302363 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302364 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302365 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302366
2367 /* Length TLV placeholder for array of uint32_t */
2368 len += WMI_TLV_HDR_SIZE;
2369 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302370 if (params->chan_list.num_chan)
2371 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302372
2373 /* Length TLV placeholder for array of wmi_ssid structures */
2374 len += WMI_TLV_HDR_SIZE;
2375 if (params->num_ssids)
2376 len += params->num_ssids * sizeof(wmi_ssid);
2377
2378 /* Length TLV placeholder for array of wmi_mac_addr structures */
2379 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302380 if (params->num_bssid)
2381 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382
2383 /* Length TLV placeholder for array of bytes */
2384 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302385 if (params->extraie.len)
2386 extraie_len_with_pad =
2387 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002388 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302389
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302390 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2391 if (ie_whitelist->num_vendor_oui)
2392 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2393
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302394 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2395 if (params->scan_f_wide_band)
2396 phymode_roundup =
2397 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2398 sizeof(uint32_t));
2399 len += phymode_roundup;
2400
Govind Singhd3156eb2016-02-26 17:50:39 +05302401 /* Allocate the memory */
2402 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2403 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302404 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302405 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302406 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 }
2408 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2409 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2410 WMITLV_SET_HDR(&cmd->tlv_header,
2411 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2412 WMITLV_GET_STRUCT_TLVLEN
2413 (wmi_start_scan_cmd_fixed_param));
2414
2415 cmd->scan_id = params->scan_id;
2416 cmd->scan_req_id = params->scan_req_id;
2417 cmd->vdev_id = params->vdev_id;
2418 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302419
2420 copy_scan_event_cntrl_flags(cmd, params);
2421
Govind Singhd3156eb2016-02-26 17:50:39 +05302422 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002423 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302424 cmd->dwell_time_passive = params->dwell_time_passive;
2425 cmd->min_rest_time = params->min_rest_time;
2426 cmd->max_rest_time = params->max_rest_time;
2427 cmd->repeat_probe_time = params->repeat_probe_time;
2428 cmd->probe_spacing_time = params->probe_spacing_time;
2429 cmd->idle_time = params->idle_time;
2430 cmd->max_scan_time = params->max_scan_time;
2431 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302432 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302433 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302434 cmd->num_bssid = params->num_bssid;
2435 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302436 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302437 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302438 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2439
2440 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2441
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302442 if (params->scan_random.randomize)
2443 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2444 params->scan_random.mac_mask,
2445 &cmd->mac_addr,
2446 &cmd->mac_mask);
2447
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302448 if (ie_whitelist->white_list)
2449 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2450 &cmd->num_vendor_oui,
2451 ie_whitelist);
2452
Govind Singhd3156eb2016-02-26 17:50:39 +05302453 buf_ptr += sizeof(*cmd);
2454 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302455 for (i = 0; i < params->chan_list.num_chan; ++i)
2456 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302457
2458 WMITLV_SET_HDR(buf_ptr,
2459 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302460 (params->chan_list.num_chan * sizeof(uint32_t)));
2461 buf_ptr += WMI_TLV_HDR_SIZE +
2462 (params->chan_list.num_chan * sizeof(uint32_t));
2463
Govind Singh4eacd2b2016-03-07 14:24:22 +05302464 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302465 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302466 goto error;
2467 }
2468
2469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2470 (params->num_ssids * sizeof(wmi_ssid)));
2471
2472 if (params->num_ssids) {
2473 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2474 for (i = 0; i < params->num_ssids; ++i) {
2475 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302476 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302477 params->ssid[i].length);
2478 ssid++;
2479 }
2480 }
2481 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2482
2483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2484 (params->num_bssid * sizeof(wmi_mac_addr)));
2485 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302486
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302487 if (params->num_bssid) {
2488 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302489 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2490 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302491 bssid++;
2492 }
2493 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302494
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302495 buf_ptr += WMI_TLV_HDR_SIZE +
2496 (params->num_bssid * sizeof(wmi_mac_addr));
2497
2498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2499 if (params->extraie.len)
2500 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2501 params);
2502
2503 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302504
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302505 /* probe req ie whitelisting */
2506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2507 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2508
2509 buf_ptr += WMI_TLV_HDR_SIZE;
2510
2511 if (cmd->num_vendor_oui) {
2512 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2513 ie_whitelist->voui);
2514 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2515 }
2516
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302517 /* Add phy mode TLV if it's a wide band scan */
2518 if (params->scan_f_wide_band) {
2519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2520 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2521 for (i = 0; i < params->chan_list.num_chan; ++i)
2522 buf_ptr[i] =
2523 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2524 buf_ptr += phymode_roundup;
2525 } else {
2526 /* Add ZERO legth phy mode TLV */
2527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2528 }
2529
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302530 wmi_mtrace(WMI_START_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302531 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002532 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302533 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302534 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302535 wmi_buf_free(wmi_buf);
2536 }
2537 return ret;
2538error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302539 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302540 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302541}
2542
2543/**
2544 * send_scan_stop_cmd_tlv() - WMI scan start function
2545 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302546 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302547 *
2548 * Return: 0 on success and -ve on failure.
2549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302550static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302551 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302552{
Govind Singhd3156eb2016-02-26 17:50:39 +05302553 wmi_stop_scan_cmd_fixed_param *cmd;
2554 int ret;
2555 int len = sizeof(*cmd);
2556 wmi_buf_t wmi_buf;
2557
2558 /* Allocate the memory */
2559 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2560 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302561 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302562 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302563 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302564 goto error;
2565 }
2566
2567 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2568 WMITLV_SET_HDR(&cmd->tlv_header,
2569 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2570 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2571 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302572 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302573 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302574 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2575 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302576 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302577 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2578 /* Cancelling all scans */
2579 cmd->req_type = WMI_SCAN_STOP_ALL;
2580 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2581 /* Cancelling VAP scans */
2582 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2583 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2584 /* Cancelling specific scan */
2585 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302586 } else {
2587 WMI_LOGE("%s: Invalid Command : ", __func__);
2588 wmi_buf_free(wmi_buf);
2589 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302590 }
2591
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302592 wmi_mtrace(WMI_STOP_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302593 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002594 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302595 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302596 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302597 wmi_buf_free(wmi_buf);
2598 }
2599
2600error:
2601 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302602}
2603
Govind Singh87542482016-06-08 19:40:11 +05302604#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302605/**
2606 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2607 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302608 * @param param : pointer to hold scan channel list parameter
2609 *
2610 * Return: 0 on success and -ve on failure.
2611 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302612static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302613 struct scan_chan_list_params *chan_list)
2614{
2615 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302616 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302617 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302618 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302619 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302620 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302621 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2622
2623 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2624 buf = wmi_buf_alloc(wmi_handle, len);
2625 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302626 WMI_LOGE("Failed to allocate memory");
2627 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302628 goto end;
2629 }
2630
2631 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2632 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2633 WMITLV_SET_HDR(&cmd->tlv_header,
2634 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2635 WMITLV_GET_STRUCT_TLVLEN
2636 (wmi_scan_chan_list_cmd_fixed_param));
2637
Govind Singhb53420c2016-03-09 14:32:57 +05302638 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302639
2640 cmd->num_scan_chans = chan_list->num_scan_chans;
2641 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2642 WMITLV_TAG_ARRAY_STRUC,
2643 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302644 chan_info = (wmi_channel_param *)
2645 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302646 tchan_info = chan_list->chan_info;
2647
2648 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2649 WMITLV_SET_HDR(&chan_info->tlv_header,
2650 WMITLV_TAG_STRUC_wmi_channel,
2651 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2652 chan_info->mhz = tchan_info->mhz;
2653 chan_info->band_center_freq1 =
2654 tchan_info->band_center_freq1;
2655 chan_info->band_center_freq2 =
2656 tchan_info->band_center_freq2;
2657 chan_info->info = tchan_info->info;
2658 chan_info->reg_info_1 = tchan_info->reg_info_1;
2659 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302660 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302661
2662 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2663 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2664 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2665 tchan_info++;
2666 chan_info++;
2667 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302668 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2669 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302670
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302671 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, NO_SESSION, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05302672 qdf_status = wmi_unified_cmd_send(wmi_handle,
2673 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302674
Govind Singh67922e82016-04-01 16:48:57 +05302675 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302676 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302677 wmi_buf_free(buf);
2678 }
Govind Singh67922e82016-04-01 16:48:57 +05302679
Govind Singhd3156eb2016-02-26 17:50:39 +05302680end:
Govind Singhb53420c2016-03-09 14:32:57 +05302681 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302682}
Govind Singh87542482016-06-08 19:40:11 +05302683#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302684static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302685 struct scan_chan_list_params *chan_list)
2686{
2687 wmi_buf_t buf;
2688 QDF_STATUS qdf_status;
2689 wmi_scan_chan_list_cmd_fixed_param *cmd;
2690 int i;
2691 uint8_t *buf_ptr;
2692 wmi_channel *chan_info;
2693 struct channel_param *tchan_info;
2694 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302695
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302696 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302697 buf = wmi_buf_alloc(wmi_handle, len);
2698 if (!buf) {
2699 WMI_LOGE("Failed to allocate memory");
2700 qdf_status = QDF_STATUS_E_NOMEM;
2701 goto end;
2702 }
2703
2704 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2705 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2706 WMITLV_SET_HDR(&cmd->tlv_header,
2707 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2708 WMITLV_GET_STRUCT_TLVLEN
2709 (wmi_scan_chan_list_cmd_fixed_param));
2710
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302711 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302712
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302713 if (chan_list->append)
2714 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2715
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302716 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2717 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302718 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302719 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2720 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302721 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302722 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2723 tchan_info = &(chan_list->ch_param[0]);
2724
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302725 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302726 WMITLV_SET_HDR(&chan_info->tlv_header,
2727 WMITLV_TAG_STRUC_wmi_channel,
2728 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2729 chan_info->mhz = tchan_info->mhz;
2730 chan_info->band_center_freq1 =
2731 tchan_info->cfreq1;
2732 chan_info->band_center_freq2 =
2733 tchan_info->cfreq2;
2734
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302735 if (tchan_info->is_chan_passive)
2736 WMI_SET_CHANNEL_FLAG(chan_info,
2737 WMI_CHAN_FLAG_PASSIVE);
2738
2739 if (tchan_info->allow_vht)
2740 WMI_SET_CHANNEL_FLAG(chan_info,
2741 WMI_CHAN_FLAG_ALLOW_VHT);
2742 else if (tchan_info->allow_ht)
2743 WMI_SET_CHANNEL_FLAG(chan_info,
2744 WMI_CHAN_FLAG_ALLOW_HT);
2745 WMI_SET_CHANNEL_MODE(chan_info,
2746 tchan_info->phy_mode);
2747
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302748 if (tchan_info->half_rate)
2749 WMI_SET_CHANNEL_FLAG(chan_info,
2750 WMI_CHAN_FLAG_HALF_RATE);
2751
2752 if (tchan_info->quarter_rate)
2753 WMI_SET_CHANNEL_FLAG(chan_info,
2754 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302755
2756 /* also fill in power information */
2757 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2758 tchan_info->minpower);
2759 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2760 tchan_info->maxpower);
2761 WMI_SET_CHANNEL_REG_POWER(chan_info,
2762 tchan_info->maxregpower);
2763 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2764 tchan_info->antennamax);
2765 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2766 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002767 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2768 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302769
Govind Singh87542482016-06-08 19:40:11 +05302770 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2771
Govind Singh87542482016-06-08 19:40:11 +05302772 tchan_info++;
2773 chan_info++;
2774 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302775 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2776 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302777
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302778 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, cmd->pdev_id, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05302779 qdf_status = wmi_unified_cmd_send(
2780 wmi_handle,
2781 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302782
2783 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2784 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2785 wmi_buf_free(buf);
2786 }
2787
2788end:
2789 return qdf_status;
2790}
2791#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302792
2793/**
2794 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2795 *
2796 * @bufp: Pointer to buffer
2797 * @param: Pointer to tx param
2798 *
2799 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2800 */
2801static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
Sathish Kumarefb25bf2018-10-02 11:03:59 +05302802 struct tx_send_params param)
Sathish Kumar5b636932017-06-28 14:40:32 +05302803{
2804 wmi_tx_send_params *tx_param;
2805 QDF_STATUS status = QDF_STATUS_SUCCESS;
2806
2807 if (!bufp) {
2808 status = QDF_STATUS_E_FAILURE;
2809 return status;
2810 }
2811 tx_param = (wmi_tx_send_params *)bufp;
2812 WMITLV_SET_HDR(&tx_param->tlv_header,
2813 WMITLV_TAG_STRUC_wmi_tx_send_params,
2814 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2815 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2816 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2817 param.mcs_mask);
2818 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2819 param.nss_mask);
2820 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2821 param.retry_limit);
2822 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2823 param.chain_mask);
2824 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2825 param.bw_mask);
2826 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2827 param.preamble_type);
2828 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2829 param.frame_type);
2830
2831 return status;
2832}
2833
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05302834#ifdef CONFIG_HL_SUPPORT
2835/**
2836 * send_mgmt_cmd_tlv() - WMI scan start function
2837 * @wmi_handle : handle to WMI.
2838 * @param : pointer to hold mgmt cmd parameter
2839 *
2840 * Return: 0 on success and -ve on failure.
2841 */
2842static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
2843 struct wmi_mgmt_params *param)
2844{
2845 wmi_buf_t buf;
2846 uint8_t *bufp;
2847 int32_t cmd_len;
2848 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2849 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2850 mgmt_tx_dl_frm_len;
2851
2852 if (param->frm_len > mgmt_tx_dl_frm_len) {
2853 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
2854 __func__, param->frm_len, mgmt_tx_dl_frm_len);
2855 return QDF_STATUS_E_INVAL;
2856 }
2857
2858 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2859 WMI_TLV_HDR_SIZE +
2860 roundup(bufp_len, sizeof(uint32_t));
2861
2862 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
2863 if (!buf) {
2864 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2865 return QDF_STATUS_E_NOMEM;
2866 }
2867
2868 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2869 bufp = (uint8_t *) cmd;
2870 WMITLV_SET_HDR(&cmd->tlv_header,
2871 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2872 WMITLV_GET_STRUCT_TLVLEN
2873 (wmi_mgmt_tx_send_cmd_fixed_param));
2874
2875 cmd->vdev_id = param->vdev_id;
2876
2877 cmd->desc_id = param->desc_id;
2878 cmd->chanfreq = param->chanfreq;
2879 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2880 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2881 sizeof(uint32_t)));
2882 bufp += WMI_TLV_HDR_SIZE;
2883 qdf_mem_copy(bufp, param->pdata, bufp_len);
2884
2885 cmd->frame_len = param->frm_len;
2886 cmd->buf_len = bufp_len;
2887 cmd->tx_params_valid = param->tx_params_valid;
2888
2889 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
2890 bufp, cmd->vdev_id, cmd->chanfreq);
2891
2892 bufp += roundup(bufp_len, sizeof(uint32_t));
2893 if (param->tx_params_valid) {
2894 if (populate_tx_send_params(bufp, param->tx_param) !=
2895 QDF_STATUS_SUCCESS) {
2896 WMI_LOGE("%s: Populate TX send params failed",
2897 __func__);
2898 goto free_buf;
2899 }
2900 cmd_len += sizeof(wmi_tx_send_params);
2901 }
2902
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302903 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05302904 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2905 WMI_MGMT_TX_SEND_CMDID)) {
2906 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
2907 goto free_buf;
2908 }
2909 return QDF_STATUS_SUCCESS;
2910
2911free_buf:
2912 wmi_buf_free(buf);
2913 return QDF_STATUS_E_FAILURE;
2914}
2915#else
Govind Singhd3156eb2016-02-26 17:50:39 +05302916/**
2917 * send_mgmt_cmd_tlv() - WMI scan start function
2918 * @wmi_handle : handle to WMI.
2919 * @param : pointer to hold mgmt cmd parameter
2920 *
2921 * Return: 0 on success and -ve on failure.
2922 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302923static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302924 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302925{
Govind Singh427ee5a2016-02-26 18:09:36 +05302926 wmi_buf_t buf;
2927 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2928 int32_t cmd_len;
2929 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302930 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302931 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302932 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302933 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2934 mgmt_tx_dl_frm_len;
2935
2936 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302937 WMI_TLV_HDR_SIZE +
2938 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302939
Sathish Kumar5b636932017-06-28 14:40:32 +05302940 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302941 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302942 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2943 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302944 }
2945
2946 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2947 bufp = (uint8_t *) cmd;
2948 WMITLV_SET_HDR(&cmd->tlv_header,
2949 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2950 WMITLV_GET_STRUCT_TLVLEN
2951 (wmi_mgmt_tx_send_cmd_fixed_param));
2952
2953 cmd->vdev_id = param->vdev_id;
2954
Govind Singh224a7312016-06-21 14:33:26 +05302955 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302956 cmd->chanfreq = param->chanfreq;
2957 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2958 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2959 sizeof(uint32_t)));
2960 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302961 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302962
2963 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2964 QDF_DMA_TO_DEVICE);
2965 if (status != QDF_STATUS_SUCCESS) {
2966 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302967 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302968 }
2969
Govind Singhb53420c2016-03-09 14:32:57 +05302970 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302971 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002972#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302973 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2974#endif
2975 cmd->frame_len = param->frm_len;
2976 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302977 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302978
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002979 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002980 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002981
Sathish Kumar5b636932017-06-28 14:40:32 +05302982 bufp += roundup(bufp_len, sizeof(uint32_t));
2983 if (param->tx_params_valid) {
2984 status = populate_tx_send_params(bufp, param->tx_param);
2985 if (status != QDF_STATUS_SUCCESS) {
2986 WMI_LOGE("%s: Populate TX send params failed",
2987 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302988 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05302989 }
2990 cmd_len += sizeof(wmi_tx_send_params);
2991 }
2992
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302993 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302994 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2995 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302996 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302997 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05302998 }
Govind Singhb53420c2016-03-09 14:32:57 +05302999 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303000
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303001unmap_tx_frame:
3002 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3003 QDF_DMA_TO_DEVICE);
3004free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303005 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303006 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303007}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303008#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303009
3010/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303011 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3012 * @wmi_handle : handle to WMI.
3013 * @param : pointer to offchan data tx cmd parameter
3014 *
3015 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3016 */
3017static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3018 struct wmi_offchan_data_tx_params *param)
3019{
3020 wmi_buf_t buf;
3021 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3022 int32_t cmd_len;
3023 uint64_t dma_addr;
3024 void *qdf_ctx = param->qdf_ctx;
3025 uint8_t *bufp;
3026 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3027 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303028 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303029
3030 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303031 WMI_TLV_HDR_SIZE +
3032 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303033
Sathish Kumar5b636932017-06-28 14:40:32 +05303034 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303035 if (!buf) {
3036 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3037 return QDF_STATUS_E_NOMEM;
3038 }
3039
3040 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3041 bufp = (uint8_t *) cmd;
3042 WMITLV_SET_HDR(&cmd->tlv_header,
3043 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3044 WMITLV_GET_STRUCT_TLVLEN
3045 (wmi_offchan_data_tx_send_cmd_fixed_param));
3046
3047 cmd->vdev_id = param->vdev_id;
3048
3049 cmd->desc_id = param->desc_id;
3050 cmd->chanfreq = param->chanfreq;
3051 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3052 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3053 sizeof(uint32_t)));
3054 bufp += WMI_TLV_HDR_SIZE;
3055 qdf_mem_copy(bufp, param->pdata, bufp_len);
3056 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3057 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3058 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3059#if defined(HTT_PADDR64)
3060 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3061#endif
3062 cmd->frame_len = param->frm_len;
3063 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303064 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303065
3066 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3067 bufp, cmd->vdev_id, cmd->chanfreq);
3068
Sathish Kumar5b636932017-06-28 14:40:32 +05303069 bufp += roundup(bufp_len, sizeof(uint32_t));
3070 if (param->tx_params_valid) {
3071 status = populate_tx_send_params(bufp, param->tx_param);
3072 if (status != QDF_STATUS_SUCCESS) {
3073 WMI_LOGE("%s: Populate TX send params failed",
3074 __func__);
3075 goto err1;
3076 }
3077 cmd_len += sizeof(wmi_tx_send_params);
3078 }
3079
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303080 wmi_mtrace(WMI_OFFCHAN_DATA_TX_SEND_CMDID, cmd->vdev_id, 0);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303081 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3082 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3083 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303084 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303085 }
3086
3087 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303088
3089err1:
3090 wmi_buf_free(buf);
3091 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303092}
3093
3094/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303095 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3096 * @wmi_handle: wmi handle
3097 * @param_value: parameter value
3098 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303099 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303101static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303102 uint32_t param_value)
3103{
Govind Singh67922e82016-04-01 16:48:57 +05303104 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303105 wmi_modem_power_state_cmd_param *cmd;
3106 wmi_buf_t buf;
3107 uint16_t len = sizeof(*cmd);
3108
3109 buf = wmi_buf_alloc(wmi_handle, len);
3110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303111 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303112 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303113 }
3114 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3115 WMITLV_SET_HDR(&cmd->tlv_header,
3116 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3117 WMITLV_GET_STRUCT_TLVLEN
3118 (wmi_modem_power_state_cmd_param));
3119 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303120 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303121 param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303122 wmi_mtrace(WMI_MODEM_POWER_STATE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3124 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303125 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303126 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303127 wmi_buf_free(buf);
3128 }
Govind Singh67922e82016-04-01 16:48:57 +05303129
Govind Singh427ee5a2016-02-26 18:09:36 +05303130 return ret;
3131}
3132
3133/**
3134 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3135 * @wmi_handle: wmi handle
3136 * @vdev_id: vdev id
3137 * @val: value
3138 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303139 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303140 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303141static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303142 uint32_t vdev_id, uint8_t val)
3143{
3144 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3145 wmi_buf_t buf;
3146 int32_t len = sizeof(*cmd);
3147
Govind Singhb53420c2016-03-09 14:32:57 +05303148 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303149
3150 buf = wmi_buf_alloc(wmi_handle, len);
3151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303152 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303153 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303154 }
3155 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3156 WMITLV_SET_HDR(&cmd->tlv_header,
3157 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3158 WMITLV_GET_STRUCT_TLVLEN
3159 (wmi_sta_powersave_mode_cmd_fixed_param));
3160 cmd->vdev_id = vdev_id;
3161 if (val)
3162 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3163 else
3164 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3165
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303166 wmi_mtrace(WMI_STA_POWERSAVE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3168 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303169 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303170 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303171 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303172 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303173 }
Govind Singh5eb51532016-03-09 11:34:12 +05303174 return 0;
3175}
3176
Govind Singh427ee5a2016-02-26 18:09:36 +05303177/**
3178 * send_set_mimops_cmd_tlv() - set MIMO powersave
3179 * @wmi_handle: wmi handle
3180 * @vdev_id: vdev id
3181 * @value: value
3182 *
Govind Singhb53420c2016-03-09 14:32:57 +05303183 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303184 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303185static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303186 uint8_t vdev_id, int value)
3187{
Govind Singh67922e82016-04-01 16:48:57 +05303188 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3190 wmi_buf_t buf;
3191 uint16_t len = sizeof(*cmd);
3192
3193 buf = wmi_buf_alloc(wmi_handle, len);
3194 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303195 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303196 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303197 }
3198 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3199 WMITLV_SET_HDR(&cmd->tlv_header,
3200 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3201 WMITLV_GET_STRUCT_TLVLEN
3202 (wmi_sta_smps_force_mode_cmd_fixed_param));
3203
3204 cmd->vdev_id = vdev_id;
3205
Houston Hoffmanb5168052016-04-14 02:18:01 -07003206 /* WMI_SMPS_FORCED_MODE values do not directly map
3207 * to SM power save values defined in the specification.
3208 * Make sure to send the right mapping.
3209 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303210 switch (value) {
3211 case 0:
3212 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3213 break;
3214 case 1:
3215 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3216 break;
3217 case 2:
3218 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3219 break;
3220 case 3:
3221 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3222 break;
3223 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303224 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303226 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303227 }
3228
Govind Singhb53420c2016-03-09 14:32:57 +05303229 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303230
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303231 wmi_mtrace(WMI_STA_SMPS_FORCE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3233 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303234 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303235 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303236 wmi_buf_free(buf);
3237 }
3238
3239 return ret;
3240}
3241
3242/**
3243 * send_set_smps_params_cmd_tlv() - set smps params
3244 * @wmi_handle: wmi handle
3245 * @vdev_id: vdev id
3246 * @value: value
3247 *
Govind Singhb53420c2016-03-09 14:32:57 +05303248 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303249 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303250static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303251 int value)
3252{
Govind Singh67922e82016-04-01 16:48:57 +05303253 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303254 wmi_sta_smps_param_cmd_fixed_param *cmd;
3255 wmi_buf_t buf;
3256 uint16_t len = sizeof(*cmd);
3257
3258 buf = wmi_buf_alloc(wmi_handle, len);
3259 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303260 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303261 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 }
3263 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3264 WMITLV_SET_HDR(&cmd->tlv_header,
3265 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3266 WMITLV_GET_STRUCT_TLVLEN
3267 (wmi_sta_smps_param_cmd_fixed_param));
3268
3269 cmd->vdev_id = vdev_id;
3270 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3271 cmd->param =
3272 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3273
Govind Singhb53420c2016-03-09 14:32:57 +05303274 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303275 cmd->param);
3276
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303277 wmi_mtrace(WMI_STA_SMPS_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3279 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303280 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303281 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303282 wmi_buf_free(buf);
3283 }
3284
3285 return ret;
3286}
3287
3288/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303289 * send_get_temperature_cmd_tlv() - get pdev temperature req
3290 * @wmi_handle: wmi handle
3291 *
Govind Singhb53420c2016-03-09 14:32:57 +05303292 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303293 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303294static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303295{
3296 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3297 wmi_buf_t wmi_buf;
3298 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3299 uint8_t *buf_ptr;
3300
3301 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303302 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3303 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303304 }
3305
3306 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3307 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303308 WMI_LOGE(FL("wmi_buf_alloc failed"));
3309 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 }
3311
3312 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3313
3314 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3315 WMITLV_SET_HDR(&cmd->tlv_header,
3316 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3317 WMITLV_GET_STRUCT_TLVLEN
3318 (wmi_pdev_get_temperature_cmd_fixed_param));
3319
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303320 wmi_mtrace(WMI_PDEV_GET_TEMPERATURE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303321 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3322 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303323 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303324 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303325 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303326 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303327
Govind Singhb53420c2016-03-09 14:32:57 +05303328 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303329}
3330
3331/**
3332 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3333 * @wmi_handle: wmi handle
3334 * @vdevid: vdev id
3335 * @peer_addr: peer mac address
3336 * @auto_triggerparam: auto trigger parameters
3337 * @num_ac: number of access category
3338 *
3339 * This function sets the trigger
3340 * uapsd params such as service interval, delay interval
3341 * and suspend interval which will be used by the firmware
3342 * to send trigger frames periodically when there is no
3343 * traffic on the transmit side.
3344 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303345 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303347static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303348 struct sta_uapsd_trig_params *param)
3349{
3350 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303351 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303352 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3353 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3354 uint32_t i;
3355 wmi_buf_t buf;
3356 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003357 struct sta_uapsd_params *uapsd_param;
3358 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303359
3360 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3361 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303362 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303363 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303364 }
3365
3366 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3367 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3368 WMITLV_SET_HDR(&cmd->tlv_header,
3369 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3370 WMITLV_GET_STRUCT_TLVLEN
3371 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3372 cmd->vdev_id = param->vdevid;
3373 cmd->num_ac = param->num_ac;
3374 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3375
3376 /* TLV indicating array of structures to follow */
3377 buf_ptr += sizeof(*cmd);
3378 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3379
3380 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303381
3382 /*
3383 * Update tag and length for uapsd auto trigger params (this will take
3384 * care of updating tag and length if it is not pre-filled by caller).
3385 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003386 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3387 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303388 for (i = 0; i < param->num_ac; i++) {
3389 WMITLV_SET_HDR((buf_ptr +
3390 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3391 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3392 WMITLV_GET_STRUCT_TLVLEN
3393 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003394 trig_param->wmm_ac = uapsd_param->wmm_ac;
3395 trig_param->user_priority = uapsd_param->user_priority;
3396 trig_param->service_interval = uapsd_param->service_interval;
3397 trig_param->suspend_interval = uapsd_param->suspend_interval;
3398 trig_param->delay_interval = uapsd_param->delay_interval;
3399 trig_param++;
3400 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303401 }
3402
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303403 wmi_mtrace(WMI_STA_UAPSD_AUTO_TRIG_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303404 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3405 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303406 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303407 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303408 wmi_buf_free(buf);
3409 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303410
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 return ret;
3412}
3413
Govind Singh17a9cfa2016-03-01 15:54:59 +05303414/**
3415 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3416 * @wmi_handle: Pointer to wmi handle
3417 * @thermal_info: Thermal command information
3418 *
3419 * This function sends the thermal management command
3420 * to the firmware
3421 *
Govind Singhb53420c2016-03-09 14:32:57 +05303422 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303423 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303424static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303425 struct thermal_cmd_params *thermal_info)
3426{
3427 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3428 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303429 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303430 uint32_t len = 0;
3431
3432 len = sizeof(*cmd);
3433
3434 buf = wmi_buf_alloc(wmi_handle, len);
3435 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303436 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3437 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303438 }
3439
3440 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3441
3442 WMITLV_SET_HDR(&cmd->tlv_header,
3443 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3444 WMITLV_GET_STRUCT_TLVLEN
3445 (wmi_thermal_mgmt_cmd_fixed_param));
3446
3447 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3448 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3449 cmd->enable = thermal_info->thermal_enable;
3450
Govind Singhb53420c2016-03-09 14:32:57 +05303451 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303452 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3453
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303454 wmi_mtrace(WMI_THERMAL_MGMT_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303455 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3456 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303457 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303458 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303459 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303460 }
3461
Govind Singh67922e82016-04-01 16:48:57 +05303462 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303463}
3464
Govind Singh17a9cfa2016-03-01 15:54:59 +05303465/**
3466 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303467 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303468 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3469 *
3470 * This function sends down the LRO configuration parameters to
3471 * the firmware to enable LRO, sets the TCP flags and sets the
3472 * seed values for the toeplitz hash generation
3473 *
Govind Singhb53420c2016-03-09 14:32:57 +05303474 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303475 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303476static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303477 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3478{
3479 wmi_lro_info_cmd_fixed_param *cmd;
3480 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303481 QDF_STATUS status;
Tallapragada Kalyan85a74002018-08-28 12:34:21 +05303482 uint8_t pdev_id = wmi_lro_cmd->pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303483
3484 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303486 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3487 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303488 }
3489
3490 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3491
3492 WMITLV_SET_HDR(&cmd->tlv_header,
3493 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3494 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3495
3496 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3497 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3498 wmi_lro_cmd->tcp_flag);
3499 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3500 wmi_lro_cmd->tcp_flag_mask);
3501 cmd->toeplitz_hash_ipv4_0_3 =
3502 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3503 cmd->toeplitz_hash_ipv4_4_7 =
3504 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3505 cmd->toeplitz_hash_ipv4_8_11 =
3506 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3507 cmd->toeplitz_hash_ipv4_12_15 =
3508 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3509 cmd->toeplitz_hash_ipv4_16 =
3510 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3511
3512 cmd->toeplitz_hash_ipv6_0_3 =
3513 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3514 cmd->toeplitz_hash_ipv6_4_7 =
3515 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3516 cmd->toeplitz_hash_ipv6_8_11 =
3517 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3518 cmd->toeplitz_hash_ipv6_12_15 =
3519 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3520 cmd->toeplitz_hash_ipv6_16_19 =
3521 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3522 cmd->toeplitz_hash_ipv6_20_23 =
3523 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3524 cmd->toeplitz_hash_ipv6_24_27 =
3525 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3526 cmd->toeplitz_hash_ipv6_28_31 =
3527 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3528 cmd->toeplitz_hash_ipv6_32_35 =
3529 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3530 cmd->toeplitz_hash_ipv6_36_39 =
3531 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3532 cmd->toeplitz_hash_ipv6_40 =
3533 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3534
Tallapragada Kalyan85a74002018-08-28 12:34:21 +05303535 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
3536 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x, pdev_id: %d",
3537 cmd->lro_enable, cmd->tcp_flag_u32, cmd->pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303538
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303539 wmi_mtrace(WMI_LRO_CONFIG_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303540 status = wmi_unified_cmd_send(wmi_handle, buf,
3541 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303542 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303544 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303545 }
3546
Govind Singh67922e82016-04-01 16:48:57 +05303547 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303548}
3549
Govind Singh4eacd2b2016-03-07 14:24:22 +05303550/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303551 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3552 * @wmi_handle: Pointer to wmi handle
3553 * @rate_report_params: Pointer to peer rate report parameters
3554 *
3555 *
3556 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3557 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303558static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303559 struct wmi_peer_rate_report_params *rate_report_params)
3560{
3561 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3562 wmi_buf_t buf = NULL;
3563 QDF_STATUS status = 0;
3564 uint32_t len = 0;
3565 uint32_t i, j;
3566
3567 len = sizeof(*cmd);
3568
3569 buf = wmi_buf_alloc(wmi_handle, len);
3570 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303571 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd");
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303572 return QDF_STATUS_E_FAILURE;
3573 }
3574
3575 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3576 wmi_buf_data(buf);
3577
3578 WMITLV_SET_HDR(
3579 &cmd->tlv_header,
3580 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3581 WMITLV_GET_STRUCT_TLVLEN(
3582 wmi_peer_set_rate_report_condition_fixed_param));
3583
3584 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3585 cmd->report_backoff_time = rate_report_params->backoff_time;
3586 cmd->report_timer_period = rate_report_params->timer_period;
3587 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303588 cmd->cond_per_phy[i].val_cond_flags =
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303589 rate_report_params->report_per_phy[i].cond_flags;
3590 cmd->cond_per_phy[i].rate_delta.min_delta =
3591 rate_report_params->report_per_phy[i].delta.delta_min;
3592 cmd->cond_per_phy[i].rate_delta.percentage =
3593 rate_report_params->report_per_phy[i].delta.percent;
3594 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3595 cmd->cond_per_phy[i].rate_threshold[j] =
3596 rate_report_params->report_per_phy[i].
3597 report_rate_threshold[j];
3598 }
3599 }
3600
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303601 WMI_LOGE("%s enable %d backoff_time %d period %d", __func__,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303602 cmd->enable_rate_report,
3603 cmd->report_backoff_time, cmd->report_timer_period);
3604
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303605 wmi_mtrace(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID, NO_SESSION, 0);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303606 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3607 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3608 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303609 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303610 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3611 __func__);
3612 }
3613 return status;
3614}
3615
3616/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303617 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3618 * @wmi_handle: wmi handle
3619 * @param: bcn ll cmd parameter
3620 *
Govind Singhb53420c2016-03-09 14:32:57 +05303621 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303622 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303623static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303624 wmi_bcn_send_from_host_cmd_fixed_param *param)
3625{
3626 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3627 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303628 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303629
3630 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3631 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303632 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3633 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303634 }
3635
3636 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3637 WMITLV_SET_HDR(&cmd->tlv_header,
3638 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3639 WMITLV_GET_STRUCT_TLVLEN
3640 (wmi_bcn_send_from_host_cmd_fixed_param));
3641 cmd->vdev_id = param->vdev_id;
3642 cmd->data_len = param->data_len;
3643 cmd->frame_ctrl = param->frame_ctrl;
3644 cmd->frag_ptr = param->frag_ptr;
3645 cmd->dtim_flag = param->dtim_flag;
3646
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303647 wmi_mtrace(WMI_PDEV_SEND_BCN_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303648 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3649 WMI_PDEV_SEND_BCN_CMDID);
3650
Govind Singh67922e82016-04-01 16:48:57 +05303651 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303653 wmi_buf_free(wmi_buf);
3654 }
3655
3656 return ret;
3657}
3658
3659/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303660 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3661 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303662 * @vdev_id: vdev id.
3663 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05303664 *
3665 * This function updates EDCA parameters to the target
3666 *
3667 * Return: CDF Status
3668 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303669static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003670 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303671 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05303672{
3673 uint8_t *buf_ptr;
3674 wmi_buf_t buf;
3675 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303676 wmi_wmm_vparams *wmm_param;
3677 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303678 int len = sizeof(*cmd);
3679 int ac;
3680
3681 buf = wmi_buf_alloc(wmi_handle, len);
3682
3683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303684 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3685 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303686 }
3687
3688 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3689 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3690 WMITLV_SET_HDR(&cmd->tlv_header,
3691 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3692 WMITLV_GET_STRUCT_TLVLEN
3693 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3694 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003695 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303696
3697 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3698 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303699 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303700 WMITLV_SET_HDR(&wmm_param->tlv_header,
3701 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3702 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3703 wmm_param->cwmin = twmm_param->cwmin;
3704 wmm_param->cwmax = twmm_param->cwmax;
3705 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003706 if (mu_edca_param)
3707 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
3708 else
3709 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303710 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303711 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303712 }
3713
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303714 wmi_mtrace(WMI_VDEV_SET_WMM_PARAMS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3716 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3717 goto fail;
3718
Govind Singhb53420c2016-03-09 14:32:57 +05303719 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303720
3721fail:
3722 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303723 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3724 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303725}
3726
3727/**
3728 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3729 * @wmi_handle: wmi handle
3730 * @vdev_id: vdev id
3731 * @probe_rsp_info: probe response info
3732 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303733 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303734 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303735static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303736 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08003737 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05303738{
3739 wmi_prb_tmpl_cmd_fixed_param *cmd;
3740 wmi_bcn_prb_info *bcn_prb_info;
3741 wmi_buf_t wmi_buf;
3742 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3743 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303744 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303745
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303747
Krunal Soni89426862017-11-14 15:42:48 -08003748 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05303749 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303750
3751 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3752 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3753 tmpl_len_aligned;
3754
3755 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303756 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303757 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303758 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303759 }
3760
3761 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3762 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303763 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303764 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303765 }
3766
3767 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3768
3769 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3770 WMITLV_SET_HDR(&cmd->tlv_header,
3771 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3772 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3773 cmd->vdev_id = vdev_id;
3774 cmd->buf_len = tmpl_len;
3775 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3776
3777 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
3778 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
3779 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
3780 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
3781 bcn_prb_info->caps = 0;
3782 bcn_prb_info->erp = 0;
3783 buf_ptr += sizeof(wmi_bcn_prb_info);
3784
3785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
3786 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08003787 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303788
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303789 wmi_mtrace(WMI_PRB_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303790 ret = wmi_unified_cmd_send(wmi_handle,
3791 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303792 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303793 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303794 wmi_buf_free(wmi_buf);
3795 }
3796
3797 return ret;
3798}
3799
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05303800#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303801#define WPI_IV_LEN 16
3802
3803/**
3804 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
3805 *
3806 * @dest_tx: destination address of tsc key counter
3807 * @src_tx: source address of tsc key counter
3808 * @dest_rx: destination address of rsc key counter
3809 * @src_rx: source address of rsc key counter
3810 *
3811 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
3812 *
3813 * Return: None
3814 *
3815 */
3816static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3817 uint8_t *dest_rx, uint8_t *src_rx)
3818{
3819 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
3820 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
3821}
3822#else
3823static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3824 uint8_t *dest_rx, uint8_t *src_rx)
3825{
3826 return;
3827}
3828#endif
3829
3830/**
3831 * send_setup_install_key_cmd_tlv() - set key parameters
3832 * @wmi_handle: wmi handle
3833 * @key_params: key parameters
3834 *
3835 * This function fills structure from information
3836 * passed in key_params.
3837 *
3838 * Return: QDF_STATUS_SUCCESS - success
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303839 * QDF_STATUS_E_FAILURE - failure
3840 * QDF_STATUS_E_NOMEM - not able to allocate buffer
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303842static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303843 struct set_key_params *key_params)
3844{
3845 wmi_vdev_install_key_cmd_fixed_param *cmd;
3846 wmi_buf_t buf;
3847 uint8_t *buf_ptr;
3848 uint32_t len;
3849 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05303850 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303851
3852 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
3853 WMI_TLV_HDR_SIZE;
3854
3855 buf = wmi_buf_alloc(wmi_handle, len);
3856 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05303857 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303858 return QDF_STATUS_E_NOMEM;
3859 }
3860
3861 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3862 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
3863 WMITLV_SET_HDR(&cmd->tlv_header,
3864 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
3865 WMITLV_GET_STRUCT_TLVLEN
3866 (wmi_vdev_install_key_cmd_fixed_param));
3867 cmd->vdev_id = key_params->vdev_id;
3868 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05303869
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05303870
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303871 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
3872 cmd->key_flags |= key_params->key_flags;
3873 cmd->key_cipher = key_params->key_cipher;
3874 if ((key_params->key_txmic_len) &&
3875 (key_params->key_rxmic_len)) {
3876 cmd->key_txmic_len = key_params->key_txmic_len;
3877 cmd->key_rxmic_len = key_params->key_rxmic_len;
3878 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05303879#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303880 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
3881 key_params->tx_iv,
3882 cmd->wpi_key_rsc_counter,
3883 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05303884#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303885 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
3886 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3887 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05303888 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303889 qdf_mem_copy((void *)key_data,
3890 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07003891 if (key_params->key_rsc_counter)
3892 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
3893 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303894 cmd->key_len = key_params->key_len;
3895
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303896 wmi_mtrace(WMI_VDEV_INSTALL_KEY_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303897 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3898 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303899 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05303900 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303901
Govind Singh67922e82016-04-01 16:48:57 +05303902 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303903}
3904
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05303905/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303906 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
3907 * @wmi_handle: wmi handle
3908 * @vdev_id: vdev id
3909 * @p2p_ie: p2p IE
3910 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303911 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303912 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303913static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05303914 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05303915{
Govind Singh67922e82016-04-01 16:48:57 +05303916 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303917 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
3918 wmi_buf_t wmi_buf;
3919 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
3920 uint8_t *buf_ptr;
3921
3922 ie_len = (uint32_t) (p2p_ie[1] + 2);
3923
3924 /* More than one P2P IE may be included in a single frame.
3925 If multiple P2P IEs are present, the complete P2P attribute
3926 data consists of the concatenation of the P2P Attribute
3927 fields of the P2P IEs. The P2P Attributes field of each
3928 P2P IE may be any length up to the maximum (251 octets).
3929 In this case host sends one P2P IE to firmware so the length
3930 should not exceed more than 251 bytes
3931 */
3932 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05303933 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05303934 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303935 }
3936
Vivekc5823092018-03-22 23:27:21 +05303937 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303938
3939 wmi_buf_len =
3940 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
3941 WMI_TLV_HDR_SIZE;
3942
3943 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3944 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303945 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303946 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303947 }
3948
3949 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3950
3951 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
3952 WMITLV_SET_HDR(&cmd->tlv_header,
3953 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
3954 WMITLV_GET_STRUCT_TLVLEN
3955 (wmi_p2p_go_set_beacon_ie_fixed_param));
3956 cmd->vdev_id = vdev_id;
3957 cmd->ie_buf_len = ie_len;
3958
3959 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
3960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
3961 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303962 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303963
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05303964 WMI_LOGD("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303965
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303966 wmi_mtrace(WMI_P2P_GO_SET_BEACON_IE, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303967 ret = wmi_unified_cmd_send(wmi_handle,
3968 wmi_buf, wmi_buf_len,
3969 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05303970 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303971 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303972 wmi_buf_free(wmi_buf);
3973 }
3974
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05303975 WMI_LOGD("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303976 return ret;
3977}
3978
3979/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303980 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
3981 * @wmi_handle: wmi handle
3982 * @psetoui: OUI parameters
3983 *
3984 * set scan probe OUI parameters in firmware
3985 *
3986 * Return: CDF status
3987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303988static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303989 struct scan_mac_oui *psetoui)
3990{
3991 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
3992 wmi_buf_t wmi_buf;
3993 uint32_t len;
3994 uint8_t *buf_ptr;
3995 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05303996 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303997
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05303998 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3999 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
4000
Govind Singh4eacd2b2016-03-07 14:24:22 +05304001 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4002 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304003 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4004 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304005 }
4006 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4007 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4008 WMITLV_SET_HDR(&cmd->tlv_header,
4009 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4010 WMITLV_GET_STRUCT_TLVLEN
4011 (wmi_scan_prob_req_oui_cmd_fixed_param));
4012
4013 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304014 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304015 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4016 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304017 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304018 cmd->prob_req_oui);
4019
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05304020 cmd->vdev_id = psetoui->vdev_id;
4021 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
4022 if (psetoui->enb_probe_req_sno_randomization)
4023 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
4024
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304025 if (ie_whitelist->white_list) {
4026 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
4027 &cmd->num_vendor_oui,
4028 ie_whitelist);
4029 cmd->flags |=
4030 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
4031 }
4032
4033 buf_ptr += sizeof(*cmd);
4034 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4035 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
4036 buf_ptr += WMI_TLV_HDR_SIZE;
4037
4038 if (cmd->num_vendor_oui != 0) {
4039 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
4040 ie_whitelist->voui);
4041 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
4042 }
4043
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304044 wmi_mtrace(WMI_SCAN_PROB_REQ_OUI_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304045 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4046 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304047 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304048 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304049 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304050 }
Govind Singhb53420c2016-03-09 14:32:57 +05304051 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304052}
4053
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304054#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05304055/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
4056 * @wmi_handle: wmi handle
4057 * @ipa_offload: ipa offload control parameter
4058 *
4059 * Returns: 0 on success, error number otherwise
4060 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304061static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304062 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304063{
4064 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
4065 wmi_buf_t wmi_buf;
4066 uint32_t len;
4067 u_int8_t *buf_ptr;
4068
4069 len = sizeof(*cmd);
4070 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4071 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304072 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
4073 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304074 }
4075
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08004076 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304077 ipa_offload->offload_type, ipa_offload->enable);
4078
4079 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
4080
4081 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
4082 WMITLV_SET_HDR(&cmd->tlv_header,
4083 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
4084 WMITLV_GET_STRUCT_TLVLEN(
4085 wmi_ipa_offload_enable_disable_cmd_fixed_param));
4086
4087 cmd->offload_type = ipa_offload->offload_type;
4088 cmd->vdev_id = ipa_offload->vdev_id;
4089 cmd->enable = ipa_offload->enable;
4090
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304091 wmi_mtrace(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304092 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4093 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304094 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304095 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304096 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304097 }
4098
Govind Singhb53420c2016-03-09 14:32:57 +05304099 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304100}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304101#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05304102
4103/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304104 * send_pno_stop_cmd_tlv() - PNO stop request
4105 * @wmi_handle: wmi handle
4106 * @vdev_id: vdev id
4107 *
4108 * This function request FW to stop ongoing PNO operation.
4109 *
4110 * Return: CDF status
4111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304112static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304113{
4114 wmi_nlo_config_cmd_fixed_param *cmd;
4115 int32_t len = sizeof(*cmd);
4116 wmi_buf_t buf;
4117 uint8_t *buf_ptr;
4118 int ret;
4119
4120 /*
4121 * TLV place holder for array of structures nlo_configured_parameters
4122 * TLV place holder for array of uint32_t channel_list
4123 * TLV place holder for chnl prediction cfg
4124 */
4125 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
4126 buf = wmi_buf_alloc(wmi_handle, len);
4127 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304128 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4129 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304130 }
4131
4132 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
4133 buf_ptr = (uint8_t *) cmd;
4134
4135 WMITLV_SET_HDR(&cmd->tlv_header,
4136 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
4137 WMITLV_GET_STRUCT_TLVLEN
4138 (wmi_nlo_config_cmd_fixed_param));
4139
4140 cmd->vdev_id = vdev_id;
4141 cmd->flags = WMI_NLO_CONFIG_STOP;
4142 buf_ptr += sizeof(*cmd);
4143
4144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
4145 buf_ptr += WMI_TLV_HDR_SIZE;
4146
4147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
4148 buf_ptr += WMI_TLV_HDR_SIZE;
4149
4150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
4151 buf_ptr += WMI_TLV_HDR_SIZE;
4152
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304153 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304154 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4155 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
4156 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304158 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304159 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304160 }
4161
Govind Singhb53420c2016-03-09 14:32:57 +05304162 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304163}
4164
4165/**
Govind Singhccb0c272016-04-01 16:30:08 +05304166 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
4167 * @buf_ptr: Buffer passed by upper layers
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304168 * @pno: Buffer to be sent to the firmware
Govind Singhccb0c272016-04-01 16:30:08 +05304169 *
4170 * Copy the PNO Channel prediction configuration parameters
4171 * passed by the upper layers to a WMI format TLV and send it
4172 * down to the firmware.
4173 *
4174 * Return: None
4175 */
4176static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
4177 struct pno_scan_req_params *pno)
4178{
4179 nlo_channel_prediction_cfg *channel_prediction_cfg =
4180 (nlo_channel_prediction_cfg *) buf_ptr;
4181 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
4182 WMITLV_TAG_ARRAY_BYTE,
4183 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05304184#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05304185 channel_prediction_cfg->enable = pno->pno_channel_prediction;
4186 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
4187 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
4188 channel_prediction_cfg->full_scan_period_ms =
4189 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05304190#endif
Govind Singhccb0c272016-04-01 16:30:08 +05304191 buf_ptr += sizeof(nlo_channel_prediction_cfg);
4192 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
4193 channel_prediction_cfg->enable,
4194 channel_prediction_cfg->top_k_num,
4195 channel_prediction_cfg->stationary_threshold,
4196 channel_prediction_cfg->full_scan_period_ms);
4197}
4198
4199/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004200 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
4201 * @wmi_handle: wmi handle
4202 * @params: configuration parameters
4203 *
4204 * Return: QDF_STATUS
4205 */
4206static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
4207 struct nlo_mawc_params *params)
4208{
4209 wmi_buf_t buf = NULL;
4210 QDF_STATUS status;
4211 int len;
4212 uint8_t *buf_ptr;
4213 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
4214
4215 len = sizeof(*wmi_nlo_mawc_params);
4216 buf = wmi_buf_alloc(wmi_handle, len);
4217 if (!buf) {
4218 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4219 return QDF_STATUS_E_NOMEM;
4220 }
4221
4222 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4223 wmi_nlo_mawc_params =
4224 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
4225 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
4226 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
4227 WMITLV_GET_STRUCT_TLVLEN
4228 (wmi_nlo_configure_mawc_cmd_fixed_param));
4229 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
4230 if (params->enable)
4231 wmi_nlo_mawc_params->enable = 1;
4232 else
4233 wmi_nlo_mawc_params->enable = 0;
4234 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
4235 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
4236 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07004237 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
4238 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
4239 wmi_nlo_mawc_params->exp_backoff_ratio,
4240 wmi_nlo_mawc_params->init_scan_interval,
4241 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004242
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304243 wmi_mtrace(WMI_NLO_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004244 status = wmi_unified_cmd_send(wmi_handle, buf,
4245 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
4246 if (QDF_IS_STATUS_ERROR(status)) {
4247 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
4248 status);
4249 wmi_buf_free(buf);
4250 return QDF_STATUS_E_FAILURE;
4251 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004252
4253 return QDF_STATUS_SUCCESS;
4254}
4255
4256/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304257 * send_pno_start_cmd_tlv() - PNO start request
4258 * @wmi_handle: wmi handle
4259 * @pno: PNO request
4260 *
4261 * This function request FW to start PNO request.
4262 * Request: CDF status
4263 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304264static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05304265 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304266{
4267 wmi_nlo_config_cmd_fixed_param *cmd;
4268 nlo_configured_parameters *nlo_list;
4269 uint32_t *channel_list;
4270 int32_t len;
4271 wmi_buf_t buf;
4272 uint8_t *buf_ptr;
4273 uint8_t i;
4274 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304275 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304276 connected_nlo_rssi_params *nlo_relative_rssi;
4277 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304278
4279 /*
4280 * TLV place holder for array nlo_configured_parameters(nlo_list)
4281 * TLV place holder for array of uint32_t channel_list
4282 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304283 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304284 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05304285 */
4286 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304287 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304288 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304289
Abhishek Singh5987b632017-03-03 22:09:07 +05304290 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304291 WMI_NLO_MAX_CHAN);
4292 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05304293 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304294 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304295 len += sizeof(enlo_candidate_score_params);
4296 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304297 len += sizeof(connected_nlo_rssi_params);
4298 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304299
4300 buf = wmi_buf_alloc(wmi_handle, len);
4301 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304302 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4303 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304304 }
4305
4306 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
4307
4308 buf_ptr = (uint8_t *) cmd;
4309 WMITLV_SET_HDR(&cmd->tlv_header,
4310 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
4311 WMITLV_GET_STRUCT_TLVLEN
4312 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05304313 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304314 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
4315
Govind Singh87542482016-06-08 19:40:11 +05304316#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05304317 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05304318 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05304319#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05304320 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05304321 cmd->active_dwell_time = pno->active_dwell_time;
4322 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304323
Manjeet Singhcd2dc062016-08-11 15:31:34 +05304324 if (pno->do_passive_scan)
4325 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304326 /* Copy scan interval */
4327 cmd->fast_scan_period = pno->fast_scan_period;
4328 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08004329 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304330 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07004331 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05304332 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304333 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05304334 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304335
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05304336 /* mac randomization attributes */
4337 if (pno->scan_random.randomize) {
4338 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
4339 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
4340 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
4341 pno->scan_random.mac_mask,
4342 &cmd->mac_addr,
4343 &cmd->mac_mask);
4344 }
4345
Govind Singh4eacd2b2016-03-07 14:24:22 +05304346 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
4347
Abhishek Singh5987b632017-03-03 22:09:07 +05304348 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05304349 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304350 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4351 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
4352 buf_ptr += WMI_TLV_HDR_SIZE;
4353
4354 nlo_list = (nlo_configured_parameters *) buf_ptr;
4355 for (i = 0; i < cmd->no_of_ssids; i++) {
4356 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
4357 WMITLV_TAG_ARRAY_BYTE,
4358 WMITLV_GET_STRUCT_TLVLEN
4359 (nlo_configured_parameters));
4360 /* Copy ssid and it's length */
4361 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05304362 nlo_list[i].ssid.ssid.ssid_len =
4363 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05304364 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05304365 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304366 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05304367 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304368 nlo_list[i].ssid.ssid.ssid_len,
4369 (char *)nlo_list[i].ssid.ssid.ssid,
4370 nlo_list[i].ssid.ssid.ssid_len);
4371
4372 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05304373 if (pno->networks_list[i].rssi_thresh &&
4374 pno->networks_list[i].rssi_thresh >
4375 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05304376 nlo_list[i].rssi_cond.valid = true;
4377 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05304378 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05304379 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304380 nlo_list[i].rssi_cond.rssi);
4381 }
4382 nlo_list[i].bcast_nw_type.valid = true;
4383 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05304384 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07004385 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304386 nlo_list[i].bcast_nw_type.bcast_nw_type);
4387 }
4388 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
4389
4390 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05304391 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304392 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05304393 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
4395 (cmd->num_of_channels * sizeof(uint32_t)));
4396 buf_ptr += WMI_TLV_HDR_SIZE;
4397
4398 channel_list = (uint32_t *) buf_ptr;
4399 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05304400 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05304401
4402 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05304403 channel_list[i] =
4404 wlan_chan_to_freq(pno->
4405 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304406
Govind Singhb53420c2016-03-09 14:32:57 +05304407 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304408 }
4409 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
4410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4411 sizeof(nlo_channel_prediction_cfg));
4412 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05304413 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304414 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415 /** TODO: Discrete firmware doesn't have command/option to configure
4416 * App IE which comes from wpa_supplicant as of part PNO start request.
4417 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
4419 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
4420 buf_ptr += sizeof(enlo_candidate_score_params);
4421
4422 if (ie_whitelist->white_list) {
4423 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
4424 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
4425 &cmd->num_vendor_oui,
4426 ie_whitelist);
4427 }
4428
4429 /* ie white list */
4430 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4431 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
4432 buf_ptr += WMI_TLV_HDR_SIZE;
4433 if (cmd->num_vendor_oui != 0) {
4434 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
4435 ie_whitelist->voui);
4436 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
4437 }
4438
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304439 if (pno->relative_rssi_set)
4440 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
4441
4442 /*
4443 * Firmware calculation using connected PNO params:
4444 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
4445 * deduction of rssi_pref for chosen band_pref and
4446 * addition of rssi_pref for remaining bands (other than chosen band).
4447 */
4448 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
4449 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
4450 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
4451 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
4452 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
4453 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
4454 buf_ptr += sizeof(*nlo_relative_rssi);
4455
4456 /*
4457 * As of now Kernel and Host supports one band and rssi preference.
4458 * Firmware supports array of band and rssi preferences
4459 */
4460 cmd->num_cnlo_band_pref = 1;
4461 WMITLV_SET_HDR(buf_ptr,
4462 WMITLV_TAG_ARRAY_STRUC,
4463 cmd->num_cnlo_band_pref *
4464 sizeof(connected_nlo_bss_band_rssi_pref));
4465 buf_ptr += WMI_TLV_HDR_SIZE;
4466
4467 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
4468 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
4469 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
4470 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
4471 WMITLV_GET_STRUCT_TLVLEN(
4472 connected_nlo_bss_band_rssi_pref));
4473 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
4474 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
4475 WMI_LOGI("band_pref %d, rssi_pref %d",
4476 nlo_band_rssi[i].band,
4477 nlo_band_rssi[i].rssi_pref);
4478 }
4479 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
4480
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304481 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4483 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
4484 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304485 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304486 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304487 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304488 }
4489
Govind Singhb53420c2016-03-09 14:32:57 +05304490 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304491}
4492
Qiwei Cai1ccba222018-05-21 16:49:39 +08004493#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304494/**
4495 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
4496 * @wmi_handle: wmi handle
4497 * @clear_req: ll stats clear request command params
4498 *
Govind Singhb53420c2016-03-09 14:32:57 +05304499 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304501static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304502 const struct ll_stats_clear_params *clear_req,
4503 uint8_t addr[IEEE80211_ADDR_LEN])
4504{
4505 wmi_clear_link_stats_cmd_fixed_param *cmd;
4506 int32_t len;
4507 wmi_buf_t buf;
4508 uint8_t *buf_ptr;
4509 int ret;
4510
4511 len = sizeof(*cmd);
4512 buf = wmi_buf_alloc(wmi_handle, len);
4513
4514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304515 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4516 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304517 }
4518
4519 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304520 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
4522
4523 WMITLV_SET_HDR(&cmd->tlv_header,
4524 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
4525 WMITLV_GET_STRUCT_TLVLEN
4526 (wmi_clear_link_stats_cmd_fixed_param));
4527
4528 cmd->stop_stats_collection_req = clear_req->stop_req;
4529 cmd->vdev_id = clear_req->sta_id;
4530 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
4531
4532 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
4533 &cmd->peer_macaddr);
4534
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304536 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
4537 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
Govind Singhb53420c2016-03-09 14:32:57 +05304538 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
4539 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304540 cmd->peer_macaddr); */
4541
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304542 wmi_mtrace(WMI_CLEAR_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304543 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4544 WMI_CLEAR_LINK_STATS_CMDID);
4545 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304546 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304547 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304548 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549 }
4550
Govind Singhb53420c2016-03-09 14:32:57 +05304551 WMI_LOGD("Clear Link Layer Stats request sent successfully");
4552 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304553}
4554
4555/**
4556 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
4557 * @wmi_handle: wmi handle
4558 * @setReq: ll stats set request command params
4559 *
Govind Singhb53420c2016-03-09 14:32:57 +05304560 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304561 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304562static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304563 const struct ll_stats_set_params *set_req)
4564{
4565 wmi_start_link_stats_cmd_fixed_param *cmd;
4566 int32_t len;
4567 wmi_buf_t buf;
4568 uint8_t *buf_ptr;
4569 int ret;
4570
4571 len = sizeof(*cmd);
4572 buf = wmi_buf_alloc(wmi_handle, len);
4573
4574 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304575 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4576 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304577 }
4578
4579 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304580 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304581 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
4582
4583 WMITLV_SET_HDR(&cmd->tlv_header,
4584 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
4585 WMITLV_GET_STRUCT_TLVLEN
4586 (wmi_start_link_stats_cmd_fixed_param));
4587
4588 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
4589 cmd->aggressive_statistics_gathering =
4590 set_req->aggressive_statistics_gathering;
4591
Govind Singhb53420c2016-03-09 14:32:57 +05304592 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
4593 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
4594 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304595
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304596 wmi_mtrace(WMI_START_LINK_STATS_CMDID, NO_SESSION, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304597 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4598 WMI_START_LINK_STATS_CMDID);
4599 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304600 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304601 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304602 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304603 }
4604
Govind Singhb53420c2016-03-09 14:32:57 +05304605 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304606}
4607
4608/**
4609 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
4610 * @wmi_handle:wmi handle
4611 * @get_req:ll stats get request command params
4612 * @addr: mac address
4613 *
Govind Singhb53420c2016-03-09 14:32:57 +05304614 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304615 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304616static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304617 const struct ll_stats_get_params *get_req,
4618 uint8_t addr[IEEE80211_ADDR_LEN])
4619{
4620 wmi_request_link_stats_cmd_fixed_param *cmd;
4621 int32_t len;
4622 wmi_buf_t buf;
4623 uint8_t *buf_ptr;
4624 int ret;
4625
4626 len = sizeof(*cmd);
4627 buf = wmi_buf_alloc(wmi_handle, len);
4628
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05304629 if (!buf) {
4630 WMI_LOGE("%s: buf allocation failed", __func__);
4631 return QDF_STATUS_E_NOMEM;
4632 }
4633
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304635 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304636 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
4637
4638 WMITLV_SET_HDR(&cmd->tlv_header,
4639 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
4640 WMITLV_GET_STRUCT_TLVLEN
4641 (wmi_request_link_stats_cmd_fixed_param));
4642
4643 cmd->request_id = get_req->req_id;
4644 cmd->stats_type = get_req->param_id_mask;
4645 cmd->vdev_id = get_req->sta_id;
4646
4647 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
4648 &cmd->peer_macaddr);
4649
Govind Singhb53420c2016-03-09 14:32:57 +05304650 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08004651 WMI_LOGD("Request ID : %u", cmd->request_id);
4652 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304653 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
Govind Singhb53420c2016-03-09 14:32:57 +05304654 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304655
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304656 wmi_mtrace(WMI_REQUEST_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304657 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4658 WMI_REQUEST_LINK_STATS_CMDID);
4659 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304660 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304661 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304662 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304663 }
4664
Govind Singhb53420c2016-03-09 14:32:57 +05304665 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304666}
Qiwei Cai1ccba222018-05-21 16:49:39 +08004667#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05304668
Govind Singh20c5dac2016-03-07 15:33:31 +05304669/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304670 * send_congestion_cmd_tlv() - send request to fw to get CCA
4671 * @wmi_handle: wmi handle
4672 * @vdev_id: vdev id
4673 *
4674 * Return: CDF status
4675 */
4676static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05304677 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304678{
4679 wmi_buf_t buf;
4680 wmi_request_stats_cmd_fixed_param *cmd;
4681 uint8_t len;
4682 uint8_t *buf_ptr;
4683
4684 len = sizeof(*cmd);
4685 buf = wmi_buf_alloc(wmi_handle, len);
4686 if (!buf) {
4687 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
4688 return QDF_STATUS_E_FAILURE;
4689 }
4690
4691 buf_ptr = wmi_buf_data(buf);
4692 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
4693 WMITLV_SET_HDR(&cmd->tlv_header,
4694 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4695 WMITLV_GET_STRUCT_TLVLEN
4696 (wmi_request_stats_cmd_fixed_param));
4697
4698 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
4699 cmd->vdev_id = vdev_id;
4700 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
4701 cmd->vdev_id, cmd->stats_id);
4702
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304703 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304704 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4705 WMI_REQUEST_STATS_CMDID)) {
4706 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
4707 __func__);
4708 wmi_buf_free(buf);
4709 return QDF_STATUS_E_FAILURE;
4710 }
4711
4712 return QDF_STATUS_SUCCESS;
4713}
4714
4715/**
Govind Singh20c5dac2016-03-07 15:33:31 +05304716 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
4717 * @wmi_handle: wmi handle
4718 * @rssi_req: get RSSI request
4719 *
4720 * Return: CDF status
4721 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304722static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05304723{
4724 wmi_buf_t buf;
4725 wmi_request_stats_cmd_fixed_param *cmd;
4726 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4727
4728 buf = wmi_buf_alloc(wmi_handle, len);
4729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304730 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4731 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304732 }
4733
4734 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4735 WMITLV_SET_HDR(&cmd->tlv_header,
4736 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4737 WMITLV_GET_STRUCT_TLVLEN
4738 (wmi_request_stats_cmd_fixed_param));
4739 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304740 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304741 if (wmi_unified_cmd_send
4742 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304743 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304744 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304745 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304746 }
4747
Govind Singhb53420c2016-03-09 14:32:57 +05304748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304749}
4750
4751/**
4752 * send_snr_cmd_tlv() - get RSSI from fw
4753 * @wmi_handle: wmi handle
4754 * @vdev_id: vdev id
4755 *
4756 * Return: CDF status
4757 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304758static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05304759{
4760 wmi_buf_t buf;
4761 wmi_request_stats_cmd_fixed_param *cmd;
4762 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4763
4764 buf = wmi_buf_alloc(wmi_handle, len);
4765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304766 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304768 }
4769
4770 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4771 cmd->vdev_id = vdev_id;
4772
4773 WMITLV_SET_HDR(&cmd->tlv_header,
4774 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4775 WMITLV_GET_STRUCT_TLVLEN
4776 (wmi_request_stats_cmd_fixed_param));
4777 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304778 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304779 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4780 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304781 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304782 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304783 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304784 }
4785
Govind Singhb53420c2016-03-09 14:32:57 +05304786 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304787}
4788
4789/**
4790 * send_link_status_req_cmd_tlv() - process link status request from UMAC
4791 * @wmi_handle: wmi handle
4792 * @link_status: get link params
4793 *
4794 * Return: CDF status
4795 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304796static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05304797 struct link_status_params *link_status)
4798{
4799 wmi_buf_t buf;
4800 wmi_request_stats_cmd_fixed_param *cmd;
4801 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4802
4803 buf = wmi_buf_alloc(wmi_handle, len);
4804 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4806 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304807 }
4808
4809 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4810 WMITLV_SET_HDR(&cmd->tlv_header,
4811 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4812 WMITLV_GET_STRUCT_TLVLEN
4813 (wmi_request_stats_cmd_fixed_param));
4814 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
4815 cmd->vdev_id = link_status->session_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304816 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304817 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4818 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304819 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304820 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304821 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304822 }
4823
Govind Singhb53420c2016-03-09 14:32:57 +05304824 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304825}
4826
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304827#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05304828/**
4829 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
4830 * @wmi_handle: wmi handler
4831 * @egap_params: pointer to egap_params
4832 *
4833 * Return: 0 for success, otherwise appropriate error code
4834 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304835static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304836 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05304837{
4838 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
4839 wmi_buf_t buf;
4840 int32_t err;
4841
4842 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4843 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304844 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
4845 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05304846 }
4847 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
4848 WMITLV_SET_HDR(&cmd->tlv_header,
4849 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
4850 WMITLV_GET_STRUCT_TLVLEN(
4851 wmi_ap_ps_egap_param_cmd_fixed_param));
4852
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304853 cmd->enable = egap_params->host_enable_egap;
4854 cmd->inactivity_time = egap_params->egap_inactivity_time;
4855 cmd->wait_time = egap_params->egap_wait_time;
4856 cmd->flags = egap_params->egap_feature_flags;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304857 wmi_mtrace(WMI_AP_PS_EGAP_PARAM_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304858 err = wmi_unified_cmd_send(wmi_handle, buf,
4859 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
4860 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05304861 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05304862 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304863 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304864 }
4865
Govind Singhb53420c2016-03-09 14:32:57 +05304866 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304867}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304868#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05304869
4870/**
Govind Singh20c5dac2016-03-07 15:33:31 +05304871 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
4872 * @wmi_handle: wmi handle
4873 * @vdev_id: vdev id
4874 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304875 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05304876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304877static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05304878 uint8_t vdev_id)
4879{
4880 wmi_csa_offload_enable_cmd_fixed_param *cmd;
4881 wmi_buf_t buf;
4882 int32_t len = sizeof(*cmd);
4883
Govind Singhb53420c2016-03-09 14:32:57 +05304884 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05304885 buf = wmi_buf_alloc(wmi_handle, len);
4886 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304887 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304888 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05304889 }
4890 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
4891 WMITLV_SET_HDR(&cmd->tlv_header,
4892 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
4893 WMITLV_GET_STRUCT_TLVLEN
4894 (wmi_csa_offload_enable_cmd_fixed_param));
4895 cmd->vdev_id = vdev_id;
4896 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304897 wmi_mtrace(WMI_CSA_OFFLOAD_ENABLE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304898 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4899 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304900 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05304901 __func__);
4902 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05304903 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304904 }
4905
4906 return 0;
4907}
4908
Naveen Rawat42cd1e62017-05-13 15:56:57 -07004909#ifdef WLAN_FEATURE_CIF_CFR
4910/**
4911 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
4912 * @wmi_handle: wmi handle
4913 * @data_len: len of dma cfg req
4914 * @data: dma cfg req
4915 *
4916 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
4917 */
4918static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
4919 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
4920{
4921 wmi_buf_t buf;
4922 uint8_t *cmd;
4923 QDF_STATUS ret;
4924
4925 WMITLV_SET_HDR(cfg,
4926 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
4927 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
4928
4929 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
4930 if (!buf) {
4931 WMI_LOGE(FL("wmi_buf_alloc failed"));
4932 return QDF_STATUS_E_FAILURE;
4933 }
4934
4935 cmd = (uint8_t *) wmi_buf_data(buf);
4936 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
4937 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
4938 sizeof(*cfg));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304939 wmi_mtrace(WMI_OEM_DMA_RING_CFG_REQ_CMDID, NO_SESSION, 0);
Naveen Rawat42cd1e62017-05-13 15:56:57 -07004940 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
4941 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
4942 if (QDF_IS_STATUS_ERROR(ret)) {
4943 WMI_LOGE(FL(":wmi cmd send failed"));
4944 wmi_buf_free(buf);
4945 }
4946
4947 return ret;
4948}
4949#endif
4950
Govind Singh20c5dac2016-03-07 15:33:31 +05304951/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07004952 * send_start_11d_scan_cmd_tlv() - start 11d scan request
4953 * @wmi_handle: wmi handle
4954 * @start_11d_scan: 11d scan start request parameters
4955 *
4956 * This function request FW to start 11d scan.
4957 *
4958 * Return: QDF status
4959 */
4960static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
4961 struct reg_start_11d_scan_req *start_11d_scan)
4962{
4963 wmi_11d_scan_start_cmd_fixed_param *cmd;
4964 int32_t len;
4965 wmi_buf_t buf;
4966 int ret;
4967
4968 len = sizeof(*cmd);
4969 buf = wmi_buf_alloc(wmi_handle, len);
4970 if (!buf) {
4971 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4972 return QDF_STATUS_E_NOMEM;
4973 }
4974
4975 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
4976
4977 WMITLV_SET_HDR(&cmd->tlv_header,
4978 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
4979 WMITLV_GET_STRUCT_TLVLEN
4980 (wmi_11d_scan_start_cmd_fixed_param));
4981
4982 cmd->vdev_id = start_11d_scan->vdev_id;
4983 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
4984 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
4985
4986 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
4987
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304988 wmi_mtrace(WMI_11D_SCAN_START_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07004989 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4990 WMI_11D_SCAN_START_CMDID);
4991 if (ret) {
4992 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
4993 wmi_buf_free(buf);
4994 return QDF_STATUS_E_FAILURE;
4995 }
4996
4997 return QDF_STATUS_SUCCESS;
4998}
4999
5000/**
5001 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
5002 * @wmi_handle: wmi handle
5003 * @start_11d_scan: 11d scan stop request parameters
5004 *
5005 * This function request FW to stop 11d scan.
5006 *
5007 * Return: QDF status
5008 */
5009static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
5010 struct reg_stop_11d_scan_req *stop_11d_scan)
5011{
5012 wmi_11d_scan_stop_cmd_fixed_param *cmd;
5013 int32_t len;
5014 wmi_buf_t buf;
5015 int ret;
5016
5017 len = sizeof(*cmd);
5018 buf = wmi_buf_alloc(wmi_handle, len);
5019 if (!buf) {
5020 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5021 return QDF_STATUS_E_NOMEM;
5022 }
5023
5024 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
5025
5026 WMITLV_SET_HDR(&cmd->tlv_header,
5027 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
5028 WMITLV_GET_STRUCT_TLVLEN
5029 (wmi_11d_scan_stop_cmd_fixed_param));
5030
5031 cmd->vdev_id = stop_11d_scan->vdev_id;
5032
5033 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
5034
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305035 wmi_mtrace(WMI_11D_SCAN_STOP_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07005036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5037 WMI_11D_SCAN_STOP_CMDID);
5038 if (ret) {
5039 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
5040 wmi_buf_free(buf);
5041 return QDF_STATUS_E_FAILURE;
5042 }
5043
5044 return QDF_STATUS_SUCCESS;
5045}
5046
5047/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305048 * send_start_oem_data_cmd_tlv() - start OEM data request to target
5049 * @wmi_handle: wmi handle
5050 * @startOemDataReq: start request params
5051 *
5052 * Return: CDF status
5053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305054static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07005055 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05305056 uint8_t *data)
5057{
5058 wmi_buf_t buf;
5059 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05305060 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305061
5062 buf = wmi_buf_alloc(wmi_handle,
5063 (data_len + WMI_TLV_HDR_SIZE));
5064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305065 WMI_LOGE(FL("wmi_buf_alloc failed"));
5066 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305067 }
5068
5069 cmd = (uint8_t *) wmi_buf_data(buf);
5070
5071 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
5072 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305073 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05305074 data_len);
5075
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08005076 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05305077 data_len);
5078
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305079 wmi_mtrace(WMI_OEM_REQ_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305080 ret = wmi_unified_cmd_send(wmi_handle, buf,
5081 (data_len +
5082 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
5083
Govind Singh67922e82016-04-01 16:48:57 +05305084 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305085 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305086 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05305087 }
5088
Govind Singh67922e82016-04-01 16:48:57 +05305089 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305090}
5091
5092/**
5093 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
5094 * @wmi_handle: wmi handle
5095 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
5096 *
5097 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
5098 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
5099 * to firmware based on phyerr filtering
5100 * offload status.
5101 *
5102 * Return: 1 success, 0 failure
5103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305104static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05305105send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
5106 bool dfs_phyerr_filter_offload)
5107{
5108 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
5109 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
5110 wmi_buf_t buf;
5111 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305112 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305113
5114
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07005115 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05305116 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05305117 __func__);
5118 len = sizeof(*disable_phyerr_offload_cmd);
5119 buf = wmi_buf_alloc(wmi_handle, len);
5120 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305121 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05305122 return 0;
5123 }
5124 disable_phyerr_offload_cmd =
5125 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
5126 wmi_buf_data(buf);
5127
5128 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
5129 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
5130 WMITLV_GET_STRUCT_TLVLEN
5131 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
5132
5133 /*
5134 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
5135 * to the firmware to disable the phyerror
5136 * filtering offload.
5137 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305138 wmi_mtrace(WMI_DFS_PHYERR_FILTER_DIS_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5140 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305142 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05305143 __func__, ret);
5144 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305145 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305146 }
Govind Singhb53420c2016-03-09 14:32:57 +05305147 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05305148 __func__);
5149 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05305150 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05305151 __func__);
5152
5153 len = sizeof(*enable_phyerr_offload_cmd);
5154 buf = wmi_buf_alloc(wmi_handle, len);
5155 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305156 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5157 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305158 }
5159
5160 enable_phyerr_offload_cmd =
5161 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
5162 wmi_buf_data(buf);
5163
5164 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
5165 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
5166 WMITLV_GET_STRUCT_TLVLEN
5167 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
5168
5169 /*
5170 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
5171 * to the firmware to enable the phyerror
5172 * filtering offload.
5173 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305174 wmi_mtrace(WMI_DFS_PHYERR_FILTER_ENA_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305175 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5176 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
5177
Govind Singh67922e82016-04-01 16:48:57 +05305178 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305179 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05305180 __func__, ret);
5181 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305182 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305183 }
Govind Singhb53420c2016-03-09 14:32:57 +05305184 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05305185 __func__);
5186 }
5187
Govind Singhb53420c2016-03-09 14:32:57 +05305188 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305189}
5190
5191#if !defined(REMOVE_PKT_LOG)
5192/**
5193 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
5194 * @wmi_handle: wmi handle
5195 * @pktlog_event: pktlog event
5196 * @cmd_id: pktlog cmd id
5197 *
5198 * Return: CDF status
5199 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305200static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305201 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05305202 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05305203{
5204 WMI_PKTLOG_EVENT PKTLOG_EVENT;
5205 WMI_CMD_ID CMD_ID;
5206 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
5207 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
5208 int len = 0;
5209 wmi_buf_t buf;
5210
5211 PKTLOG_EVENT = pktlog_event;
5212 CMD_ID = cmd_id;
5213
5214 switch (CMD_ID) {
5215 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
5216 len = sizeof(*cmd);
5217 buf = wmi_buf_alloc(wmi_handle, len);
5218 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305219 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5220 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305221 }
5222 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
5223 wmi_buf_data(buf);
5224 WMITLV_SET_HDR(&cmd->tlv_header,
5225 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
5226 WMITLV_GET_STRUCT_TLVLEN
5227 (wmi_pdev_pktlog_enable_cmd_fixed_param));
5228 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05305229 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
5230 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305231 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5232 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305233 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305234 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5235 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305236 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05305237 goto wmi_send_failed;
5238 }
5239 break;
5240 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
5241 len = sizeof(*disable_cmd);
5242 buf = wmi_buf_alloc(wmi_handle, len);
5243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305244 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5245 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305246 }
5247 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
5248 wmi_buf_data(buf);
5249 WMITLV_SET_HDR(&disable_cmd->tlv_header,
5250 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
5251 WMITLV_GET_STRUCT_TLVLEN
5252 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305253 disable_cmd->pdev_id =
5254 wmi_handle->ops->convert_pdev_id_host_to_target(
5255 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305256 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5258 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305259 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05305260 goto wmi_send_failed;
5261 }
5262 break;
5263 default:
Govind Singhb53420c2016-03-09 14:32:57 +05305264 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05305265 break;
5266 }
5267
Govind Singhb53420c2016-03-09 14:32:57 +05305268 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305269
5270wmi_send_failed:
5271 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305272 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305273}
5274#endif /* REMOVE_PKT_LOG */
5275
5276/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305277 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
5278 * @wmi_handle: wmi handle
5279 * @preq: stats ext params
5280 *
5281 * Return: CDF status
5282 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305283static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305284 struct stats_ext_params *preq)
5285{
Govind Singh67922e82016-04-01 16:48:57 +05305286 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305287 wmi_req_stats_ext_cmd_fixed_param *cmd;
5288 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05305289 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05305290 uint8_t *buf_ptr;
5291
5292 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
5293
5294 buf = wmi_buf_alloc(wmi_handle, len);
5295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305296 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305297 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305298 }
5299
5300 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5301 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
5302
5303 WMITLV_SET_HDR(&cmd->tlv_header,
5304 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
5305 WMITLV_GET_STRUCT_TLVLEN
5306 (wmi_req_stats_ext_cmd_fixed_param));
5307 cmd->vdev_id = preq->vdev_id;
5308 cmd->data_len = preq->request_data_len;
5309
Govind Singhb53420c2016-03-09 14:32:57 +05305310 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05305311 __func__, preq->request_data_len, preq->vdev_id);
5312
5313 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
5314 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
5315
5316 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305317 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05305318
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305319 wmi_mtrace(WMI_REQUEST_STATS_EXT_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305320 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5321 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305322 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305323 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05305324 ret);
5325 wmi_buf_free(buf);
5326 }
5327
5328 return ret;
5329}
5330
5331/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305332 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
5333 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07005334 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05305335 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305336 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05305337 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07005338static QDF_STATUS
5339send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
5340 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05305341{
5342 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
5343 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305344 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05305345
5346 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5347 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305348 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05305349 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05305350 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305351 }
5352
5353 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05305354
5355 WMITLV_SET_HDR(&cmd->tlv_header,
5356 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
5357 WMITLV_GET_STRUCT_TLVLEN
5358 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07005359 cmd->vdev_id = params->vdev_id;
5360 cmd->enable = params->dhcp_offload_enabled;
5361 cmd->num_client = params->dhcp_client_num;
5362 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05305363 cmd->start_lsb = 0;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305364 wmi_mtrace(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID, cmd->vdev_id, 0);
Govind Singh67922e82016-04-01 16:48:57 +05305365 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05305366 sizeof(*cmd),
5367 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305368 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305369 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05305370 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05305371 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305372 }
Govind Singhb53420c2016-03-09 14:32:57 +05305373 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07005374 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05305375
5376 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05305377}
5378
5379/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305380 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
5381 * @wmi_handle: wmi handle
5382 * @param: pointer to pdev regdomain params
5383 *
5384 * Return: 0 for success or error code
5385 */
5386static QDF_STATUS
5387send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
5388 struct pdev_set_regdomain_params *param)
5389{
5390 wmi_buf_t buf;
5391 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
5392 int32_t len = sizeof(*cmd);
5393
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305394 buf = wmi_buf_alloc(wmi_handle, len);
5395 if (!buf) {
5396 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5397 return QDF_STATUS_E_NOMEM;
5398 }
5399 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
5400 WMITLV_SET_HDR(&cmd->tlv_header,
5401 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
5402 WMITLV_GET_STRUCT_TLVLEN
5403 (wmi_pdev_set_regdomain_cmd_fixed_param));
5404
5405 cmd->reg_domain = param->currentRDinuse;
5406 cmd->reg_domain_2G = param->currentRD2G;
5407 cmd->reg_domain_5G = param->currentRD5G;
5408 cmd->conformance_test_limit_2G = param->ctl_2G;
5409 cmd->conformance_test_limit_5G = param->ctl_5G;
5410 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305411 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5412 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305413
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305414 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305415 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5416 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
5417 WMI_LOGE("%s: Failed to send pdev set regdomain command",
5418 __func__);
5419 wmi_buf_free(buf);
5420 return QDF_STATUS_E_FAILURE;
5421 }
5422
5423 return QDF_STATUS_SUCCESS;
5424}
5425
5426/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305427 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
5428 * @wmi_handle: wmi handle
5429 * @reg_dmn: reg domain
5430 * @regdmn2G: 2G reg domain
5431 * @regdmn5G: 5G reg domain
5432 * @ctl2G: 2G test limit
5433 * @ctl5G: 5G test limit
5434 *
5435 * Return: none
5436 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305437static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305438 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05305439 uint16_t regdmn5G, uint8_t ctl2G,
5440 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05305441{
5442 wmi_buf_t buf;
5443 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
5444 int32_t len = sizeof(*cmd);
5445
5446
5447 buf = wmi_buf_alloc(wmi_handle, len);
5448 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305449 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5450 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305451 }
5452 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
5453 WMITLV_SET_HDR(&cmd->tlv_header,
5454 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
5455 WMITLV_GET_STRUCT_TLVLEN
5456 (wmi_pdev_set_regdomain_cmd_fixed_param));
5457 cmd->reg_domain = reg_dmn;
5458 cmd->reg_domain_2G = regdmn2G;
5459 cmd->reg_domain_5G = regdmn5G;
5460 cmd->conformance_test_limit_2G = ctl2G;
5461 cmd->conformance_test_limit_5G = ctl5G;
5462
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305463 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305464 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5465 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305466 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05305467 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305468 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305469 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305470 }
5471
Govind Singhb53420c2016-03-09 14:32:57 +05305472 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305473}
5474
Sathish Kumar497bef42017-03-01 14:02:36 +05305475/**
Sathish Kumar6011c742017-11-08 14:49:58 +05305476 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
5477 * @param: param sent from the host side
5478 * @cmd: param to be sent to the fw side
5479 */
5480static inline void copy_custom_aggr_bitmap(
5481 struct set_custom_aggr_size_params *param,
5482 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
5483{
5484 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
5485 param->ac);
5486 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
5487 param->aggr_type);
5488 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
5489 param->tx_aggr_size_disable);
5490 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
5491 param->rx_aggr_size_disable);
5492 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
5493 param->tx_ac_enable);
5494}
5495
5496/**
5497 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
5498 * @wmi_handle: wmi handle
5499 * @param: pointer to hold custom aggr size params
5500 *
5501 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5502 */
5503static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
5504 wmi_unified_t wmi_handle,
5505 struct set_custom_aggr_size_params *param)
5506{
5507 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
5508 wmi_buf_t buf;
5509 int32_t len = sizeof(*cmd);
5510
5511 buf = wmi_buf_alloc(wmi_handle, len);
5512 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305513 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar6011c742017-11-08 14:49:58 +05305514 return QDF_STATUS_E_FAILURE;
5515 }
5516 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
5517 wmi_buf_data(buf);
5518 WMITLV_SET_HDR(&cmd->tlv_header,
5519 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
5520 WMITLV_GET_STRUCT_TLVLEN(
5521 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
5522 cmd->vdev_id = param->vdev_id;
5523 cmd->tx_aggr_size = param->tx_aggr_size;
5524 cmd->rx_aggr_size = param->rx_aggr_size;
5525 copy_custom_aggr_bitmap(param, cmd);
5526
5527 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
5528 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
5529 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305530 "tx_ac_enable=0x%X",
Sathish Kumar6011c742017-11-08 14:49:58 +05305531 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
5532 param->ac, param->aggr_type, param->tx_aggr_size_disable,
5533 param->rx_aggr_size_disable, param->tx_ac_enable);
5534
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305535 wmi_mtrace(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID, cmd->vdev_id, 0);
Sathish Kumar6011c742017-11-08 14:49:58 +05305536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5537 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305538 WMI_LOGE("Seting custom aggregation size failed");
Sathish Kumar6011c742017-11-08 14:49:58 +05305539 wmi_buf_free(buf);
5540 return QDF_STATUS_E_FAILURE;
5541 }
5542
5543 return QDF_STATUS_SUCCESS;
5544}
5545
5546/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305547 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
5548 * @param wmi_handle : handle to WMI.
5549 * @param param : pointer to tx antenna param
5550 *
5551 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5552 */
5553
5554static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
5555 struct set_qdepth_thresh_params *param)
5556{
5557 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
5558 wmi_msduq_qdepth_thresh_update *cmd_update;
5559 wmi_buf_t buf;
5560 int32_t len = 0;
5561 int i;
5562 uint8_t *buf_ptr;
5563 QDF_STATUS ret;
5564
5565 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305566 WMI_LOGE("%s: Invalid Update Count!", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305567 return QDF_STATUS_E_INVAL;
5568 }
5569
5570 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5571 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
5572 param->num_of_msduq_updates);
5573 buf = wmi_buf_alloc(wmi_handle, len);
5574
5575 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305576 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305577 return QDF_STATUS_E_NOMEM;
5578 }
5579
5580 buf_ptr = (uint8_t *)wmi_buf_data(buf);
5581 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
5582 buf_ptr;
5583
5584 WMITLV_SET_HDR(&cmd->tlv_header,
5585 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
5586 , WMITLV_GET_STRUCT_TLVLEN(
5587 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
5588
5589 cmd->pdev_id =
5590 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
5591 cmd->vdev_id = param->vdev_id;
5592 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
5593 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
5594
5595 buf_ptr += sizeof(
5596 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
5597 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5598 param->num_of_msduq_updates *
5599 sizeof(wmi_msduq_qdepth_thresh_update));
5600 buf_ptr += WMI_TLV_HDR_SIZE;
5601 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
5602
5603 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
5604 WMITLV_SET_HDR(&cmd_update->tlv_header,
5605 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
5606 WMITLV_GET_STRUCT_TLVLEN(
5607 wmi_msduq_qdepth_thresh_update));
5608 cmd_update->tid_num = param->update_params[i].tid_num;
5609 cmd_update->msduq_update_mask =
5610 param->update_params[i].msduq_update_mask;
5611 cmd_update->qdepth_thresh_value =
5612 param->update_params[i].qdepth_thresh_value;
5613 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
5614 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305615 " update mask=0x%X thresh val=0x%X",
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305616 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
5617 cmd->peer_mac_address.mac_addr31to0,
5618 cmd->peer_mac_address.mac_addr47to32,
5619 cmd_update->msduq_update_mask,
5620 cmd_update->qdepth_thresh_value);
5621 cmd_update++;
5622 }
5623
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305624 wmi_mtrace(WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID,
5625 cmd->vdev_id, 0);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5627 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
5628
5629 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305630 WMI_LOGE(" %s :WMI Failed", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305631 wmi_buf_free(buf);
5632 }
5633
5634 return ret;
5635}
5636
5637/**
Sathish Kumar497bef42017-03-01 14:02:36 +05305638 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
5639 * @wmi_handle: wmi handle
5640 * @param: pointer to hold vap dscp tid map param
5641 *
5642 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5643 */
5644static QDF_STATUS
5645send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
5646 struct vap_dscp_tid_map_params *param)
5647{
5648 wmi_buf_t buf;
5649 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
5650 int32_t len = sizeof(*cmd);
5651
5652 buf = wmi_buf_alloc(wmi_handle, len);
5653 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305654 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar497bef42017-03-01 14:02:36 +05305655 return QDF_STATUS_E_FAILURE;
5656 }
5657
5658 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
5659 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +05305660 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +05305661
5662 cmd->vdev_id = param->vdev_id;
5663 cmd->enable_override = 0;
5664
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305665 WMI_LOGI("Setting dscp for vap id: %d", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305666 wmi_mtrace(WMI_VDEV_SET_DSCP_TID_MAP_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +05305667 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5668 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305669 WMI_LOGE("Failed to set dscp cmd");
Sathish Kumar497bef42017-03-01 14:02:36 +05305670 wmi_buf_free(buf);
5671 return QDF_STATUS_E_FAILURE;
5672 }
5673
5674 return QDF_STATUS_SUCCESS;
5675}
5676
5677/**
Sathish Kumar02c3b542017-02-22 17:24:45 +05305678 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
5679 * @wmi_handle: wmi handle
5680 * @param: pointer to hold fwtest param
5681 *
5682 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5683 */
5684static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
5685 struct set_fwtest_params *param)
5686{
5687 wmi_fwtest_set_param_cmd_fixed_param *cmd;
5688 wmi_buf_t buf;
5689 int32_t len = sizeof(*cmd);
5690
5691 buf = wmi_buf_alloc(wmi_handle, len);
5692
5693 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305694 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar02c3b542017-02-22 17:24:45 +05305695 return QDF_STATUS_E_FAILURE;
5696 }
5697
5698 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
5699 WMITLV_SET_HDR(&cmd->tlv_header,
5700 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
5701 WMITLV_GET_STRUCT_TLVLEN(
5702 wmi_fwtest_set_param_cmd_fixed_param));
5703 cmd->param_id = param->arg;
5704 cmd->param_value = param->value;
5705
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305706 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +05305707 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305708 WMI_LOGE("Setting FW test param failed");
Sathish Kumar02c3b542017-02-22 17:24:45 +05305709 wmi_buf_free(buf);
5710 return QDF_STATUS_E_FAILURE;
5711 }
5712
5713 return QDF_STATUS_SUCCESS;
5714}
5715
5716/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305717 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
5718 *
5719 * @param wmi_handle : handle to WMI.
5720 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5721 */
5722static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
5723{
5724 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
5725 wmi_buf_t buf;
5726 QDF_STATUS ret;
5727 int32_t len;
5728
5729 len = sizeof(*cmd);
5730
5731 buf = wmi_buf_alloc(wmi_handle, len);
5732 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305733 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305734 return QDF_STATUS_E_FAILURE;
5735 }
5736
5737 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
5738 WMITLV_SET_HDR(&cmd->tlv_header,
5739 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
5740 WMITLV_GET_STRUCT_TLVLEN(
5741 wmi_pdev_dfs_disable_cmd_fixed_param));
5742 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305743 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5744 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305745
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305746 wmi_mtrace(WMI_PDEV_DFS_DISABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305747 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5748 WMI_PDEV_DFS_DISABLE_CMDID);
5749
5750 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305751 WMI_LOGE("Sending PDEV DFS disable cmd failed");
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305752 wmi_buf_free(buf);
5753 }
5754
5755 return ret;
5756}
5757
5758/**
5759 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
5760 *
5761 * @param wmi_handle : handle to WMI.
5762 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5763 */
5764static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
5765{
5766 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
5767 wmi_buf_t buf;
5768 QDF_STATUS ret;
5769 int32_t len;
5770
5771 len = sizeof(*cmd);
5772
5773 buf = wmi_buf_alloc(wmi_handle, len);
5774 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305775 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305776 return QDF_STATUS_E_FAILURE;
5777 }
5778
5779 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
5780 WMITLV_SET_HDR(&cmd->tlv_header,
5781 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
5782 WMITLV_GET_STRUCT_TLVLEN(
5783 wmi_pdev_dfs_enable_cmd_fixed_param));
5784 /* Reserved for future use */
5785 cmd->reserved0 = 0;
5786
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305787 wmi_mtrace(WMI_PDEV_DFS_ENABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305788 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5789 WMI_PDEV_DFS_ENABLE_CMDID);
5790
5791 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305792 WMI_LOGE("Sending PDEV DFS enable cmd failed");
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305793 wmi_buf_free(buf);
5794 }
5795
5796 return ret;
5797}
5798
5799/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305800 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
5801 * to fw
5802 * @wmi_handle: wmi handle
5803 * @param: pointer to hold periodic chan stats param
5804 *
5805 * Return: 0 for success or error code
5806 */
5807static QDF_STATUS
5808send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
5809 struct periodic_chan_stats_params *param)
5810{
5811 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
5812 wmi_buf_t buf;
5813 QDF_STATUS ret;
5814 int32_t len;
5815
5816 len = sizeof(*cmd);
5817
5818 buf = wmi_buf_alloc(wmi_handle, len);
5819 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305820 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305821 return QDF_STATUS_E_FAILURE;
5822 }
5823
5824 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
5825 wmi_buf_data(buf);
5826 WMITLV_SET_HDR(&cmd->tlv_header,
5827 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
5828 WMITLV_GET_STRUCT_TLVLEN(
5829 wmi_set_periodic_channel_stats_config_fixed_param));
5830 cmd->enable = param->enable;
5831 cmd->stats_period = param->stats_period;
5832 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5833 param->pdev_id);
5834
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305835 wmi_mtrace(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID, NO_SESSION, 0);
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305836 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5837 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
5838
5839 if (ret != 0) {
5840 WMI_LOGE("Sending periodic chan stats config failed");
5841 wmi_buf_free(buf);
5842 }
5843
5844 return ret;
5845}
5846
5847/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305848 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
5849 * command to fw
5850 * @wmi_handle: wmi handle
5851 * @param: pointer to hold spectral config parameter
5852 *
5853 * Return: 0 for success or error code
5854 */
5855static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
5856 struct vdev_spectral_configure_params *param)
5857{
5858 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
5859 wmi_buf_t buf;
5860 QDF_STATUS ret;
5861 int32_t len;
5862
5863 len = sizeof(*cmd);
5864 buf = wmi_buf_alloc(wmi_handle, len);
5865 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305866 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305867 return QDF_STATUS_E_FAILURE;
5868 }
5869
5870 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
5871 WMITLV_SET_HDR(&cmd->tlv_header,
5872 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
5873 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +05305874 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305875
5876 cmd->vdev_id = param->vdev_id;
5877 cmd->spectral_scan_count = param->count;
5878 cmd->spectral_scan_period = param->period;
5879 cmd->spectral_scan_priority = param->spectral_pri;
5880 cmd->spectral_scan_fft_size = param->fft_size;
5881 cmd->spectral_scan_gc_ena = param->gc_enable;
5882 cmd->spectral_scan_restart_ena = param->restart_enable;
5883 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
5884 cmd->spectral_scan_init_delay = param->init_delay;
5885 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
5886 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
5887 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
5888 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
5889 cmd->spectral_scan_rssi_thr = param->rssi_thr;
5890 cmd->spectral_scan_pwr_format = param->pwr_format;
5891 cmd->spectral_scan_rpt_mode = param->rpt_mode;
5892 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +05305893 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305894 cmd->spectral_scan_chn_mask = param->chn_mask;
5895
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305896 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305897 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5898 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
5899
5900 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305901 WMI_LOGE("Sending set quiet cmd failed");
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305902 wmi_buf_free(buf);
5903 }
5904
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305905 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305906 __func__);
5907
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305908 WMI_LOGI("vdev_id = %u"
5909 "spectral_scan_count = %u"
5910 "spectral_scan_period = %u"
5911 "spectral_scan_priority = %u"
5912 "spectral_scan_fft_size = %u"
5913 "spectral_scan_gc_ena = %u"
5914 "spectral_scan_restart_ena = %u"
5915 "spectral_scan_noise_floor_ref = %u"
5916 "spectral_scan_init_delay = %u"
5917 "spectral_scan_nb_tone_thr = %u"
5918 "spectral_scan_str_bin_thr = %u"
5919 "spectral_scan_wb_rpt_mode = %u"
5920 "spectral_scan_rssi_rpt_mode = %u"
5921 "spectral_scan_rssi_thr = %u"
5922 "spectral_scan_pwr_format = %u"
5923 "spectral_scan_rpt_mode = %u"
5924 "spectral_scan_bin_scale = %u"
5925 "spectral_scan_dBm_adj = %u"
5926 "spectral_scan_chn_mask = %u",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305927 param->vdev_id,
5928 param->count,
5929 param->period,
5930 param->spectral_pri,
5931 param->fft_size,
5932 param->gc_enable,
5933 param->restart_enable,
5934 param->noise_floor_ref,
5935 param->init_delay,
5936 param->nb_tone_thr,
5937 param->str_bin_thr,
5938 param->wb_rpt_mode,
5939 param->rssi_rpt_mode,
5940 param->rssi_thr,
5941 param->pwr_format,
5942 param->rpt_mode,
5943 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +05305944 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305945 param->chn_mask);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305946 WMI_LOGI("%s: Status: %d\n", __func__, ret);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305947
5948 return ret;
5949}
5950
5951/**
5952 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
5953 * command to fw
5954 * @wmi_handle: wmi handle
5955 * @param: pointer to hold spectral enable parameter
5956 *
5957 * Return: 0 for success or error code
5958 */
5959static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
5960 struct vdev_spectral_enable_params *param)
5961{
5962 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
5963 wmi_buf_t buf;
5964 QDF_STATUS ret;
5965 int32_t len;
5966
5967 len = sizeof(*cmd);
5968 buf = wmi_buf_alloc(wmi_handle, len);
5969 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305970 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305971 return QDF_STATUS_E_FAILURE;
5972 }
5973
5974 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
5975 WMITLV_SET_HDR(&cmd->tlv_header,
5976 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
5977 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +05305978 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305979
5980 cmd->vdev_id = param->vdev_id;
5981
5982 if (param->active_valid) {
5983 cmd->trigger_cmd = param->active ? 1 : 2;
5984 /* 1: Trigger, 2: Clear Trigger */
5985 } else {
5986 cmd->trigger_cmd = 0; /* 0: Ignore */
5987 }
5988
5989 if (param->enabled_valid) {
5990 cmd->enable_cmd = param->enabled ? 1 : 2;
5991 /* 1: Enable 2: Disable */
5992 } else {
5993 cmd->enable_cmd = 0; /* 0: Ignore */
5994 }
5995
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305996 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305997 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5998 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
5999
6000 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306001 WMI_LOGE("Sending scan enable CMD failed");
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306002 wmi_buf_free(buf);
6003 }
6004
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306005 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306006
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306007 WMI_LOGI("vdev_id = %u"
6008 "trigger_cmd = %u"
6009 "enable_cmd = %u",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306010 cmd->vdev_id,
6011 cmd->trigger_cmd,
6012 cmd->enable_cmd);
6013
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306014 WMI_LOGI("%s: Status: %d\n", __func__, ret);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306015
6016 return ret;
6017}
6018
6019/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306020 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
6021 * @param wmi_handle : handle to WMI.
6022 * @param param : pointer to hold thermal mitigation param
6023 *
6024 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
6025 */
6026static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
6027 wmi_unified_t wmi_handle,
6028 struct thermal_mitigation_params *param)
6029{
6030 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
6031 wmi_therm_throt_level_config_info *lvl_conf = NULL;
6032 wmi_buf_t buf = NULL;
6033 uint8_t *buf_ptr = NULL;
6034 int error;
6035 int32_t len;
6036 int i;
6037
6038 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
6039 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
6040
6041 buf = wmi_buf_alloc(wmi_handle, len);
6042 if (!buf) {
6043 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
6044 return QDF_STATUS_E_NOMEM;
6045 }
6046 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
6047
6048 /* init fixed params */
6049 WMITLV_SET_HDR(tt_conf,
6050 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
6051 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
6052
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05306053 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
6054 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306055 tt_conf->enable = param->enable;
6056 tt_conf->dc = param->dc;
6057 tt_conf->dc_per_event = param->dc_per_event;
6058 tt_conf->therm_throt_levels = THERMAL_LEVELS;
6059
6060 buf_ptr = (uint8_t *) ++tt_conf;
6061 /* init TLV params */
6062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6063 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
6064
6065 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
6066 for (i = 0; i < THERMAL_LEVELS; i++) {
6067 WMITLV_SET_HDR(&lvl_conf->tlv_header,
6068 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
6069 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
6070 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
6071 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
6072 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
6073 lvl_conf->prio = param->levelconf[i].priority;
6074 lvl_conf++;
6075 }
6076
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306077 wmi_mtrace(WMI_THERM_THROT_SET_CONF_CMDID, NO_SESSION, 0);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306078 error = wmi_unified_cmd_send(wmi_handle, buf, len,
6079 WMI_THERM_THROT_SET_CONF_CMDID);
6080 if (QDF_IS_STATUS_ERROR(error)) {
6081 wmi_buf_free(buf);
6082 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
6083 }
6084
6085 return error;
6086}
6087
6088/**
Sathish Kumar80f4f382017-04-24 11:36:00 +05306089 * send_coex_config_cmd_tlv() - send coex config command to fw
6090 * @wmi_handle: wmi handle
6091 * @param: pointer to coex config param
6092 *
6093 * Return: 0 for success or error code
6094 */
6095static QDF_STATUS
6096send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
6097 struct coex_config_params *param)
6098{
6099 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
6100 wmi_buf_t buf;
6101 QDF_STATUS ret;
6102 int32_t len;
6103
6104 len = sizeof(*cmd);
6105 buf = wmi_buf_alloc(wmi_handle, len);
6106 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306107 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumar80f4f382017-04-24 11:36:00 +05306108 return QDF_STATUS_E_FAILURE;
6109 }
6110
6111 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
6112 WMITLV_SET_HDR(&cmd->tlv_header,
6113 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
6114 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +05306115 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +05306116
6117 cmd->vdev_id = param->vdev_id;
6118 cmd->config_type = param->config_type;
6119 cmd->config_arg1 = param->config_arg1;
6120 cmd->config_arg2 = param->config_arg2;
6121 cmd->config_arg3 = param->config_arg3;
6122 cmd->config_arg4 = param->config_arg4;
6123 cmd->config_arg5 = param->config_arg5;
6124 cmd->config_arg6 = param->config_arg6;
6125
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306126 wmi_mtrace(WMI_COEX_CONFIG_CMDID, cmd->vdev_id, 0);
Sathish Kumar80f4f382017-04-24 11:36:00 +05306127 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6128 WMI_COEX_CONFIG_CMDID);
6129
6130 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306131 WMI_LOGE("Sending COEX CONFIG CMD failed");
Sathish Kumar80f4f382017-04-24 11:36:00 +05306132 wmi_buf_free(buf);
6133 }
6134
6135 return ret;
6136}
6137
Kiran Venkatappa3619e662018-04-04 14:31:43 +05306138#ifdef WLAN_SUPPORT_TWT
6139static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
6140 target_resource_config *tgt_res_cfg)
6141{
6142 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
6143 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
6144}
6145#else
6146static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
6147 target_resource_config *tgt_res_cfg)
6148{
6149 resource_cfg->twt_ap_pdev_count = 0;
6150 resource_cfg->twt_ap_sta_count = 0;
6151}
6152#endif
6153
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006154static
Govind Singh9ddd5162016-03-07 16:30:32 +05306155void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05306156 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05306157{
Govind Singhe7f2f342016-05-23 12:12:52 +05306158 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05306159 resource_cfg->num_peers = tgt_res_cfg->num_peers;
6160 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
6161 resource_cfg->num_offload_reorder_buffs =
6162 tgt_res_cfg->num_offload_reorder_buffs;
6163 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
6164 resource_cfg->num_tids = tgt_res_cfg->num_tids;
6165 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
6166 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
6167 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
6168 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
6169 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
6170 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
6171 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
6172 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
6173 resource_cfg->scan_max_pending_req =
6174 tgt_res_cfg->scan_max_pending_req;
6175 resource_cfg->bmiss_offload_max_vdev =
6176 tgt_res_cfg->bmiss_offload_max_vdev;
6177 resource_cfg->roam_offload_max_vdev =
6178 tgt_res_cfg->roam_offload_max_vdev;
6179 resource_cfg->roam_offload_max_ap_profiles =
6180 tgt_res_cfg->roam_offload_max_ap_profiles;
6181 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
6182 resource_cfg->num_mcast_table_elems =
6183 tgt_res_cfg->num_mcast_table_elems;
6184 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
6185 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
6186 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
6187 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
6188 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
6189 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
6190 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
6191 resource_cfg->vow_config = tgt_res_cfg->vow_config;
6192 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
6193 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
6194 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
6195 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
6196 resource_cfg->num_tdls_conn_table_entries =
6197 tgt_res_cfg->num_tdls_conn_table_entries;
6198 resource_cfg->beacon_tx_offload_max_vdev =
6199 tgt_res_cfg->beacon_tx_offload_max_vdev;
6200 resource_cfg->num_multicast_filter_entries =
6201 tgt_res_cfg->num_multicast_filter_entries;
6202 resource_cfg->num_wow_filters =
6203 tgt_res_cfg->num_wow_filters;
6204 resource_cfg->num_keep_alive_pattern =
6205 tgt_res_cfg->num_keep_alive_pattern;
6206 resource_cfg->keep_alive_pattern_size =
6207 tgt_res_cfg->keep_alive_pattern_size;
6208 resource_cfg->max_tdls_concurrent_sleep_sta =
6209 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
6210 resource_cfg->max_tdls_concurrent_buffer_sta =
6211 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
6212 resource_cfg->wmi_send_separate =
6213 tgt_res_cfg->wmi_send_separate;
6214 resource_cfg->num_ocb_vdevs =
6215 tgt_res_cfg->num_ocb_vdevs;
6216 resource_cfg->num_ocb_channels =
6217 tgt_res_cfg->num_ocb_channels;
6218 resource_cfg->num_ocb_schedules =
6219 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +05306220 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05306221 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
6222 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +05306223 resource_cfg->max_num_dbs_scan_duty_cycle =
6224 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -08006225 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -08006226 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
6227 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07006228 resource_cfg->max_bssid_indicator = tgt_res_cfg->max_bssid_indicator;
Mukul Sharmad7c9e332017-11-02 17:42:36 +05306229 if (tgt_res_cfg->atf_config)
6230 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
6231 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
6232 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
6233 resource_cfg->flag1, 1);
6234 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
6235 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
6236 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +05306237 if (tgt_res_cfg->cce_disable)
6238 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Aditya Sathish800c7372018-10-02 11:02:55 +05306239 if (tgt_res_cfg->eapol_minrate_set) {
6240 WMI_RSRC_CFG_FLAG_EAPOL_REKEY_MINRATE_SUPPORT_ENABLE_SET(
6241 resource_cfg->flag1, 1);
6242 if (tgt_res_cfg->eapol_minrate_ac_set != 3) {
6243 WMI_RSRC_CFG_FLAG_EAPOL_AC_OVERRIDE_VALID_SET(
6244 resource_cfg->flag1, 1);
6245 WMI_RSRC_CFG_FLAG_EAPOL_AC_OVERRIDE_SET(
6246 resource_cfg->flag1,
6247 tgt_res_cfg->eapol_minrate_ac_set);
6248 }
6249 }
Kiran Venkatappa3619e662018-04-04 14:31:43 +05306250
6251 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Chaithanya Garrepallibdfea2b2018-09-12 17:02:31 +05306252 resource_cfg->peer_map_unmap_v2_support =
6253 tgt_res_cfg->peer_map_unmap_v2;
Govind Singh9ddd5162016-03-07 16:30:32 +05306254}
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306255
6256/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
6257 * @wmi_handle: pointer to wmi handle
6258 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -07006259 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306260 * @param: point host parameters for init command
6261 *
6262 * Return: Updated pointer of buf_ptr.
6263 */
6264static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
6265 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
6266{
6267 uint16_t idx;
6268
6269 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
6270 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
6271 wmi_pdev_band_to_mac *band_to_mac;
6272
6273 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
6274 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
6275 sizeof(wmi_resource_config) +
6276 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
6277 sizeof(wlan_host_memory_chunk)));
6278
6279 WMITLV_SET_HDR(&hw_mode->tlv_header,
6280 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
6281 (WMITLV_GET_STRUCT_TLVLEN
6282 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
6283
6284 hw_mode->hw_mode_index = param->hw_mode_id;
6285 hw_mode->num_band_to_mac = param->num_band_to_mac;
6286
6287 buf_ptr = (uint8_t *) (hw_mode + 1);
6288 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
6289 WMI_TLV_HDR_SIZE);
6290 for (idx = 0; idx < param->num_band_to_mac; idx++) {
6291 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
6292 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
6293 WMITLV_GET_STRUCT_TLVLEN
6294 (wmi_pdev_band_to_mac));
6295 band_to_mac[idx].pdev_id =
6296 wmi_handle->ops->convert_pdev_id_host_to_target(
6297 param->band_to_mac[idx].pdev_id);
6298 band_to_mac[idx].start_freq =
6299 param->band_to_mac[idx].start_freq;
6300 band_to_mac[idx].end_freq =
6301 param->band_to_mac[idx].end_freq;
6302 }
6303 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
6304 (param->num_band_to_mac *
6305 sizeof(wmi_pdev_band_to_mac)) +
6306 WMI_TLV_HDR_SIZE;
6307
6308 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6309 (param->num_band_to_mac *
6310 sizeof(wmi_pdev_band_to_mac)));
6311 }
6312
6313 return buf_ptr;
6314}
6315
6316static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
6317 wmi_init_cmd_fixed_param *cmd)
6318{
6319 int num_whitelist;
6320 wmi_abi_version my_vers;
6321
6322 num_whitelist = sizeof(version_whitelist) /
6323 sizeof(wmi_whitelist_version_info);
6324 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
6325 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
6326 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
6327 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
6328 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
6329 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
6330
6331 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
6332 &my_vers,
6333 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
6334 &cmd->host_abi_vers);
6335
6336 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
6337 __func__,
6338 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
6339 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
6340 cmd->host_abi_vers.abi_version_ns_0,
6341 cmd->host_abi_vers.abi_version_ns_1,
6342 cmd->host_abi_vers.abi_version_ns_2,
6343 cmd->host_abi_vers.abi_version_ns_3);
6344
6345 /* Save version sent from host -
6346 * Will be used to check ready event
6347 */
6348 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
6349 sizeof(wmi_abi_version));
6350}
6351
Sathish Kumarfd347372017-02-13 12:29:09 +05306352static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05306353{
6354 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
6355 wmi_service_ready_event_fixed_param *ev;
6356
6357
6358 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
6359
6360 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
6361 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05306362 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05306363
6364 /*Save fw version from service ready message */
6365 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05306366 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306367 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306368
Govind Singhb53420c2016-03-09 14:32:57 +05306369 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05306370}
6371
6372/**
6373 * wmi_unified_save_fw_version_cmd() - save fw version
6374 * @wmi_handle: pointer to wmi handle
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306375 * @res_cfg: resource config
Govind Singh9ddd5162016-03-07 16:30:32 +05306376 * @num_mem_chunks: no of mem chunck
6377 * @mem_chunk: pointer to mem chunck structure
6378 *
6379 * This function sends IE information to firmware
6380 *
Govind Singhb53420c2016-03-09 14:32:57 +05306381 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05306382 *
6383 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306384static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05306385 void *evt_buf)
6386{
6387 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6388 wmi_ready_event_fixed_param *ev = NULL;
6389
6390 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
6391 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306392 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
6393 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306394 &ev->fw_abi_vers)) {
6395 /*
6396 * Error: Our host version and the given firmware version
6397 * are incompatible.
6398 **/
Govind Singhb53420c2016-03-09 14:32:57 +05306399 WMI_LOGD("%s: Error: Incompatible WMI version."
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306400 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05306401 __func__,
6402 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
6403 abi_version_0),
6404 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
6405 abi_version_0),
6406 wmi_handle->final_abi_vers.abi_version_ns_0,
6407 wmi_handle->final_abi_vers.abi_version_ns_1,
6408 wmi_handle->final_abi_vers.abi_version_ns_2,
6409 wmi_handle->final_abi_vers.abi_version_ns_3,
6410 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
6411 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
6412 ev->fw_abi_vers.abi_version_ns_0,
6413 ev->fw_abi_vers.abi_version_ns_1,
6414 ev->fw_abi_vers.abi_version_ns_2,
6415 ev->fw_abi_vers.abi_version_ns_3);
6416
Govind Singhb53420c2016-03-09 14:32:57 +05306417 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05306418 }
Govind Singhb53420c2016-03-09 14:32:57 +05306419 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306420 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05306421 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306422 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +05306423
Govind Singhb53420c2016-03-09 14:32:57 +05306424 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05306425}
Govind Singha4836fd2016-03-07 16:45:38 +05306426
6427/**
Govind Singha4836fd2016-03-07 16:45:38 +05306428 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
6429 * @handle: wmi handle
6430 * @event: Event received from FW
6431 * @len: Length of the event
6432 *
6433 * Enables the low frequency events and disables the high frequency
6434 * events. Bit 17 indicates if the event if low/high frequency.
6435 * 1 - high frequency, 0 - low frequency
6436 *
6437 * Return: 0 on successfully enabling/disabling the events
6438 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306439static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05306440 uint8_t *event,
6441 uint32_t len)
6442{
6443 uint32_t num_of_diag_events_logs;
6444 wmi_diag_event_log_config_fixed_param *cmd;
6445 wmi_buf_t buf;
6446 uint8_t *buf_ptr;
6447 uint32_t *cmd_args, *evt_args;
6448 uint32_t buf_len, i;
6449
6450 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
6451 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
6452
Govind Singhb53420c2016-03-09 14:32:57 +05306453 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05306454
6455 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
6456 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306457 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05306458 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306459 }
6460 wmi_event = param_buf->fixed_param;
6461 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -07006462
6463 if (num_of_diag_events_logs >
6464 param_buf->num_diag_events_logs_list) {
6465 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
6466 num_of_diag_events_logs,
6467 param_buf->num_diag_events_logs_list);
6468 return QDF_STATUS_E_INVAL;
6469 }
6470
Govind Singha4836fd2016-03-07 16:45:38 +05306471 evt_args = param_buf->diag_events_logs_list;
6472 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05306473 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05306474 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05306475 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306476 }
6477
Govind Singhb53420c2016-03-09 14:32:57 +05306478 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05306479 __func__, num_of_diag_events_logs);
6480
6481 /* Free any previous allocation */
6482 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05306483 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05306484
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -07006485 if (num_of_diag_events_logs >
6486 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
6487 WMI_LOGE("%s: excess num of logs:%d", __func__,
6488 num_of_diag_events_logs);
6489 QDF_ASSERT(0);
6490 return QDF_STATUS_E_INVAL;
6491 }
Govind Singha4836fd2016-03-07 16:45:38 +05306492 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05306493 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05306494 sizeof(uint32_t));
6495 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05306496 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306497 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306498 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306499 }
6500 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
6501
6502 /* Prepare the send buffer */
6503 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6504 (num_of_diag_events_logs * sizeof(uint32_t));
6505
6506 buf = wmi_buf_alloc(wmi_handle, buf_len);
6507 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6509 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05306510 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306511 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306512 }
6513
6514 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
6515 buf_ptr = (uint8_t *) cmd;
6516
6517 WMITLV_SET_HDR(&cmd->tlv_header,
6518 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
6519 WMITLV_GET_STRUCT_TLVLEN(
6520 wmi_diag_event_log_config_fixed_param));
6521
6522 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
6523
6524 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
6525
6526 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6527 (num_of_diag_events_logs * sizeof(uint32_t)));
6528
6529 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
6530
6531 /* Populate the events */
6532 for (i = 0; i < num_of_diag_events_logs; i++) {
6533 /* Low freq (0) - Enable (1) the event
6534 * High freq (1) - Disable (0) the event
6535 */
6536 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
6537 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
6538 /* Set the event ID */
6539 WMI_DIAG_ID_SET(cmd_args[i],
6540 WMI_DIAG_ID_GET(evt_args[i]));
6541 /* Set the type */
6542 WMI_DIAG_TYPE_SET(cmd_args[i],
6543 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05306544 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +05306545 wmi_handle->events_logs_list[i] = evt_args[i];
6546 }
6547
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306548 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306549 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
6550 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306551 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306552 __func__);
6553 wmi_buf_free(buf);
6554 /* Not clearing events_logs_list, though wmi cmd failed.
6555 * Host can still have this list
6556 */
Govind Singh67922e82016-04-01 16:48:57 +05306557 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306558 }
6559
6560 return 0;
6561}
6562
6563/**
6564 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
6565 * @wmi_handle: wmi handle
6566 * @start_log: Start logging related parameters
6567 *
6568 * Send the command to the FW based on which specific logging of diag
6569 * event/log id can be started/stopped
6570 *
6571 * Return: None
6572 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306573static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05306574 struct wmi_wifi_start_log *start_log)
6575{
6576 wmi_diag_event_log_config_fixed_param *cmd;
6577 wmi_buf_t buf;
6578 uint8_t *buf_ptr;
6579 uint32_t len, count, log_level, i;
6580 uint32_t *cmd_args;
6581 uint32_t total_len;
6582 count = 0;
6583
6584 if (!wmi_handle->events_logs_list) {
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306585 WMI_LOGD("%s: Not received event/log list from FW, yet",
6586 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306587 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306588 }
6589 /* total_len stores the number of events where BITS 17 and 18 are set.
6590 * i.e., events of high frequency (17) and for extended debugging (18)
6591 */
6592 total_len = 0;
6593 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
6594 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
6595 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
6596 total_len++;
6597 }
6598
6599 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6600 (total_len * sizeof(uint32_t));
6601
6602 buf = wmi_buf_alloc(wmi_handle, len);
6603 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306604 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306605 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306606 }
6607 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
6608 buf_ptr = (uint8_t *) cmd;
6609
6610 WMITLV_SET_HDR(&cmd->tlv_header,
6611 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
6612 WMITLV_GET_STRUCT_TLVLEN(
6613 wmi_diag_event_log_config_fixed_param));
6614
6615 cmd->num_of_diag_events_logs = total_len;
6616
6617 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
6618
6619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6620 (total_len * sizeof(uint32_t)));
6621
6622 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
6623
Govind Singh224a7312016-06-21 14:33:26 +05306624 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +05306625 log_level = 1;
6626 else
6627 log_level = 0;
6628
Govind Singhb53420c2016-03-09 14:32:57 +05306629 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +05306630 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
6631 uint32_t val = wmi_handle->events_logs_list[i];
6632 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
6633 (WMI_DIAG_EXT_FEATURE_GET(val))) {
6634
6635 WMI_DIAG_ID_SET(cmd_args[count],
6636 WMI_DIAG_ID_GET(val));
6637 WMI_DIAG_TYPE_SET(cmd_args[count],
6638 WMI_DIAG_TYPE_GET(val));
6639 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
6640 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +05306641 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +05306642 count++;
6643 }
6644 }
6645
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306646 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306647 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6648 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306649 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306650 __func__);
6651 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306652 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306653 }
6654
Govind Singhb53420c2016-03-09 14:32:57 +05306655 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05306656}
6657
6658/**
6659 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
6660 * @wmi_handle: WMI handle
6661 *
6662 * This function is used to send the flush command to the FW,
6663 * that will flush the fw logs that are residue in the FW
6664 *
6665 * Return: None
6666 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306667static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +05306668{
6669 wmi_debug_mesg_flush_fixed_param *cmd;
6670 wmi_buf_t buf;
6671 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +05306672 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +05306673
6674 buf = wmi_buf_alloc(wmi_handle, len);
6675 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306676 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306677 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306678 }
6679
6680 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
6681 WMITLV_SET_HDR(&cmd->tlv_header,
6682 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
6683 WMITLV_GET_STRUCT_TLVLEN(
6684 wmi_debug_mesg_flush_fixed_param));
6685 cmd->reserved0 = 0;
6686
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306687 wmi_mtrace(WMI_DEBUG_MESG_FLUSH_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306688 ret = wmi_unified_cmd_send(wmi_handle,
6689 buf,
6690 len,
6691 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306692 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306693 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +05306694 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306695 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306696 }
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306697 WMI_LOGD("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +05306698
Govind Singh67922e82016-04-01 16:48:57 +05306699 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +05306700}
6701
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306702#ifdef BIG_ENDIAN_HOST
6703/**
6704* fips_conv_data_be() - LE to BE conversion of FIPS ev data
6705* @param data_len - data length
6706* @param data - pointer to data
6707*
6708* Return: QDF_STATUS - success or error status
6709*/
6710static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
6711 struct fips_params *param)
6712{
6713 unsigned char *key_unaligned, *data_unaligned;
6714 int c;
6715 u_int8_t *key_aligned = NULL;
6716 u_int8_t *data_aligned = NULL;
6717
6718 /* Assigning unaligned space to copy the key */
6719 key_unaligned = qdf_mem_malloc(
6720 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
6721 data_unaligned = qdf_mem_malloc(
6722 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
6723
Jeff Johnsonda263992018-05-12 14:22:00 -07006724 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306725 if (key_unaligned == NULL)
6726 return QDF_STATUS_SUCCESS;
6727 /* Checking if space is aligned */
6728 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
6729 /* align to 4 */
6730 key_aligned =
6731 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
6732 FIPS_ALIGN);
6733 } else {
6734 key_aligned = (u_int8_t *)key_unaligned;
6735 }
6736
6737 /* memset and copy content from key to key aligned */
6738 OS_MEMSET(key_aligned, 0, param->key_len);
6739 OS_MEMCPY(key_aligned, param->key, param->key_len);
6740
6741 /* print a hexdump for host debug */
6742 print_hex_dump(KERN_DEBUG,
6743 "\t Aligned and Copied Key:@@@@ ",
6744 DUMP_PREFIX_NONE,
6745 16, 1, key_aligned, param->key_len, true);
6746
Jeff Johnsonda263992018-05-12 14:22:00 -07006747 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306748 if (data_unaligned == NULL)
6749 return QDF_STATUS_SUCCESS;
6750 /* Checking of space is aligned */
6751 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
6752 /* align to 4 */
6753 data_aligned =
6754 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
6755 FIPS_ALIGN);
6756 } else {
6757 data_aligned = (u_int8_t *)data_unaligned;
6758 }
6759
6760 /* memset and copy content from data to data aligned */
6761 OS_MEMSET(data_aligned, 0, param->data_len);
6762 OS_MEMCPY(data_aligned, param->data, param->data_len);
6763
6764 /* print a hexdump for host debug */
6765 print_hex_dump(KERN_DEBUG,
6766 "\t Properly Aligned and Copied Data:@@@@ ",
6767 DUMP_PREFIX_NONE,
6768 16, 1, data_aligned, param->data_len, true);
6769
6770 /* converting to little Endian both key_aligned and
6771 * data_aligned*/
6772 for (c = 0; c < param->key_len/4; c++) {
6773 *((u_int32_t *)key_aligned+c) =
6774 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
6775 }
6776 for (c = 0; c < param->data_len/4; c++) {
6777 *((u_int32_t *)data_aligned+c) =
6778 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
6779 }
6780
6781 /* update endian data to key and data vectors */
6782 OS_MEMCPY(param->key, key_aligned, param->key_len);
6783 OS_MEMCPY(param->data, data_aligned, param->data_len);
6784
6785 /* clean up allocated spaces */
6786 qdf_mem_free(key_unaligned);
6787 key_unaligned = NULL;
6788 key_aligned = NULL;
6789
6790 qdf_mem_free(data_unaligned);
6791 data_unaligned = NULL;
6792 data_aligned = NULL;
6793
6794 return QDF_STATUS_SUCCESS;
6795}
6796#else
6797/**
6798* fips_align_data_be() - DUMMY for LE platform
6799*
6800* Return: QDF_STATUS - success
6801*/
6802static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
6803 struct fips_params *param)
6804{
6805 return QDF_STATUS_SUCCESS;
6806}
6807#endif
6808
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306809/**
6810 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
6811 * @wmi_handle: wmi handle
6812 * @param: pointer to hold pdev fips param
6813 *
6814 * Return: 0 for success or error code
6815 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306816static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306817send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
6818 struct fips_params *param)
6819{
6820 wmi_pdev_fips_cmd_fixed_param *cmd;
6821 wmi_buf_t buf;
6822 uint8_t *buf_ptr;
6823 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
6824 QDF_STATUS retval = QDF_STATUS_SUCCESS;
6825
6826 /* Length TLV placeholder for array of bytes */
6827 len += WMI_TLV_HDR_SIZE;
6828 if (param->data_len)
6829 len += (param->data_len*sizeof(uint8_t));
6830
6831 /*
6832 * Data length must be multiples of 16 bytes - checked against 0xF -
6833 * and must be less than WMI_SVC_MSG_SIZE - static size of
6834 * wmi_pdev_fips_cmd structure
6835 */
6836
6837 /* do sanity on the input */
6838 if (!(((param->data_len & 0xF) == 0) &&
6839 ((param->data_len > 0) &&
6840 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
6841 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
6842 return QDF_STATUS_E_INVAL;
6843 }
6844
6845 buf = wmi_buf_alloc(wmi_handle, len);
6846 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306847 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306848 return QDF_STATUS_E_FAILURE;
6849 }
6850
6851 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6852 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
6853 WMITLV_SET_HDR(&cmd->tlv_header,
6854 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
6855 WMITLV_GET_STRUCT_TLVLEN
6856 (wmi_pdev_fips_cmd_fixed_param));
6857
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05306858 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
6859 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306860 if (param->key != NULL && param->data != NULL) {
6861 cmd->key_len = param->key_len;
6862 cmd->data_len = param->data_len;
6863 cmd->fips_cmd = !!(param->op);
6864
6865 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
6866 return QDF_STATUS_E_FAILURE;
6867
6868 qdf_mem_copy(cmd->key, param->key, param->key_len);
6869
6870 if (param->mode == FIPS_ENGINE_AES_CTR ||
6871 param->mode == FIPS_ENGINE_AES_MIC) {
6872 cmd->mode = param->mode;
6873 } else {
6874 cmd->mode = FIPS_ENGINE_AES_CTR;
6875 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306876 qdf_print("Key len = %d, Data len = %d",
6877 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306878
6879 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
6880 cmd->key, cmd->key_len, true);
6881 buf_ptr += sizeof(*cmd);
6882
6883 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
6884
6885 buf_ptr += WMI_TLV_HDR_SIZE;
6886 if (param->data_len)
6887 qdf_mem_copy(buf_ptr,
6888 (uint8_t *) param->data, param->data_len);
6889
6890 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
6891 16, 1, buf_ptr, cmd->data_len, true);
6892
6893 buf_ptr += param->data_len;
6894
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306895 wmi_mtrace(WMI_PDEV_FIPS_CMDID, NO_SESSION, 0);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306896 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
6897 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306898 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306899 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306900 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306901 wmi_buf_free(buf);
6902 retval = -QDF_STATUS_E_BADMSG;
6903 }
6904
6905 return retval;
6906}
6907
Govind Singha4836fd2016-03-07 16:45:38 +05306908/**
6909 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
6910 * @wmi_handle: wmi handle
6911 * @request: SSID hotlist set request
6912 *
Govind Singhb53420c2016-03-09 14:32:57 +05306913 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +05306914 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306915static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +05306916send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
6917 struct ssid_hotlist_request_params *request)
6918{
6919 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
6920 wmi_buf_t wmi_buf;
6921 uint32_t len;
6922 uint32_t array_size;
6923 uint8_t *buf_ptr;
6924
6925 /* length of fixed portion */
6926 len = sizeof(*cmd);
6927
6928 /* length of variable portion */
6929 array_size =
6930 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
6931 len += WMI_TLV_HDR_SIZE + array_size;
6932
6933 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6934 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306935 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6936 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306937 }
6938
6939 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6940 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
6941 buf_ptr;
6942 WMITLV_SET_HDR
6943 (&cmd->tlv_header,
6944 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
6945 WMITLV_GET_STRUCT_TLVLEN
6946 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
6947
6948 cmd->request_id = request->request_id;
6949 cmd->requestor_id = 0;
6950 cmd->vdev_id = request->session_id;
6951 cmd->table_id = 0;
6952 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
6953 cmd->total_entries = request->ssid_count;
6954 cmd->num_entries_in_page = request->ssid_count;
6955 cmd->first_entry_index = 0;
6956
6957 buf_ptr += sizeof(*cmd);
6958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
6959
6960 if (request->ssid_count) {
6961 wmi_extscan_hotlist_ssid_entry *entry;
6962 int i;
6963
6964 buf_ptr += WMI_TLV_HDR_SIZE;
6965 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
6966 for (i = 0; i < request->ssid_count; i++) {
6967 WMITLV_SET_HDR
6968 (entry,
6969 WMITLV_TAG_ARRAY_STRUC,
6970 WMITLV_GET_STRUCT_TLVLEN
6971 (wmi_extscan_hotlist_ssid_entry));
6972 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306973 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +05306974 request->ssids[i].ssid.mac_ssid,
6975 request->ssids[i].ssid.length);
6976 entry->band = request->ssids[i].band;
6977 entry->min_rssi = request->ssids[i].rssi_low;
6978 entry->max_rssi = request->ssids[i].rssi_high;
6979 entry++;
6980 }
6981 cmd->mode = WMI_EXTSCAN_MODE_START;
6982 } else {
6983 cmd->mode = WMI_EXTSCAN_MODE_STOP;
6984 }
6985
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306986 wmi_mtrace(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID,
6987 cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306988 if (wmi_unified_cmd_send
6989 (wmi_handle, wmi_buf, len,
6990 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306991 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +05306992 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306993 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05306994 }
6995
Govind Singhb53420c2016-03-09 14:32:57 +05306996 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05306997}
6998
6999/**
Anurag Chouhan459e0152016-07-22 20:19:54 +05307000 * send_fw_test_cmd_tlv() - send fw test command to fw.
7001 * @wmi_handle: wmi handle
7002 * @wmi_fwtest: fw test command
7003 *
7004 * This function sends fw test command to fw.
7005 *
7006 * Return: CDF STATUS
7007 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007008static
Anurag Chouhan459e0152016-07-22 20:19:54 +05307009QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
7010 struct set_fwtest_params *wmi_fwtest)
7011{
7012 wmi_fwtest_set_param_cmd_fixed_param *cmd;
7013 wmi_buf_t wmi_buf;
7014 uint16_t len;
7015
7016 len = sizeof(*cmd);
7017
7018 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7019 if (!wmi_buf) {
7020 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
7021 return QDF_STATUS_E_NOMEM;
7022 }
7023
7024 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
7025 WMITLV_SET_HDR(&cmd->tlv_header,
7026 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
7027 WMITLV_GET_STRUCT_TLVLEN(
7028 wmi_fwtest_set_param_cmd_fixed_param));
7029 cmd->param_id = wmi_fwtest->arg;
7030 cmd->param_value = wmi_fwtest->value;
7031
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307032 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Anurag Chouhan459e0152016-07-22 20:19:54 +05307033 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7034 WMI_FWTEST_CMDID)) {
7035 WMI_LOGP("%s: failed to send fw test command", __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +05307036 wmi_buf_free(wmi_buf);
Anurag Chouhan459e0152016-07-22 20:19:54 +05307037 return QDF_STATUS_E_FAILURE;
7038 }
7039
7040 return QDF_STATUS_SUCCESS;
7041}
7042
7043/**
Govind Singha4836fd2016-03-07 16:45:38 +05307044 * send_unit_test_cmd_tlv() - send unit test command to fw.
7045 * @wmi_handle: wmi handle
7046 * @wmi_utest: unit test command
7047 *
7048 * This function send unit test command to fw.
7049 *
7050 * Return: CDF STATUS
7051 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307052static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05307053 struct wmi_unit_test_cmd *wmi_utest)
7054{
7055 wmi_unit_test_cmd_fixed_param *cmd;
7056 wmi_buf_t wmi_buf;
7057 uint8_t *buf_ptr;
7058 int i;
7059 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +05307060 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +05307061
7062 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +05307063 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +05307064 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
7065
7066 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7067 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307068 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
7069 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05307070 }
7071
7072 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
7073 buf_ptr = (uint8_t *) cmd;
7074 WMITLV_SET_HDR(&cmd->tlv_header,
7075 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
7076 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
7077 cmd->vdev_id = wmi_utest->vdev_id;
7078 cmd->module_id = wmi_utest->module_id;
7079 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07007080 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +05307081 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
7082 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7083 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05307084 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307085 WMI_LOGI("%s: VDEV ID: %d", __func__, cmd->vdev_id);
7086 WMI_LOGI("%s: MODULE ID: %d", __func__, cmd->module_id);
7087 WMI_LOGI("%s: TOKEN: %d", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +05307088 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -08007089 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +05307090 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +05307091 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +05307092 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307093 wmi_mtrace(WMI_UNIT_TEST_CMDID, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05307094 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7095 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307096 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307097 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307098 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05307099 }
7100
Govind Singhb53420c2016-03-09 14:32:57 +05307101 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05307102}
7103
7104/**
Govind Singhbca3b1b2016-05-02 17:59:24 +05307105 * send_power_dbg_cmd_tlv() - send power debug commands
7106 * @wmi_handle: wmi handle
7107 * @param: wmi power debug parameter
7108 *
7109 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
7110 *
7111 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7112 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007113static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
7114 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +05307115{
7116 wmi_buf_t buf = NULL;
7117 QDF_STATUS status;
7118 int len, args_tlv_len;
7119 uint8_t *buf_ptr;
7120 uint8_t i;
7121 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
7122 uint32_t *cmd_args;
7123
7124 /* Prepare and send power debug cmd parameters */
7125 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
7126 len = sizeof(*cmd) + args_tlv_len;
7127 buf = wmi_buf_alloc(wmi_handle, len);
7128 if (!buf) {
7129 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7130 return QDF_STATUS_E_NOMEM;
7131 }
7132
7133 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7134 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
7135 WMITLV_SET_HDR(&cmd->tlv_header,
7136 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
7137 WMITLV_GET_STRUCT_TLVLEN
7138 (wmi_pdev_wal_power_debug_cmd_fixed_param));
7139
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307140 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
7141 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +05307142 cmd->module_id = param->module_id;
7143 cmd->num_args = param->num_args;
7144 buf_ptr += sizeof(*cmd);
7145 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7146 (param->num_args * sizeof(uint32_t)));
7147 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
7148 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08007149 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +05307150 cmd_args[i] = param->args[i];
7151 WMI_LOGI("%d,", param->args[i]);
7152 }
7153
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307154 wmi_mtrace(WMI_PDEV_WAL_POWER_DEBUG_CMDID, NO_SESSION, 0);
Govind Singhbca3b1b2016-05-02 17:59:24 +05307155 status = wmi_unified_cmd_send(wmi_handle, buf,
7156 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
7157 if (QDF_IS_STATUS_ERROR(status)) {
7158 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
7159 status);
7160 goto error;
7161 }
7162
7163 return QDF_STATUS_SUCCESS;
7164error:
7165 wmi_buf_free(buf);
7166
7167 return status;
7168}
7169
Govind Singhe7f2f342016-05-23 12:12:52 +05307170/**
Arif Hussainf00be1d2017-01-07 18:21:55 -08007171 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
7172 * @wmi_handle: wmi handle
7173 * @pdev_id: pdev id
7174 *
7175 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
7176 *
7177 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7178 */
7179static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7180 uint32_t pdev_id)
7181{
7182 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
7183 wmi_buf_t buf;
7184 uint16_t len;
7185 QDF_STATUS ret;
7186
7187 len = sizeof(*cmd);
7188 buf = wmi_buf_alloc(wmi_handle, len);
7189
7190 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
7191
7192 if (!buf) {
7193 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7194 return QDF_STATUS_E_NOMEM;
7195 }
7196
7197 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
7198 wmi_buf_data(buf);
7199
7200 WMITLV_SET_HDR(&cmd->tlv_header,
7201 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
7202 WMITLV_GET_STRUCT_TLVLEN(
7203 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
7204
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307205 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307206 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -08007207 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7208 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
7209 if (QDF_IS_STATUS_ERROR(ret)) {
7210 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
7211 __func__, ret, pdev_id);
7212 wmi_buf_free(buf);
7213 return QDF_STATUS_E_FAILURE;
7214 }
7215
7216 return QDF_STATUS_SUCCESS;
7217}
7218
7219/**
7220 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
7221 * @wmi_handle: wmi handle
7222 * @pdev_id: pdev id
7223 *
7224 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
7225 *
7226 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7227 */
7228static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
7229 uint32_t pdev_id)
7230{
7231 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
7232 wmi_buf_t buf;
7233 uint16_t len;
7234 QDF_STATUS ret;
7235
7236 len = sizeof(*cmd);
7237 buf = wmi_buf_alloc(wmi_handle, len);
7238
7239 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
7240
7241 if (!buf) {
7242 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7243 return QDF_STATUS_E_NOMEM;
7244 }
7245
7246 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
7247 wmi_buf_data(buf);
7248
7249 WMITLV_SET_HDR(&cmd->tlv_header,
7250 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
7251 WMITLV_GET_STRUCT_TLVLEN(
7252 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
7253
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307254 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307255 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -08007256 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7257 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
7258 if (QDF_IS_STATUS_ERROR(ret)) {
7259 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
7260 __func__, ret, pdev_id);
7261 wmi_buf_free(buf);
7262 return QDF_STATUS_E_FAILURE;
7263 }
7264
7265 return QDF_STATUS_SUCCESS;
7266}
7267
7268/**
Govind Singhe7f2f342016-05-23 12:12:52 +05307269 * init_cmd_send_tlv() - send initialization cmd to fw
7270 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +05307271 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +05307272 *
7273 * Return: QDF_STATUS_SUCCESS for success or error code
7274 */
7275static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +05307276 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +05307277{
7278 wmi_buf_t buf;
7279 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +05307280 uint8_t *buf_ptr;
7281 wmi_resource_config *resource_cfg;
7282 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +05307283 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +05307284 uint16_t idx;
7285 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307286 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +05307287
Kiran Venkatappa26117052016-12-23 19:58:54 +05307288 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
7289 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +05307290 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +05307291
7292 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
7293 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
7294 WMI_TLV_HDR_SIZE +
7295 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
7296
7297 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +05307298 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307299 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307300 return QDF_STATUS_E_FAILURE;
7301 }
7302
7303 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7304 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
7305 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
7306
7307 host_mem_chunks = (wlan_host_memory_chunk *)
7308 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
7309 + WMI_TLV_HDR_SIZE);
7310
7311 WMITLV_SET_HDR(&cmd->tlv_header,
7312 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
7313 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
7314
Kiran Venkatappa26117052016-12-23 19:58:54 +05307315 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +05307316 WMITLV_SET_HDR(&resource_cfg->tlv_header,
7317 WMITLV_TAG_STRUC_wmi_resource_config,
7318 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
7319
Kiran Venkatappa26117052016-12-23 19:58:54 +05307320 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307321 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
7322 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
7323 WMITLV_GET_STRUCT_TLVLEN
7324 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +05307325 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
7326 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
7327 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +05307328 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
7329 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +05307330 idx, host_mem_chunks[idx].size,
7331 host_mem_chunks[idx].ptr);
7332 }
Kiran Venkatappa26117052016-12-23 19:58:54 +05307333 cmd->num_host_mem_chunks = param->num_mem_chunks;
7334 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
7335
Govind Singhe7f2f342016-05-23 12:12:52 +05307336 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
7337 WMITLV_TAG_ARRAY_STRUC,
7338 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +05307339 param->num_mem_chunks));
7340
7341 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307342 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +05307343
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307344 /* Fill fw_abi_vers */
7345 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +05307346
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307347 wmi_mtrace(WMI_INIT_CMDID, NO_SESSION, 0);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307348 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
7349 if (QDF_IS_STATUS_ERROR(ret)) {
7350 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
7351 ret);
7352 wmi_buf_free(buf);
7353 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307354
Abhishek Singh716c46c2016-05-04 16:24:07 +05307355 return ret;
7356
Govind Singhe7f2f342016-05-23 12:12:52 +05307357}
7358
7359/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007360 * send_addba_send_cmd_tlv() - send addba send command to fw
7361 * @wmi_handle: wmi handle
7362 * @param: pointer to delba send params
7363 * @macaddr: peer mac address
7364 *
7365 * Send WMI_ADDBA_SEND_CMDID command to firmware
7366 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
7367 */
7368static QDF_STATUS
7369send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
7370 uint8_t macaddr[IEEE80211_ADDR_LEN],
7371 struct addba_send_params *param)
7372{
7373 wmi_addba_send_cmd_fixed_param *cmd;
7374 wmi_buf_t buf;
7375 uint16_t len;
7376 QDF_STATUS ret;
7377
7378 len = sizeof(*cmd);
7379
7380 buf = wmi_buf_alloc(wmi_handle, len);
7381 if (!buf) {
7382 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7383 return QDF_STATUS_E_NOMEM;
7384 }
7385
7386 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
7387
7388 WMITLV_SET_HDR(&cmd->tlv_header,
7389 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
7390 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
7391
7392 cmd->vdev_id = param->vdev_id;
7393 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7394 cmd->tid = param->tidno;
7395 cmd->buffersize = param->buffersize;
7396
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307397 wmi_mtrace(WMI_ADDBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007398 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
7399 if (QDF_IS_STATUS_ERROR(ret)) {
7400 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7401 wmi_buf_free(buf);
7402 return QDF_STATUS_E_FAILURE;
7403 }
7404
7405 return QDF_STATUS_SUCCESS;
7406}
7407
7408/**
7409 * send_delba_send_cmd_tlv() - send delba send command to fw
7410 * @wmi_handle: wmi handle
7411 * @param: pointer to delba send params
7412 * @macaddr: peer mac address
7413 *
7414 * Send WMI_DELBA_SEND_CMDID command to firmware
7415 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
7416 */
7417static QDF_STATUS
7418send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
7419 uint8_t macaddr[IEEE80211_ADDR_LEN],
7420 struct delba_send_params *param)
7421{
7422 wmi_delba_send_cmd_fixed_param *cmd;
7423 wmi_buf_t buf;
7424 uint16_t len;
7425 QDF_STATUS ret;
7426
7427 len = sizeof(*cmd);
7428
7429 buf = wmi_buf_alloc(wmi_handle, len);
7430 if (!buf) {
7431 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7432 return QDF_STATUS_E_NOMEM;
7433 }
7434
7435 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
7436
7437 WMITLV_SET_HDR(&cmd->tlv_header,
7438 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
7439 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
7440
7441 cmd->vdev_id = param->vdev_id;
7442 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7443 cmd->tid = param->tidno;
7444 cmd->initiator = param->initiator;
7445 cmd->reasoncode = param->reasoncode;
7446
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307447 wmi_mtrace(WMI_DELBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007448 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
7449 if (QDF_IS_STATUS_ERROR(ret)) {
7450 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7451 wmi_buf_free(buf);
7452 return QDF_STATUS_E_FAILURE;
7453 }
7454
7455 return QDF_STATUS_SUCCESS;
7456}
7457
7458/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007459 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
7460 * to fw
7461 * @wmi_handle: wmi handle
7462 * @param: pointer to addba clearresp params
7463 * @macaddr: peer mac address
7464 * Return: 0 for success or error code
7465 */
7466static QDF_STATUS
7467send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
7468 uint8_t macaddr[IEEE80211_ADDR_LEN],
7469 struct addba_clearresponse_params *param)
7470{
7471 wmi_addba_clear_resp_cmd_fixed_param *cmd;
7472 wmi_buf_t buf;
7473 uint16_t len;
7474 QDF_STATUS ret;
7475
7476 len = sizeof(*cmd);
7477
7478 buf = wmi_buf_alloc(wmi_handle, len);
7479 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307480 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007481 return QDF_STATUS_E_FAILURE;
7482 }
7483 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
7484
7485 WMITLV_SET_HDR(&cmd->tlv_header,
7486 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
7487 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
7488
7489 cmd->vdev_id = param->vdev_id;
7490 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7491
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307492 wmi_mtrace(WMI_ADDBA_CLEAR_RESP_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007493 ret = wmi_unified_cmd_send(wmi_handle,
7494 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
7495 if (QDF_IS_STATUS_ERROR(ret)) {
7496 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7497 wmi_buf_free(buf);
7498 return QDF_STATUS_E_FAILURE;
7499 }
7500
7501 return QDF_STATUS_SUCCESS;
7502}
7503
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307504#ifdef OBSS_PD
7505/**
7506 * send_obss_spatial_reuse_set_cmd_tlv - send obss spatial reuse set cmd to fw
7507 * @wmi_handle: wmi handle
7508 * @obss_spatial_reuse_param: pointer to obss_spatial_reuse_param
7509 *
7510 * Return: QDF_STATUS_SUCCESS for success or error code
7511 */
7512static
7513QDF_STATUS send_obss_spatial_reuse_set_cmd_tlv(wmi_unified_t wmi_handle,
7514 struct wmi_host_obss_spatial_reuse_set_param
7515 *obss_spatial_reuse_param)
7516{
7517 wmi_buf_t buf;
7518 wmi_obss_spatial_reuse_set_cmd_fixed_param *cmd;
7519 QDF_STATUS ret;
7520 uint32_t len;
7521
7522 len = sizeof(*cmd);
7523
7524 buf = wmi_buf_alloc(wmi_handle, len);
7525 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307526 qdf_print("%s: wmi_buf_alloc failed", __func__);
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307527 return QDF_STATUS_E_FAILURE;
7528 }
7529
7530 cmd = (wmi_obss_spatial_reuse_set_cmd_fixed_param *)wmi_buf_data(buf);
7531 WMITLV_SET_HDR(&cmd->tlv_header,
7532 WMITLV_TAG_STRUC_wmi_obss_spatial_reuse_set_cmd_fixed_param,
7533 WMITLV_GET_STRUCT_TLVLEN
7534 (wmi_obss_spatial_reuse_set_cmd_fixed_param));
7535
7536 cmd->enable = obss_spatial_reuse_param->enable;
7537 cmd->obss_min = obss_spatial_reuse_param->obss_min;
7538 cmd->obss_max = obss_spatial_reuse_param->obss_max;
7539 cmd->vdev_id = obss_spatial_reuse_param->vdev_id;
7540
7541 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7542 WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID);
7543
7544 if (QDF_IS_STATUS_ERROR(ret)) {
7545 WMI_LOGE(
7546 "WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID send returned Error %d",
7547 ret);
7548 wmi_buf_free(buf);
7549 }
7550
7551 return ret;
7552}
7553#endif
7554
Naveen Rawat963ee942018-04-13 16:38:36 -07007555#ifdef QCA_SUPPORT_CP_STATS
7556/**
7557 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
7558 * @wmi_handle: wma handle
7559 * @evt_buf: event buffer
7560 * @out_buff: buffer to populated after stats extraction
7561 *
7562 * Return: status of operation
7563 */
7564static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
7565 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
7566{
7567 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
7568 wmi_congestion_stats *congestion_stats;
7569
7570 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
7571 congestion_stats = param_buf->congestion_stats;
7572 if (!congestion_stats) {
7573 WMI_LOGD("%s: no cca stats in event buffer", __func__);
7574 return QDF_STATUS_E_INVAL;
7575 }
7576
7577 out_buff->vdev_id = congestion_stats->vdev_id;
7578 out_buff->congestion = congestion_stats->congestion;
7579
7580 WMI_LOGD("%s: cca stats event processed", __func__);
7581 return QDF_STATUS_SUCCESS;
7582}
7583#endif /* QCA_SUPPORT_CP_STATS */
7584
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +05307585/**
Alok Singh0243e7d2018-09-20 16:07:28 +05307586 * extract_ctl_failsafe_check_ev_param_tlv() - extract ctl data from
7587 * event
7588 * @wmi_handle: wmi handle
7589 * @param evt_buf: pointer to event buffer
7590 * @param param: Pointer to hold peer ctl data
7591 *
7592 * Return: QDF_STATUS_SUCCESS for success or error code
7593 */
7594static QDF_STATUS extract_ctl_failsafe_check_ev_param_tlv(
7595 wmi_unified_t wmi_handle,
7596 void *evt_buf,
7597 struct wmi_host_pdev_ctl_failsafe_event *param)
7598{
7599 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *param_buf;
7600 wmi_pdev_ctl_failsafe_check_fixed_param *fix_param;
7601
7602 param_buf = (WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *)evt_buf;
7603 if (!param_buf) {
7604 WMI_LOGE("Invalid ctl_failsafe event buffer");
7605 return QDF_STATUS_E_INVAL;
7606 }
7607
7608 fix_param = param_buf->fixed_param;
7609 param->ctl_failsafe_status = fix_param->ctl_FailsafeStatus;
7610
7611 return QDF_STATUS_SUCCESS;
7612}
7613
7614/**
Govind Singhe7f2f342016-05-23 12:12:52 +05307615 * save_service_bitmap_tlv() - save service bitmap
7616 * @wmi_handle: wmi handle
7617 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -08007618 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +05307619 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307620 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +05307621 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007622static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307623QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007624 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307625{
7626 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307627 struct wmi_soc *soc = wmi_handle->soc;
7628
Govind Singhe7f2f342016-05-23 12:12:52 +05307629 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7630
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307631 /* If it is already allocated, use that buffer. This can happen
7632 * during target stop/start scenarios where host allocation is skipped.
7633 */
7634 if (!soc->wmi_service_bitmap) {
7635 soc->wmi_service_bitmap =
7636 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
7637 if (!soc->wmi_service_bitmap) {
7638 WMI_LOGE("Failed memory allocation for service bitmap");
7639 return QDF_STATUS_E_NOMEM;
7640 }
7641 }
7642
7643 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +05307644 param_buf->wmi_service_bitmap,
7645 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -08007646
7647 if (bitmap_buf)
7648 qdf_mem_copy(bitmap_buf,
7649 param_buf->wmi_service_bitmap,
7650 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307651
7652 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +05307653}
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307654
7655/**
7656 * save_ext_service_bitmap_tlv() - save extendend service bitmap
7657 * @wmi_handle: wmi handle
7658 * @param evt_buf: pointer to event buffer
7659 * @param bitmap_buf: bitmap buffer, for converged legacy support
7660 *
7661 * Return: QDF_STATUS
7662 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007663static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307664QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007665 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307666{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307667 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
7668 wmi_service_available_event_fixed_param *ev;
7669 struct wmi_soc *soc = wmi_handle->soc;
7670
7671 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
7672
7673 ev = param_buf->fixed_param;
7674
7675 /* If it is already allocated, use that buffer. This can happen
7676 * during target stop/start scenarios where host allocation is skipped.
7677 */
7678 if (!soc->wmi_ext_service_bitmap) {
7679 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
7680 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
7681 if (!soc->wmi_ext_service_bitmap) {
7682 WMI_LOGE("Failed memory allocation for service bitmap");
7683 return QDF_STATUS_E_NOMEM;
7684 }
7685 }
7686
7687 qdf_mem_copy(soc->wmi_ext_service_bitmap,
7688 ev->wmi_service_segment_bitmap,
7689 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307690
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307691 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x",
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +05307692 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
7693 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
7694
Rajeev Kumar77901472017-02-12 02:12:17 -08007695 if (bitmap_buf)
7696 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307697 soc->wmi_ext_service_bitmap,
7698 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307699
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307700 return QDF_STATUS_SUCCESS;
7701}
Govind Singhe7f2f342016-05-23 12:12:52 +05307702/**
7703 * is_service_enabled_tlv() - Check if service enabled
7704 * @param wmi_handle: wmi handle
7705 * @param service_id: service identifier
7706 *
7707 * Return: 1 enabled, 0 disabled
7708 */
Govind Singhe7f2f342016-05-23 12:12:52 +05307709static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
7710 uint32_t service_id)
7711{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307712 struct wmi_soc *soc = wmi_handle->soc;
7713
7714 if (!soc->wmi_service_bitmap) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307715 WMI_LOGE("WMI service bit map is not saved yet");
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307716 return false;
7717 }
7718
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +05307719 /* if wmi_service_enabled was received with extended bitmap,
7720 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307721 */
7722 if (soc->wmi_ext_service_bitmap)
7723 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
7724 soc->wmi_ext_service_bitmap,
7725 service_id);
7726
Zhu Jianmin3ed26de2018-04-19 17:55:30 +08007727 if (service_id >= WMI_MAX_SERVICE) {
7728 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
7729 service_id);
7730 return false;
7731 }
7732
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307733 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
7734 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05307735}
Govind Singhe7f2f342016-05-23 12:12:52 +05307736
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307737static inline void copy_ht_cap_info(uint32_t ev_target_cap,
7738 struct wlan_psoc_target_capability_info *cap)
7739{
7740 /* except LDPC all flags are common betwen legacy and here
7741 * also IBFEER is not defined for TLV
7742 */
7743 cap->ht_cap_info |= ev_target_cap & (
7744 WMI_HT_CAP_ENABLED
7745 | WMI_HT_CAP_HT20_SGI
7746 | WMI_HT_CAP_DYNAMIC_SMPS
7747 | WMI_HT_CAP_TX_STBC
7748 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
7749 | WMI_HT_CAP_RX_STBC
7750 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
7751 | WMI_HT_CAP_LDPC
7752 | WMI_HT_CAP_L_SIG_TXOP_PROT
7753 | WMI_HT_CAP_MPDU_DENSITY
7754 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
7755 | WMI_HT_CAP_HT40_SGI);
7756 if (ev_target_cap & WMI_HT_CAP_LDPC)
7757 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
7758 WMI_HOST_HT_CAP_TX_LDPC;
7759}
Govind Singhe7f2f342016-05-23 12:12:52 +05307760/**
7761 * extract_service_ready_tlv() - extract service ready event
7762 * @wmi_handle: wmi handle
7763 * @param evt_buf: pointer to received event buffer
7764 * @param cap: pointer to hold target capability information extracted from even
7765 *
7766 * Return: QDF_STATUS_SUCCESS for success or error code
7767 */
7768static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007769 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307770{
7771 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7772 wmi_service_ready_event_fixed_param *ev;
7773
7774
7775 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7776
7777 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7778 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307779 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307780 return QDF_STATUS_E_FAILURE;
7781 }
7782
7783 cap->phy_capability = ev->phy_capability;
7784 cap->max_frag_entry = ev->max_frag_entry;
7785 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307786 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +05307787 cap->vht_cap_info = ev->vht_cap_info;
7788 cap->vht_supp_mcs = ev->vht_supp_mcs;
7789 cap->hw_min_tx_power = ev->hw_min_tx_power;
7790 cap->hw_max_tx_power = ev->hw_max_tx_power;
7791 cap->sys_cap_info = ev->sys_cap_info;
7792 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
7793 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
7794 cap->max_num_scan_channels = ev->max_num_scan_channels;
7795 cap->max_supported_macs = ev->max_supported_macs;
7796 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
7797 cap->txrx_chainmask = ev->txrx_chainmask;
7798 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
7799 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05307800 cap->fw_version = ev->fw_build_vers;
7801 /* fw_version_1 is not available in TLV. */
7802 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +05307803
7804 return QDF_STATUS_SUCCESS;
7805}
7806
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307807/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307808 * to host internal WMI_HOST_REGDMN_MODE values.
7809 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
7810 * host currently. Add this in the future if required.
7811 * 11AX (Phase II) : 11ax related values are not currently
7812 * advertised separately by FW. As part of phase II regulatory bring-up,
7813 * finalize the advertisement mechanism.
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307814 * @target_wireless_mode: target wireless mode received in message
7815 *
7816 * Return: returns the host internal wireless mode.
7817 */
7818static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
7819{
7820
7821 uint32_t wireless_modes = 0;
7822
7823 if (target_wireless_mode & REGDMN_MODE_11A)
7824 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
7825
7826 if (target_wireless_mode & REGDMN_MODE_TURBO)
7827 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
7828
7829 if (target_wireless_mode & REGDMN_MODE_11B)
7830 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
7831
7832 if (target_wireless_mode & REGDMN_MODE_PUREG)
7833 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
7834
7835 if (target_wireless_mode & REGDMN_MODE_11G)
7836 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
7837
7838 if (target_wireless_mode & REGDMN_MODE_108G)
7839 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
7840
7841 if (target_wireless_mode & REGDMN_MODE_108A)
7842 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
7843
7844 if (target_wireless_mode & REGDMN_MODE_XR)
7845 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
7846
7847 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
7848 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
7849
7850 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
7851 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
7852
7853 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
7854 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
7855
7856 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
7857 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
7858
7859 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
7860 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
7861
7862 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
7863 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
7864
7865 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
7866 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
7867
7868 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
7869 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
7870
7871 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
7872 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
7873
7874 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
7875 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
7876
7877 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
7878 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
7879
7880 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
7881 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
7882
7883 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
7884 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
7885
7886 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
7887 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
7888
7889 return wireless_modes;
7890}
7891
Govind Singhe7f2f342016-05-23 12:12:52 +05307892/**
7893 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
7894 * @wmi_handle: wmi handle
7895 * @param evt_buf: Pointer to event buffer
7896 * @param cap: pointer to hold HAL reg capabilities
7897 *
7898 * Return: QDF_STATUS_SUCCESS for success or error code
7899 */
7900static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007901 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307902{
7903 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7904
7905 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7906
7907 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
7908 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -08007909 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +05307910
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307911 cap->wireless_modes = convert_wireless_modes_tlv(
7912 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +05307913
Govind Singhe7f2f342016-05-23 12:12:52 +05307914 return QDF_STATUS_SUCCESS;
7915}
7916
7917/**
7918 * extract_host_mem_req_tlv() - Extract host memory request event
7919 * @wmi_handle: wmi handle
7920 * @param evt_buf: pointer to event buffer
7921 * @param num_entries: pointer to hold number of entries requested
7922 *
7923 * Return: Number of entries requested
7924 */
7925static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
7926 void *evt_buf, uint8_t *num_entries)
7927{
7928 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7929 wmi_service_ready_event_fixed_param *ev;
7930
7931 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7932
7933 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7934 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307935 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307936 return NULL;
7937 }
7938
7939 *num_entries = ev->num_mem_reqs;
7940
7941 return (host_mem_req *)param_buf->mem_reqs;
7942}
7943
7944/**
7945 * save_fw_version_in_service_ready_tlv() - Save fw version in service
7946 * ready function
7947 * @wmi_handle: wmi handle
7948 * @param evt_buf: pointer to event buffer
7949 *
7950 * Return: QDF_STATUS_SUCCESS for success or error code
7951 */
7952static QDF_STATUS
7953save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
7954{
7955 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7956 wmi_service_ready_event_fixed_param *ev;
7957
7958
7959 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7960
7961 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7962 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307963 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307964 return QDF_STATUS_E_FAILURE;
7965 }
7966
7967 /*Save fw version from service ready message */
7968 /*This will be used while sending INIT message */
7969 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
7970 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307971
Govind Singhe7f2f342016-05-23 12:12:52 +05307972 return QDF_STATUS_SUCCESS;
7973}
7974
7975/**
7976 * ready_extract_init_status_tlv() - Extract init status from ready event
7977 * @wmi_handle: wmi handle
7978 * @param evt_buf: Pointer to event buffer
7979 *
7980 * Return: ready status
7981 */
7982static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
7983 void *evt_buf)
7984{
7985 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
7986 wmi_ready_event_fixed_param *ev = NULL;
7987
Govind Singhe7f2f342016-05-23 12:12:52 +05307988 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
7989 ev = param_buf->fixed_param;
7990
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307991 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +05307992
7993 return ev->status;
7994}
7995
7996/**
7997 * ready_extract_mac_addr_tlv() - extract mac address from ready event
7998 * @wmi_handle: wmi handle
7999 * @param evt_buf: pointer to event buffer
8000 * @param macaddr: Pointer to hold MAC address
8001 *
8002 * Return: QDF_STATUS_SUCCESS for success or error code
8003 */
8004static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
8005 void *evt_buf, uint8_t *macaddr)
8006{
8007 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8008 wmi_ready_event_fixed_param *ev = NULL;
8009
8010
8011 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8012 ev = param_buf->fixed_param;
8013
8014 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
8015
8016 return QDF_STATUS_SUCCESS;
8017}
8018
8019/**
Manoj Ekbotedd273902017-07-09 23:28:56 -07008020 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
8021 * @wmi_handle: wmi handle
8022 * @param evt_buf: pointer to event buffer
8023 * @param macaddr: Pointer to hold number of MAC addresses
8024 *
8025 * Return: Pointer to addr list
8026 */
8027static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
8028 void *evt_buf, uint8_t *num_mac)
8029{
8030 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8031 wmi_ready_event_fixed_param *ev = NULL;
8032
8033 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8034 ev = param_buf->fixed_param;
8035
8036 *num_mac = ev->num_extra_mac_addr;
8037
8038 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
8039}
8040
8041/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308042 * extract_ready_params_tlv() - Extract data from ready event apart from
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308043 * status, macaddr and version.
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308044 * @wmi_handle: Pointer to WMI handle.
8045 * @evt_buf: Pointer to Ready event buffer.
8046 * @ev_param: Pointer to host defined struct to copy the data from event.
8047 *
8048 * Return: QDF_STATUS_SUCCESS on success.
8049 */
8050static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
8051 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
8052{
8053 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8054 wmi_ready_event_fixed_param *ev = NULL;
8055
8056 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8057 ev = param_buf->fixed_param;
8058
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308059 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308060 ev_param->num_dscp_table = ev->num_dscp_table;
8061 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
8062 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308063 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308064 /* Agile_cap in ready event is not supported in TLV target */
8065 ev_param->agile_capability = false;
8066
8067 return QDF_STATUS_SUCCESS;
8068}
8069
8070/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308071 * extract_dbglog_data_len_tlv() - extract debuglog data length
8072 * @wmi_handle: wmi handle
8073 * @param evt_buf: pointer to event buffer
8074 *
8075 * Return: length
8076 */
8077static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -08008078 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +05308079{
8080 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
8081
8082 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
8083
8084 *len = param_buf->num_bufp;
8085
8086 return param_buf->bufp;
8087}
8088
Govind Singhe7f2f342016-05-23 12:12:52 +05308089
Jinwei Chenb69924c2018-08-20 11:31:31 +08008090#ifdef CONFIG_MCL
8091#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
8092 ((_status) & WMI_RXERR_DECRYPT)
8093#else
8094#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
8095#endif
8096
Govind Singhe7f2f342016-05-23 12:12:52 +05308097/**
8098 * extract_mgmt_rx_params_tlv() - extract management rx params from event
8099 * @wmi_handle: wmi handle
8100 * @param evt_buf: pointer to event buffer
8101 * @param hdr: Pointer to hold header
8102 * @param bufp: Pointer to hold pointer to rx param buffer
8103 *
8104 * Return: QDF_STATUS_SUCCESS for success or error code
8105 */
8106static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +05308107 void *evt_buf, struct mgmt_rx_event_params *hdr,
8108 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +05308109{
8110 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
8111 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308112 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +05308113
8114 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
8115 if (!param_tlvs) {
8116 WMI_LOGE("Get NULL point message from FW");
8117 return QDF_STATUS_E_INVAL;
8118 }
8119
8120 ev_hdr = param_tlvs->hdr;
8121 if (!hdr) {
8122 WMI_LOGE("Rx event is NULL");
8123 return QDF_STATUS_E_INVAL;
8124 }
8125
Jinwei Chenb69924c2018-08-20 11:31:31 +08008126 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
8127 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
8128 __func__);
8129 return QDF_STATUS_E_INVAL;
8130 }
8131
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308132 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8133 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308134
8135 hdr->channel = ev_hdr->channel;
8136 hdr->snr = ev_hdr->snr;
8137 hdr->rate = ev_hdr->rate;
8138 hdr->phy_mode = ev_hdr->phy_mode;
8139 hdr->buf_len = ev_hdr->buf_len;
8140 hdr->status = ev_hdr->status;
8141 hdr->flags = ev_hdr->flags;
8142 hdr->rssi = ev_hdr->rssi;
8143 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308144 for (i = 0; i < ATH_MAX_ANTENNA; i++)
8145 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +05308146
8147 *bufp = param_tlvs->bufp;
8148
8149 return QDF_STATUS_SUCCESS;
8150}
8151
8152/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308153 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
8154 * @wmi_handle: wmi handle
8155 * @param evt_buf: pointer to event buffer
8156 * @param param: Pointer to hold roam param
8157 *
8158 * Return: QDF_STATUS_SUCCESS for success or error code
8159 */
8160static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
8161 void *evt_buf, wmi_host_roam_event *param)
8162{
8163 WMI_ROAM_EVENTID_param_tlvs *param_buf;
8164 wmi_roam_event_fixed_param *evt;
8165
8166 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
8167 if (!param_buf) {
8168 WMI_LOGE("Invalid roam event buffer");
8169 return QDF_STATUS_E_INVAL;
8170 }
8171
8172 evt = param_buf->fixed_param;
8173 qdf_mem_zero(param, sizeof(*param));
8174
8175 param->vdev_id = evt->vdev_id;
8176 param->reason = evt->reason;
8177 param->rssi = evt->rssi;
8178
8179 return QDF_STATUS_SUCCESS;
8180}
8181
8182/**
8183 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
8184 * @wmi_handle: wmi handle
8185 * @param evt_buf: pointer to event buffer
8186 * @param param: Pointer to hold vdev scan param
8187 *
8188 * Return: QDF_STATUS_SUCCESS for success or error code
8189 */
8190static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308191 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +05308192{
8193 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
8194 wmi_scan_event_fixed_param *evt = NULL;
8195
8196 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
8197 evt = param_buf->fixed_param;
8198
8199 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308200
Govind Singhe7f2f342016-05-23 12:12:52 +05308201 switch (evt->event) {
8202 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308203 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308204 break;
8205 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308206 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308207 break;
8208 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308209 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308210 break;
8211 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308212 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308213 break;
8214 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308215 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308216 break;
8217 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308218 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308219 break;
8220 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308221 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308222 break;
8223 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308224 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308225 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +05308226 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308227 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308228 break;
8229 case WMI_SCAN_EVENT_MAX:
8230 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308231 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308232 break;
8233 };
8234
8235 switch (evt->reason) {
8236 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308237 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308238 break;
8239 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308240 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308241 break;
8242 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308243 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308244 break;
8245 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308246 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308247 break;
8248 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308249 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308250 break;
8251 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308252 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308253 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308254 case WMI_SCAN_REASON_SUSPENDED:
8255 param->reason = SCAN_REASON_SUSPENDED;
8256 break;
Abhijit Pradhanf6694f82018-10-17 10:13:15 +05308257 case WMI_SCAN_REASON_DFS_VIOLATION:
8258 param->reason = SCAN_REASON_DFS_VIOLATION;
8259 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308260 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308261 param->reason = SCAN_REASON_MAX;
8262 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308263 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308264 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308265 break;
8266 };
8267
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308268 param->chan_freq = evt->channel_freq;
8269 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +05308270 param->scan_id = evt->scan_id;
8271 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +05308272 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +05308273
8274 return QDF_STATUS_SUCCESS;
8275}
8276
Govind Singhe7f2f342016-05-23 12:12:52 +05308277/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308278 * extract_all_stats_counts_tlv() - extract all stats count from event
8279 * @wmi_handle: wmi handle
8280 * @param evt_buf: pointer to event buffer
8281 * @param stats_param: Pointer to hold stats count
8282 *
8283 * Return: QDF_STATUS_SUCCESS for success or error code
8284 */
8285static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
8286 void *evt_buf, wmi_host_stats_event *stats_param)
8287{
Govind Singhe7f2f342016-05-23 12:12:52 +05308288 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008289 wmi_per_chain_rssi_stats *rssi_event;
8290 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008291 uint64_t min_data_len;
Govind Singhe7f2f342016-05-23 12:12:52 +05308292
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008293 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +05308294 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +05308295 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008296 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +05308297 if (!ev) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308298 WMI_LOGE("%s: event fixed param NULL", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05308299 return QDF_STATUS_E_FAILURE;
8300 }
8301
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008302 if (param_buf->num_data > WMI_SVC_MSG_MAX_SIZE - sizeof(*ev)) {
8303 WMI_LOGE("num_data : %u is invalid", param_buf->num_data);
8304 return QDF_STATUS_E_FAULT;
8305 }
8306
Govind Singhe7f2f342016-05-23 12:12:52 +05308307 switch (ev->stats_id) {
8308 case WMI_REQUEST_PEER_STAT:
8309 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
8310 break;
8311
8312 case WMI_REQUEST_AP_STAT:
8313 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
8314 break;
8315
8316 case WMI_REQUEST_PDEV_STAT:
8317 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
8318 break;
8319
8320 case WMI_REQUEST_VDEV_STAT:
8321 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
8322 break;
8323
8324 case WMI_REQUEST_BCNFLT_STAT:
8325 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
8326 break;
8327
8328 case WMI_REQUEST_VDEV_RATE_STAT:
8329 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
8330 break;
8331
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308332 case WMI_REQUEST_BCN_STAT:
8333 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
8334 break;
8335
Govind Singhe7f2f342016-05-23 12:12:52 +05308336 default:
8337 stats_param->stats_id = 0;
8338 break;
8339
8340 }
8341
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008342 /* ev->num_*_stats may cause uint32_t overflow, so use uint64_t
8343 * to save total length calculated
8344 */
8345 min_data_len =
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308346 (((uint64_t)ev->num_pdev_stats) * sizeof(wmi_pdev_stats_v2)) +
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008347 (((uint64_t)ev->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8348 (((uint64_t)ev->num_peer_stats) * sizeof(wmi_peer_stats)) +
8349 (((uint64_t)ev->num_bcnflt_stats) *
8350 sizeof(wmi_bcnfilter_stats_t)) +
8351 (((uint64_t)ev->num_chan_stats) * sizeof(wmi_chan_stats)) +
8352 (((uint64_t)ev->num_mib_stats) * sizeof(wmi_mib_stats)) +
8353 (((uint64_t)ev->num_bcn_stats) * sizeof(wmi_bcn_stats)) +
8354 (((uint64_t)ev->num_peer_extd_stats) *
8355 sizeof(wmi_peer_extd_stats));
8356 if (param_buf->num_data != min_data_len) {
8357 WMI_LOGE("data len: %u isn't same as calculated: %llu",
8358 param_buf->num_data, min_data_len);
8359 return QDF_STATUS_E_FAULT;
8360 }
8361
Govind Singhe7f2f342016-05-23 12:12:52 +05308362 stats_param->num_pdev_stats = ev->num_pdev_stats;
8363 stats_param->num_pdev_ext_stats = 0;
8364 stats_param->num_vdev_stats = ev->num_vdev_stats;
8365 stats_param->num_peer_stats = ev->num_peer_stats;
8366 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
8367 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308368 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05308369 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8370 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308371
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008372 /* if chain_stats is not populated */
8373 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
8374 return QDF_STATUS_SUCCESS;
8375
8376 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
8377 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
8378 return QDF_STATUS_SUCCESS;
8379
8380 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -07008381 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008382 return QDF_STATUS_SUCCESS;
8383
Harprit Chhabada4efe1fa2018-09-28 12:06:49 -07008384 if (rssi_event->num_per_chain_rssi_stats >=
8385 WMITLV_GET_TLVLEN(rssi_event->tlv_header)) {
8386 WMI_LOGE("num_per_chain_rssi_stats:%u is out of bounds",
8387 rssi_event->num_per_chain_rssi_stats);
8388 return QDF_STATUS_E_INVAL;
8389 }
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008390 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
8391
Govind Singhe7f2f342016-05-23 12:12:52 +05308392 return QDF_STATUS_SUCCESS;
8393}
8394
8395/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308396 * extract_pdev_tx_stats() - extract pdev tx stats from event
8397 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308398static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx,
8399 struct wlan_dbg_tx_stats_v2 *tx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308400{
8401 /* Tx Stats */
8402 tx->comp_queued = tx_stats->comp_queued;
8403 tx->comp_delivered = tx_stats->comp_delivered;
8404 tx->msdu_enqued = tx_stats->msdu_enqued;
8405 tx->mpdu_enqued = tx_stats->mpdu_enqued;
8406 tx->wmm_drop = tx_stats->wmm_drop;
8407 tx->local_enqued = tx_stats->local_enqued;
8408 tx->local_freed = tx_stats->local_freed;
8409 tx->hw_queued = tx_stats->hw_queued;
8410 tx->hw_reaped = tx_stats->hw_reaped;
8411 tx->underrun = tx_stats->underrun;
8412 tx->tx_abort = tx_stats->tx_abort;
8413 tx->mpdus_requed = tx_stats->mpdus_requed;
8414 tx->data_rc = tx_stats->data_rc;
8415 tx->self_triggers = tx_stats->self_triggers;
8416 tx->sw_retry_failure = tx_stats->sw_retry_failure;
8417 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
8418 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
8419 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
8420 tx->pdev_resets = tx_stats->pdev_resets;
8421 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
8422 tx->phy_underrun = tx_stats->phy_underrun;
8423 tx->txop_ovf = tx_stats->txop_ovf;
8424
8425 return;
8426}
8427
8428
8429/**
8430 * extract_pdev_rx_stats() - extract pdev rx stats from event
8431 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308432static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx,
8433 struct wlan_dbg_rx_stats_v2 *rx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308434{
8435 /* Rx Stats */
8436 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
8437 rx->status_rcvd = rx_stats->status_rcvd;
8438 rx->r0_frags = rx_stats->r0_frags;
8439 rx->r1_frags = rx_stats->r1_frags;
8440 rx->r2_frags = rx_stats->r2_frags;
8441 /* Only TLV */
8442 rx->r3_frags = 0;
8443 rx->htt_msdus = rx_stats->htt_msdus;
8444 rx->htt_mpdus = rx_stats->htt_mpdus;
8445 rx->loc_msdus = rx_stats->loc_msdus;
8446 rx->loc_mpdus = rx_stats->loc_mpdus;
8447 rx->oversize_amsdu = rx_stats->oversize_amsdu;
8448 rx->phy_errs = rx_stats->phy_errs;
8449 rx->phy_err_drop = rx_stats->phy_err_drop;
8450 rx->mpdu_errs = rx_stats->mpdu_errs;
8451
8452 return;
8453}
8454
8455/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308456 * extract_pdev_stats_tlv() - extract pdev stats from event
8457 * @wmi_handle: wmi handle
8458 * @param evt_buf: pointer to event buffer
8459 * @param index: Index into pdev stats
8460 * @param pdev_stats: Pointer to hold pdev stats
8461 *
8462 * Return: QDF_STATUS_SUCCESS for success or error code
8463 */
8464static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
8465 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
8466{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308467 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8468 wmi_stats_event_fixed_param *ev_param;
8469 uint8_t *data;
8470
8471 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8472 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8473
8474 data = param_buf->data;
8475
8476 if (index < ev_param->num_pdev_stats) {
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308477 wmi_pdev_stats_v2 *ev = (wmi_pdev_stats_v2 *) ((data) +
8478 (index * sizeof(wmi_pdev_stats_v2)));
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308479
8480 pdev_stats->chan_nf = ev->chan_nf;
8481 pdev_stats->tx_frame_count = ev->tx_frame_count;
8482 pdev_stats->rx_frame_count = ev->rx_frame_count;
8483 pdev_stats->rx_clear_count = ev->rx_clear_count;
8484 pdev_stats->cycle_count = ev->cycle_count;
8485 pdev_stats->phy_err_count = ev->phy_err_count;
8486 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
8487
8488 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
8489 &(ev->pdev_stats.tx));
8490 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
8491 &(ev->pdev_stats.rx));
8492 }
8493
Govind Singhe7f2f342016-05-23 12:12:52 +05308494 return QDF_STATUS_SUCCESS;
8495}
8496
8497/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008498 * extract_unit_test_tlv() - extract unit test data
8499 * @wmi_handle: wmi handle
8500 * @param evt_buf: pointer to event buffer
8501 * @param unit_test: pointer to hold unit test data
8502 * @param maxspace: Amount of space in evt_buf
8503 *
8504 * Return: QDF_STATUS_SUCCESS for success or error code
8505 */
8506static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
8507 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
8508{
8509 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
8510 wmi_unit_test_event_fixed_param *ev_param;
8511 uint32_t num_bufp;
8512 uint32_t copy_size;
8513 uint8_t *bufp;
8514
8515 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
8516 ev_param = param_buf->fixed_param;
8517 bufp = param_buf->bufp;
8518 num_bufp = param_buf->num_bufp;
8519 unit_test->vdev_id = ev_param->vdev_id;
8520 unit_test->module_id = ev_param->module_id;
8521 unit_test->diag_token = ev_param->diag_token;
8522 unit_test->flag = ev_param->flag;
8523 unit_test->payload_len = ev_param->payload_len;
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308524 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d", __func__,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008525 ev_param->vdev_id,
8526 ev_param->module_id,
8527 ev_param->diag_token,
8528 ev_param->flag);
8529 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
8530 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
8531 bufp, num_bufp);
8532 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
8533 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
8534 unit_test->buffer_len = copy_size;
8535
8536 return QDF_STATUS_SUCCESS;
8537}
8538
8539/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308540 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
8541 * @wmi_handle: wmi handle
8542 * @param evt_buf: pointer to event buffer
8543 * @param index: Index into extended pdev stats
8544 * @param pdev_ext_stats: Pointer to hold extended pdev stats
8545 *
8546 * Return: QDF_STATUS_SUCCESS for success or error code
8547 */
8548static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
8549 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
8550{
8551 return QDF_STATUS_SUCCESS;
8552}
8553
8554/**
8555 * extract_vdev_stats_tlv() - extract vdev stats from event
8556 * @wmi_handle: wmi handle
8557 * @param evt_buf: pointer to event buffer
8558 * @param index: Index into vdev stats
8559 * @param vdev_stats: Pointer to hold vdev stats
8560 *
8561 * Return: QDF_STATUS_SUCCESS for success or error code
8562 */
8563static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
8564 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
8565{
8566 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8567 wmi_stats_event_fixed_param *ev_param;
8568 uint8_t *data;
8569
8570 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8571 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8572 data = (uint8_t *) param_buf->data;
8573
8574 if (index < ev_param->num_vdev_stats) {
8575 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
8576 ((ev_param->num_pdev_stats) *
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308577 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308578 (index * sizeof(wmi_vdev_stats)));
8579
8580 vdev_stats->vdev_id = ev->vdev_id;
8581 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
8582 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
8583
8584 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
8585 sizeof(ev->tx_frm_cnt));
8586 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
8587 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
8588 ev->multiple_retry_cnt,
8589 sizeof(ev->multiple_retry_cnt));
8590 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
8591 sizeof(ev->fail_cnt));
8592 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
8593 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
8594 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
8595 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
8596 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
8597 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
8598 sizeof(ev->tx_rate_history));
8599 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
8600 sizeof(ev->bcn_rssi_history));
8601
8602 }
8603
8604 return QDF_STATUS_SUCCESS;
8605}
8606
8607/**
Naveen Rawatd2115722018-04-12 08:17:55 -07008608 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
8609 * buffer
8610 * @wmi_handle: wmi handle
8611 * @evt_buf: pointer to event buffer
8612 * @index: Index into vdev stats
8613 * @rssi_stats: Pointer to hold rssi stats
8614 *
8615 * Return: QDF_STATUS_SUCCESS for success or error code
8616 */
8617static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
8618 void *evt_buf, uint32_t index,
8619 struct wmi_host_per_chain_rssi_stats *rssi_stats)
8620{
8621 uint8_t *data;
8622 wmi_rssi_stats *fw_rssi_stats;
8623 wmi_per_chain_rssi_stats *rssi_event;
8624 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8625
8626 if (!evt_buf) {
8627 WMI_LOGE("evt_buf is null");
8628 return QDF_STATUS_E_NULL_VALUE;
8629 }
8630
8631 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8632 rssi_event = param_buf->chain_stats;
8633
8634 if (index >= rssi_event->num_per_chain_rssi_stats) {
8635 WMI_LOGE("invalid index");
8636 return QDF_STATUS_E_INVAL;
8637 }
8638
8639 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
8640 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
8641
8642 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
8643 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
8644 fw_rssi_stats->rssi_avg_beacon,
8645 sizeof(fw_rssi_stats->rssi_avg_beacon));
8646 qdf_mem_copy(rssi_stats->rssi_avg_data,
8647 fw_rssi_stats->rssi_avg_data,
8648 sizeof(fw_rssi_stats->rssi_avg_data));
8649 qdf_mem_copy(&rssi_stats->peer_macaddr,
8650 &fw_rssi_stats->peer_macaddr,
8651 sizeof(fw_rssi_stats->peer_macaddr));
8652
8653 return QDF_STATUS_SUCCESS;
8654}
8655
8656
8657
8658/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308659 * extract_bcn_stats_tlv() - extract bcn stats from event
8660 * @wmi_handle: wmi handle
8661 * @param evt_buf: pointer to event buffer
8662 * @param index: Index into vdev stats
8663 * @param bcn_stats: Pointer to hold bcn stats
8664 *
8665 * Return: QDF_STATUS_SUCCESS for success or error code
8666 */
8667static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
8668 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
8669{
8670 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8671 wmi_stats_event_fixed_param *ev_param;
8672 uint8_t *data;
8673
8674 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8675 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8676 data = (uint8_t *) param_buf->data;
8677
8678 if (index < ev_param->num_bcn_stats) {
8679 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308680 ((ev_param->num_pdev_stats) *
8681 sizeof(wmi_pdev_stats_v2)) +
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308682 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8683 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8684 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
8685 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
8686 (index * sizeof(wmi_bcn_stats)));
8687
8688 bcn_stats->vdev_id = ev->vdev_id;
8689 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
8690 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
8691 }
8692
8693 return QDF_STATUS_SUCCESS;
8694}
8695
8696/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308697 * extract_peer_stats_tlv() - extract peer stats from event
8698 * @wmi_handle: wmi handle
8699 * @param evt_buf: pointer to event buffer
8700 * @param index: Index into peer stats
8701 * @param peer_stats: Pointer to hold peer stats
8702 *
8703 * Return: QDF_STATUS_SUCCESS for success or error code
8704 */
8705static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
8706 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
8707{
8708 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8709 wmi_stats_event_fixed_param *ev_param;
8710 uint8_t *data;
8711
8712 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8713 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8714 data = (uint8_t *) param_buf->data;
8715
8716 if (index < ev_param->num_peer_stats) {
8717 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308718 ((ev_param->num_pdev_stats) *
8719 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308720 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8721 (index * sizeof(wmi_peer_stats)));
8722
8723 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
8724
8725 OS_MEMCPY(&(peer_stats->peer_macaddr),
8726 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
8727
8728 peer_stats->peer_rssi = ev->peer_rssi;
8729 peer_stats->peer_tx_rate = ev->peer_tx_rate;
8730 peer_stats->peer_rx_rate = ev->peer_rx_rate;
8731 }
8732
8733 return QDF_STATUS_SUCCESS;
8734}
8735
8736/**
8737 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
8738 * @wmi_handle: wmi handle
8739 * @param evt_buf: pointer to event buffer
8740 * @param index: Index into bcn fault stats
8741 * @param bcnflt_stats: Pointer to hold bcn fault stats
8742 *
8743 * Return: QDF_STATUS_SUCCESS for success or error code
8744 */
8745static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
8746 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
8747{
8748 return QDF_STATUS_SUCCESS;
8749}
8750
8751/**
8752 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
8753 * @wmi_handle: wmi handle
8754 * @param evt_buf: pointer to event buffer
8755 * @param index: Index into extended peer stats
8756 * @param peer_extd_stats: Pointer to hold extended peer stats
8757 *
8758 * Return: QDF_STATUS_SUCCESS for success or error code
8759 */
8760static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
8761 void *evt_buf, uint32_t index,
8762 wmi_host_peer_extd_stats *peer_extd_stats)
8763{
8764 return QDF_STATUS_SUCCESS;
8765}
8766
8767/**
8768 * extract_chan_stats_tlv() - extract chan stats from event
8769 * @wmi_handle: wmi handle
8770 * @param evt_buf: pointer to event buffer
8771 * @param index: Index into chan stats
8772 * @param vdev_extd_stats: Pointer to hold chan stats
8773 *
8774 * Return: QDF_STATUS_SUCCESS for success or error code
8775 */
8776static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
8777 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
8778{
8779 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8780 wmi_stats_event_fixed_param *ev_param;
8781 uint8_t *data;
8782
8783 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8784 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8785 data = (uint8_t *) param_buf->data;
8786
8787 if (index < ev_param->num_chan_stats) {
8788 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308789 ((ev_param->num_pdev_stats) *
8790 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308791 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8792 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8793 (index * sizeof(wmi_chan_stats)));
8794
8795
Jeff Johnson79eaacb2018-05-06 17:53:18 -07008796 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +05308797 chan_stats->chan_mhz = ev->chan_mhz;
8798 chan_stats->sampling_period_us = ev->sampling_period_us;
8799 chan_stats->rx_clear_count = ev->rx_clear_count;
8800 chan_stats->tx_duration_us = ev->tx_duration_us;
8801 chan_stats->rx_duration_us = ev->rx_duration_us;
8802 }
8803
8804 return QDF_STATUS_SUCCESS;
8805}
8806
8807/**
8808 * extract_profile_ctx_tlv() - extract profile context from event
8809 * @wmi_handle: wmi handle
8810 * @param evt_buf: pointer to event buffer
8811 * @idx: profile stats index to extract
8812 * @param profile_ctx: Pointer to hold profile context
8813 *
8814 * Return: QDF_STATUS_SUCCESS for success or error code
8815 */
8816static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
8817 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
8818{
8819 return QDF_STATUS_SUCCESS;
8820}
8821
8822/**
8823 * extract_profile_data_tlv() - extract profile data from event
8824 * @wmi_handle: wmi handle
8825 * @param evt_buf: pointer to event buffer
8826 * @param profile_data: Pointer to hold profile data
8827 *
8828 * Return: QDF_STATUS_SUCCESS for success or error code
8829 */
8830static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
8831 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
8832{
8833
8834 return QDF_STATUS_SUCCESS;
8835}
8836
8837/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308838 * extract_pdev_utf_event_tlv() - extract UTF data info from event
8839 * @wmi_handle: WMI handle
8840 * @param evt_buf: Pointer to event buffer
8841 * @param param: Pointer to hold data
8842 *
8843 * Return : QDF_STATUS_SUCCESS for success or error code
8844 */
8845static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
8846 uint8_t *evt_buf,
8847 struct wmi_host_pdev_utf_event *event)
8848{
8849 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308850 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308851
8852 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
8853 event->data = param_buf->data;
8854 event->datalen = param_buf->num_data;
Pragaspathi Thilagarajd8d0e152018-09-04 14:39:09 +05308855
8856 if (event->datalen < sizeof(struct wmi_host_utf_seg_header_info)) {
8857 WMI_LOGE("%s: Invalid datalen: %d ", __func__, event->datalen);
8858 return QDF_STATUS_E_INVAL;
8859 }
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308860 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +05308861 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308862 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308863 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308864
8865 return QDF_STATUS_SUCCESS;
8866}
Govind Singhe7f2f342016-05-23 12:12:52 +05308867
Kiran Venkatappa06520822016-08-10 23:55:40 +05308868/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308869 * extract_chainmask_tables_tlv() - extract chain mask tables from event
8870 * @wmi_handle: wmi handle
8871 * @param evt_buf: pointer to event buffer
8872 * @param param: Pointer to hold evt buf
8873 *
8874 * Return: QDF_STATUS_SUCCESS for success or error code
8875 */
8876static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
8877 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
8878{
8879 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
8880 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
8881 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
8882 uint8_t i = 0, j = 0;
8883
8884 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
8885 if (!param_buf)
8886 return QDF_STATUS_E_INVAL;
8887
8888 hw_caps = param_buf->soc_hw_mode_caps;
8889 if (!hw_caps)
8890 return QDF_STATUS_E_INVAL;
8891
Wu Gao5d1c9ed2018-10-12 18:16:09 +08008892 if ((!hw_caps->num_chainmask_tables) ||
Pragaspathi Thilagaraj9ad6eca2018-10-24 18:36:47 +05308893 (hw_caps->num_chainmask_tables > PSOC_MAX_CHAINMASK_TABLES) ||
8894 (hw_caps->num_chainmask_tables >
8895 param_buf->num_mac_phy_chainmask_combo))
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308896 return QDF_STATUS_E_INVAL;
8897
8898 chainmask_caps = param_buf->mac_phy_chainmask_caps;
8899
8900 if (chainmask_caps == NULL)
8901 return QDF_STATUS_E_INVAL;
8902
8903 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
8904
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308905 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308906 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
8907
8908 chainmask_table[i].cap_list[j].chainmask =
8909 chainmask_caps->chainmask;
8910
8911 chainmask_table[i].cap_list[j].supports_chan_width_20 =
8912 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
8913
8914 chainmask_table[i].cap_list[j].supports_chan_width_40 =
8915 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
8916
8917 chainmask_table[i].cap_list[j].supports_chan_width_80 =
8918 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
8919
8920 chainmask_table[i].cap_list[j].supports_chan_width_160 =
8921 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
8922
8923 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
8924 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
8925
8926 chainmask_table[i].cap_list[j].chain_mask_2G =
8927 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
8928
8929 chainmask_table[i].cap_list[j].chain_mask_5G =
8930 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
8931
8932 chainmask_table[i].cap_list[j].chain_mask_tx =
8933 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
8934
8935 chainmask_table[i].cap_list[j].chain_mask_rx =
8936 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
8937
8938 chainmask_table[i].cap_list[j].supports_aDFS =
8939 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
8940
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308941 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
8942 chainmask_caps->supported_flags,
8943 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308944 );
8945 chainmask_caps++;
8946 }
8947 }
8948
8949 return QDF_STATUS_SUCCESS;
8950}
8951
8952/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05308953 * extract_service_ready_ext_tlv() - extract basic extended service ready params
8954 * from event
8955 * @wmi_handle: wmi handle
8956 * @param evt_buf: pointer to event buffer
8957 * @param param: Pointer to hold evt buf
8958 *
8959 * Return: QDF_STATUS_SUCCESS for success or error code
8960 */
8961static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08008962 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05308963{
8964 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
8965 wmi_service_ready_ext_event_fixed_param *ev;
8966 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
8967 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308968 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
8969 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308970
8971 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
8972 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308973 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308974
8975 ev = param_buf->fixed_param;
8976 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308977 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308978
8979 /* Move this to host based bitmap */
8980 param->default_conc_scan_config_bits =
8981 ev->default_conc_scan_config_bits;
8982 param->default_fw_config_bits = ev->default_fw_config_bits;
8983 param->he_cap_info = ev->he_cap_info;
8984 param->mpdu_density = ev->mpdu_density;
8985 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05308986 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +05308987 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07008988 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308989 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
8990
8991 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308992 if (hw_caps)
8993 param->num_hw_modes = hw_caps->num_hw_modes;
8994 else
8995 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308996
8997 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308998 if (reg_caps)
8999 param->num_phy = reg_caps->num_phy;
9000 else
9001 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309002
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309003 if (hw_caps) {
9004 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309005 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309006 } else
9007 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309008
Harprit Chhabada00ef4b72018-10-18 13:27:56 -07009009 if (param->num_chainmask_tables > PSOC_MAX_CHAINMASK_TABLES ||
9010 param->num_chainmask_tables >
9011 param_buf->num_mac_phy_chainmask_combo) {
9012 wmi_err_rl("num_chainmask_tables is OOB: %u",
9013 param->num_chainmask_tables);
9014 return QDF_STATUS_E_INVAL;
9015 }
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309016 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
9017
9018 if (chain_mask_combo == NULL)
9019 return QDF_STATUS_SUCCESS;
9020
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309021 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309022
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309023 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309024
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309025 qdf_print("table_id : %d Num valid chainmasks: %d",
9026 chain_mask_combo->chainmask_table_id,
9027 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309028 );
9029
9030 param->chainmask_table[i].table_id =
9031 chain_mask_combo->chainmask_table_id;
9032 param->chainmask_table[i].num_valid_chainmasks =
9033 chain_mask_combo->num_valid_chainmask;
9034 chain_mask_combo++;
9035 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309036 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309037
Kiran Venkatappa06520822016-08-10 23:55:40 +05309038 return QDF_STATUS_SUCCESS;
9039}
9040
9041/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009042 * extract_sar_cap_service_ready_ext_tlv() -
9043 * extract SAR cap from service ready event
9044 * @wmi_handle: wmi handle
9045 * @event: pointer to event buffer
9046 * @ext_param: extended target info
9047 *
9048 * Return: QDF_STATUS_SUCCESS for success or error code
9049 */
9050static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
9051 wmi_unified_t wmi_handle,
9052 uint8_t *event,
9053 struct wlan_psoc_host_service_ext_param *ext_param)
9054{
9055 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9056 WMI_SAR_CAPABILITIES *sar_caps;
9057
9058 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9059
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009060 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009061 return QDF_STATUS_E_INVAL;
9062
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009063 sar_caps = param_buf->sar_caps;
9064 if (sar_caps)
9065 ext_param->sar_version = sar_caps->active_version;
9066 else
9067 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009068
9069 return QDF_STATUS_SUCCESS;
9070}
9071
9072/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05309073 * extract_hw_mode_cap_service_ready_ext_tlv() -
9074 * extract HW mode cap from service ready event
9075 * @wmi_handle: wmi handle
9076 * @param evt_buf: pointer to event buffer
9077 * @param param: Pointer to hold evt buf
9078 * @param hw_mode_idx: hw mode idx should be less than num_mode
9079 *
9080 * Return: QDF_STATUS_SUCCESS for success or error code
9081 */
9082static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
9083 wmi_unified_t wmi_handle,
9084 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009085 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309086{
9087 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9088 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9089
9090 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9091 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309092 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309093
9094 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309095 if (!hw_caps)
9096 return QDF_STATUS_E_INVAL;
9097
Kiran Venkatappa06520822016-08-10 23:55:40 +05309098 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309099 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309100
9101 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
9102 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
9103
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309104 param->hw_mode_config_type =
9105 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
9106
Kiran Venkatappa06520822016-08-10 23:55:40 +05309107 return QDF_STATUS_SUCCESS;
9108}
9109
9110/**
9111 * extract_mac_phy_cap_service_ready_ext_tlv() -
9112 * extract MAC phy cap from service ready event
9113 * @wmi_handle: wmi handle
9114 * @param evt_buf: pointer to event buffer
9115 * @param param: Pointer to hold evt buf
9116 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309117 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +05309118 *
9119 * Return: QDF_STATUS_SUCCESS for success or error code
9120 */
9121static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
9122 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309123 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009124 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309125{
9126 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309127 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309128 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9129 uint32_t phy_map;
9130 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309131
9132 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9133 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309134 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309135
9136 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309137 if (!hw_caps)
9138 return QDF_STATUS_E_INVAL;
9139
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309140 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
9141 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
9142 break;
9143
9144 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
9145 while (phy_map) {
9146 phy_map >>= 1;
9147 phy_idx++;
9148 }
9149 }
9150
9151 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309152 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309153
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309154 phy_idx += phy_id;
9155 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309156 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309157
9158 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +05309159
9160 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309161 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9162 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309163 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309164 param->supports_11b =
9165 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
9166 param->supports_11g =
9167 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
9168 param->supports_11a =
9169 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
9170 param->supports_11n =
9171 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
9172 param->supports_11ac =
9173 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
9174 param->supports_11ax =
9175 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309176
9177 param->supported_bands = mac_phy_caps->supported_bands;
9178 param->ampdu_density = mac_phy_caps->ampdu_density;
9179 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
9180 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
9181 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
9182 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009183 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD1] =
9184 mac_phy_caps->he_cap_info_2G;
9185 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD2] =
9186 mac_phy_caps->he_cap_info_2G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309187 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
9188 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
9189 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
9190 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
9191 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
9192 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
9193 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009194 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD1] =
9195 mac_phy_caps->he_cap_info_5G;
9196 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD2] =
9197 mac_phy_caps->he_cap_info_5G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309198 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
9199 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
9200 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -08009201 qdf_mem_copy(&param->he_cap_phy_info_2G,
9202 &mac_phy_caps->he_cap_phy_info_2G,
9203 sizeof(param->he_cap_phy_info_2G));
9204 qdf_mem_copy(&param->he_cap_phy_info_5G,
9205 &mac_phy_caps->he_cap_phy_info_5G,
9206 sizeof(param->he_cap_phy_info_5G));
9207 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
9208 sizeof(param->he_ppet2G));
9209 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
9210 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309211 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309212
9213 return QDF_STATUS_SUCCESS;
9214}
9215
9216/**
9217 * extract_reg_cap_service_ready_ext_tlv() -
9218 * extract REG cap from service ready event
9219 * @wmi_handle: wmi handle
9220 * @param evt_buf: pointer to event buffer
9221 * @param param: Pointer to hold evt buf
9222 * @param phy_idx: phy idx should be less than num_mode
9223 *
9224 * Return: QDF_STATUS_SUCCESS for success or error code
9225 */
9226static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
9227 wmi_unified_t wmi_handle,
9228 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009229 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309230{
9231 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9232 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
9233 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
9234
9235 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9236 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309237 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309238
9239 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309240 if (!reg_caps)
9241 return QDF_STATUS_E_INVAL;
9242
Kiran Venkatappa06520822016-08-10 23:55:40 +05309243 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309244 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309245
9246 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
9247
9248 param->phy_id = ext_reg_cap->phy_id;
9249 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
9250 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
9251 param->regcap1 = ext_reg_cap->regcap1;
9252 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05309253 param->wireless_modes = convert_wireless_modes_tlv(
9254 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309255 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
9256 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
9257 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
9258 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
9259
9260 return QDF_STATUS_SUCCESS;
9261}
9262
Sathish Kumarf396c722017-11-17 17:30:41 +05309263static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
9264 wmi_unified_t wmi_handle,
9265 uint8_t *event, uint8_t idx,
9266 struct wlan_psoc_host_dbr_ring_caps *param)
9267{
9268 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9269 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
9270
9271 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9272 if (!param_buf)
9273 return QDF_STATUS_E_INVAL;
9274
9275 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
9276
9277 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9278 dbr_ring_caps->pdev_id);
9279 param->mod_id = dbr_ring_caps->mod_id;
9280 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
9281 param->min_buf_size = dbr_ring_caps->min_buf_size;
9282 param->min_buf_align = dbr_ring_caps->min_buf_align;
9283
9284 return QDF_STATUS_SUCCESS;
9285}
9286
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309287/**
9288 * extract_thermal_stats_tlv() - extract thermal stats from event
9289 * @wmi_handle: wmi handle
9290 * @param evt_buf: Pointer to event buffer
9291 * @param temp: Pointer to hold extracted temperature
9292 * @param level: Pointer to hold extracted level
9293 *
9294 * Return: 0 for success or error code
9295 */
9296static QDF_STATUS
9297extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
9298 void *evt_buf, uint32_t *temp,
9299 uint32_t *level, uint32_t *pdev_id)
9300{
9301 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9302 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
9303
9304 param_buf =
9305 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9306 if (!param_buf)
9307 return QDF_STATUS_E_INVAL;
9308
9309 tt_stats_event = param_buf->fixed_param;
9310
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309311 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9312 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309313 *temp = tt_stats_event->temp;
9314 *level = tt_stats_event->level;
9315
9316 return QDF_STATUS_SUCCESS;
9317}
9318
9319/**
9320 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
9321 * @wmi_handle: wmi handle
9322 * @param evt_buf: pointer to event buffer
9323 * @param idx: Index to level stats
9324 * @param levelcount: Pointer to hold levelcount
9325 * @param dccount: Pointer to hold dccount
9326 *
9327 * Return: 0 for success or error code
9328 */
9329static QDF_STATUS
9330extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
9331 void *evt_buf, uint8_t idx, uint32_t *levelcount,
9332 uint32_t *dccount)
9333{
9334 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9335 wmi_therm_throt_level_stats_info *tt_level_info;
9336
9337 param_buf =
9338 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9339 if (!param_buf)
9340 return QDF_STATUS_E_INVAL;
9341
9342 tt_level_info = param_buf->therm_throt_level_stats_info;
9343
9344 if (idx < THERMAL_LEVELS) {
9345 *levelcount = tt_level_info[idx].level_count;
9346 *dccount = tt_level_info[idx].dc_count;
9347 return QDF_STATUS_SUCCESS;
9348 }
9349
9350 return QDF_STATUS_E_FAILURE;
9351}
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309352#ifdef BIG_ENDIAN_HOST
9353/**
9354 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
9355 * @param data_len - data length
9356 * @param data - pointer to data
9357 *
9358 * Return: QDF_STATUS - success or error status
9359 */
9360static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9361{
9362 uint8_t *data_aligned = NULL;
9363 int c;
9364 unsigned char *data_unaligned;
9365
9366 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
9367 FIPS_ALIGN));
9368 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -07009369 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309370 if (data_unaligned == NULL)
9371 return QDF_STATUS_E_FAILURE;
9372
9373 /* Checking if space is alligned */
9374 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
9375 /* align the data space */
9376 data_aligned =
9377 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
9378 } else {
9379 data_aligned = (u_int8_t *)data_unaligned;
9380 }
9381
9382 /* memset and copy content from data to data aligned */
9383 OS_MEMSET(data_aligned, 0, data_len);
9384 OS_MEMCPY(data_aligned, data, data_len);
9385 /* Endianness to LE */
9386 for (c = 0; c < data_len/4; c++) {
9387 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +05309388 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309389 }
9390
9391 /* Copy content to event->data */
9392 OS_MEMCPY(data, data_aligned, data_len);
9393
9394 /* clean up allocated space */
9395 qdf_mem_free(data_unaligned);
9396 data_aligned = NULL;
9397 data_unaligned = NULL;
9398
9399 /*************************************************************/
9400
9401 return QDF_STATUS_SUCCESS;
9402}
9403#else
9404/**
9405 * fips_conv_data_be() - DUMMY for LE platform
9406 *
9407 * Return: QDF_STATUS - success
9408 */
9409static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9410{
9411 return QDF_STATUS_SUCCESS;
9412}
9413#endif
9414
9415/**
9416 * extract_fips_event_data_tlv() - extract fips event data
9417 * @wmi_handle: wmi handle
9418 * @param evt_buf: pointer to event buffer
9419 * @param param: pointer FIPS event params
9420 *
9421 * Return: 0 for success or error code
9422 */
9423static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
9424 void *evt_buf, struct wmi_host_fips_event_param *param)
9425{
9426 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
9427 wmi_pdev_fips_event_fixed_param *event;
9428
9429 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
9430 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
9431
9432 if (fips_conv_data_be(event->data_len, param_buf->data) !=
9433 QDF_STATUS_SUCCESS)
9434 return QDF_STATUS_E_FAILURE;
9435
9436 param->data = (uint32_t *)param_buf->data;
9437 param->data_len = event->data_len;
9438 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309439 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9440 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309441
9442 return QDF_STATUS_SUCCESS;
9443}
9444
Govind Singhecf03cd2016-05-12 12:45:51 +05309445static bool is_management_record_tlv(uint32_t cmd_id)
9446{
Rajeev Kumar173bef42018-09-18 16:45:39 -07009447 switch (cmd_id) {
9448 case WMI_MGMT_TX_SEND_CMDID:
9449 case WMI_MGMT_TX_COMPLETION_EVENTID:
9450 case WMI_OFFCHAN_DATA_TX_SEND_CMDID:
9451 case WMI_MGMT_RX_EVENTID:
Govind Singhecf03cd2016-05-12 12:45:51 +05309452 return true;
Rajeev Kumar173bef42018-09-18 16:45:39 -07009453 default:
9454 return false;
jiad36c94d22018-01-22 15:37:03 +08009455 }
Govind Singhecf03cd2016-05-12 12:45:51 +05309456}
9457
Rajeev Kumarb64e1282018-09-19 13:02:23 -07009458static bool is_diag_event_tlv(uint32_t event_id)
9459{
9460 if (WMI_DIAG_EVENTID == event_id)
9461 return true;
9462
9463 return false;
9464}
9465
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309466static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9467{
9468 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
9469
9470 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
9471
9472 switch (set_cmd->param_id) {
9473 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
9474 case WMI_VDEV_PARAM_DTIM_POLICY:
9475 return HTC_TX_PACKET_TAG_AUTO_PM;
9476 default:
9477 break;
9478 }
9479
9480 return 0;
9481}
9482
9483static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9484{
9485 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
9486
9487 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
9488
9489 switch (ps_cmd->param) {
9490 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
9491 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
9492 case WMI_STA_PS_ENABLE_QPOWER:
9493 return HTC_TX_PACKET_TAG_AUTO_PM;
9494 default:
9495 break;
9496 }
9497
9498 return 0;
9499}
9500
9501static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
9502 uint32_t cmd_id)
9503{
9504 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
9505 return 0;
9506
9507 switch (cmd_id) {
9508 case WMI_VDEV_SET_PARAM_CMDID:
9509 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
9510 case WMI_STA_POWERSAVE_PARAM_CMDID:
9511 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
9512 default:
9513 break;
9514 }
9515
9516 return 0;
9517}
9518
9519static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
9520{
9521 uint16_t tag = 0;
9522
9523 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309524 pr_err("%s: Target is already suspended, Ignore FW Hang Command",
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309525 __func__);
9526 return tag;
9527 }
9528
9529 if (wmi_handle->tag_crash_inject)
9530 tag = HTC_TX_PACKET_TAG_AUTO_PM;
9531
9532 wmi_handle->tag_crash_inject = false;
9533 return tag;
9534}
9535
9536/**
9537 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
9538 * @wmi_handle: WMI handle
9539 * @buf: WMI buffer
9540 * @cmd_id: WMI command Id
9541 *
9542 * Return htc_tx_tag
9543 */
9544static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
9545 wmi_buf_t buf,
9546 uint32_t cmd_id)
9547{
9548 uint16_t htc_tx_tag = 0;
9549
9550 switch (cmd_id) {
9551 case WMI_WOW_ENABLE_CMDID:
9552 case WMI_PDEV_SUSPEND_CMDID:
9553 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
9554 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
9555 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
9556 case WMI_PDEV_RESUME_CMDID:
9557 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
9558 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
9559#ifdef FEATURE_WLAN_D0WOW
9560 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
9561#endif
9562 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
9563 break;
9564 case WMI_FORCE_FW_HANG_CMDID:
9565 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
9566 break;
9567 case WMI_VDEV_SET_PARAM_CMDID:
9568 case WMI_STA_POWERSAVE_PARAM_CMDID:
9569 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
9570 default:
9571 break;
9572 }
9573
9574 return htc_tx_tag;
9575}
9576
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309577static struct cur_reg_rule
9578*create_reg_rules_from_wmi(uint32_t num_reg_rules,
9579 wmi_regulatory_rule_struct *wmi_reg_rule)
9580{
9581 struct cur_reg_rule *reg_rule_ptr;
9582 uint32_t count;
9583
9584 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
9585
9586 if (NULL == reg_rule_ptr) {
9587 WMI_LOGE("memory allocation failure");
9588 return NULL;
9589 }
9590
9591 for (count = 0; count < num_reg_rules; count++) {
9592 reg_rule_ptr[count].start_freq =
9593 WMI_REG_RULE_START_FREQ_GET(
9594 wmi_reg_rule[count].freq_info);
9595 reg_rule_ptr[count].end_freq =
9596 WMI_REG_RULE_END_FREQ_GET(
9597 wmi_reg_rule[count].freq_info);
9598 reg_rule_ptr[count].max_bw =
9599 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009600 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309601 reg_rule_ptr[count].reg_power =
9602 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009603 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +05309604 reg_rule_ptr[count].ant_gain =
9605 WMI_REG_RULE_ANTENNA_GAIN_GET(
9606 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309607 reg_rule_ptr[count].flags =
9608 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009609 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309610 }
9611
9612 return reg_rule_ptr;
9613}
9614
9615static QDF_STATUS extract_reg_chan_list_update_event_tlv(
9616 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9617 struct cur_regulatory_info *reg_info, uint32_t len)
9618{
9619 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
9620 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
9621 wmi_regulatory_rule_struct *wmi_reg_rule;
9622 uint32_t num_2g_reg_rules, num_5g_reg_rules;
9623
9624 WMI_LOGD("processing regulatory channel list");
9625
9626 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
9627 if (!param_buf) {
9628 WMI_LOGE("invalid channel list event buf");
9629 return QDF_STATUS_E_FAILURE;
9630 }
9631
9632 chan_list_event_hdr = param_buf->fixed_param;
9633
9634 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
9635 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
Jianmin Zhu8a3cccb2018-10-10 17:03:28 +08009636 num_2g_reg_rules = reg_info->num_2g_reg_rules;
9637 num_5g_reg_rules = reg_info->num_5g_reg_rules;
9638 if ((num_2g_reg_rules > MAX_REG_RULES) ||
9639 (num_5g_reg_rules > MAX_REG_RULES) ||
9640 (num_2g_reg_rules + num_5g_reg_rules > MAX_REG_RULES) ||
9641 (num_2g_reg_rules + num_5g_reg_rules !=
9642 param_buf->num_reg_rule_array)) {
9643 wmi_err_rl("Invalid num_2g_reg_rules: %u, num_5g_reg_rules: %u",
9644 num_2g_reg_rules, num_5g_reg_rules);
9645 return QDF_STATUS_E_FAILURE;
9646 }
9647 if (param_buf->num_reg_rule_array >
9648 (WMI_SVC_MSG_MAX_SIZE - sizeof(*chan_list_event_hdr)) /
9649 sizeof(*wmi_reg_rule)) {
9650 wmi_err_rl("Invalid num_reg_rule_array: %u",
9651 param_buf->num_reg_rule_array);
9652 return QDF_STATUS_E_FAILURE;
9653 }
9654
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309655 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +05309656 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309657 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
9658 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -07009659 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -07009660 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +05309661 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -07009662 reg_info->ctry_code = chan_list_event_hdr->country_id;
9663 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
9664 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
9665 reg_info->status_code = REG_SET_CC_STATUS_PASS;
9666 else if (chan_list_event_hdr->status_code ==
9667 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
9668 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
9669 else if (chan_list_event_hdr->status_code ==
9670 WMI_REG_INIT_ALPHA2_NOT_FOUND)
9671 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
9672 else if (chan_list_event_hdr->status_code ==
9673 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
9674 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
9675 else if (chan_list_event_hdr->status_code ==
9676 WMI_REG_SET_CC_STATUS_NO_MEMORY)
9677 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
9678 else if (chan_list_event_hdr->status_code ==
9679 WMI_REG_SET_CC_STATUS_FAIL)
9680 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
9681
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309682 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
9683 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
9684 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
9685 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
9686
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009687 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
9688 __func__, reg_info->alpha2, reg_info->dfs_region,
9689 reg_info->min_bw_2g, reg_info->max_bw_2g,
9690 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309691
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009692 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
9693 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -07009694 wmi_reg_rule =
9695 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
9696 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
9697 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309698 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
9699 wmi_reg_rule);
9700 wmi_reg_rule += num_2g_reg_rules;
9701
9702 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
9703 wmi_reg_rule);
9704
9705 WMI_LOGD("processed regulatory channel list");
9706
9707 return QDF_STATUS_SUCCESS;
9708}
9709
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009710static QDF_STATUS extract_reg_11d_new_country_event_tlv(
9711 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9712 struct reg_11d_new_country *reg_11d_country, uint32_t len)
9713{
9714 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
9715 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
9716
9717 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
9718 if (!param_buf) {
9719 WMI_LOGE("invalid 11d country event buf");
9720 return QDF_STATUS_E_FAILURE;
9721 }
9722
9723 reg_11d_country_event = param_buf->fixed_param;
9724
9725 qdf_mem_copy(reg_11d_country->alpha2,
9726 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
Jianmin Zhuf6d5a652018-10-11 20:30:58 +08009727 reg_11d_country->alpha2[REG_ALPHA2_LEN] = '\0';
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009728
9729 WMI_LOGD("processed 11d country event, new cc %s",
9730 reg_11d_country->alpha2);
9731
9732 return QDF_STATUS_SUCCESS;
9733}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009734
9735static QDF_STATUS extract_reg_ch_avoid_event_tlv(
9736 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9737 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
9738{
9739 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
9740 wmi_avoid_freq_range_desc *afr_desc;
9741 uint32_t num_freq_ranges, freq_range_idx;
9742 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
9743 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
9744
9745 if (!param_buf) {
9746 WMI_LOGE("Invalid channel avoid event buffer");
9747 return QDF_STATUS_E_INVAL;
9748 }
9749
9750 afr_fixed_param = param_buf->fixed_param;
9751 if (!afr_fixed_param) {
9752 WMI_LOGE("Invalid channel avoid event fixed param buffer");
9753 return QDF_STATUS_E_INVAL;
9754 }
9755
9756 if (!ch_avoid_ind) {
9757 WMI_LOGE("Invalid channel avoid indication buffer");
9758 return QDF_STATUS_E_INVAL;
9759 }
Kiran Kumar Lokere7d312042018-09-19 16:55:34 -07009760 if (param_buf->num_avd_freq_range < afr_fixed_param->num_freq_ranges) {
9761 WMI_LOGE(FL("no.of freq ranges exceeded the limit"));
9762 return QDF_STATUS_E_INVAL;
9763 }
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009764 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
9765 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
9766 afr_fixed_param->num_freq_ranges;
9767
9768 WMI_LOGD("Channel avoid event received with %d ranges",
9769 num_freq_ranges);
9770
9771 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
9772 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
9773 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
9774 freq_range_idx++) {
9775 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
9776 afr_desc->start_freq;
9777 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
9778 afr_desc->end_freq;
9779 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
9780 freq_range_idx, afr_desc->tlv_header,
9781 afr_desc->start_freq, afr_desc->end_freq);
9782 afr_desc++;
9783 }
9784
9785 return QDF_STATUS_SUCCESS;
9786}
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309787
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009788#ifdef DFS_COMPONENT_ENABLE
9789/**
9790 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
9791 * @wmi_handle: wma handle
9792 * @evt_buf: event buffer
9793 * @vdev_id: vdev id
9794 * @len: length of buffer
9795 *
9796 * Return: 0 for success or error code
9797 */
9798static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
9799 uint8_t *evt_buf,
9800 uint32_t *vdev_id,
9801 uint32_t len)
9802{
9803 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
9804 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
9805
9806 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
9807 if (!param_tlvs) {
9808 WMI_LOGE("invalid cac complete event buf");
9809 return QDF_STATUS_E_FAILURE;
9810 }
9811
9812 cac_event = param_tlvs->fixed_param;
9813 *vdev_id = cac_event->vdev_id;
9814 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
9815
9816 return QDF_STATUS_SUCCESS;
9817}
9818
9819/**
9820 * extract_dfs_radar_detection_event_tlv() - extract radar found event
9821 * @wmi_handle: wma handle
9822 * @evt_buf: event buffer
9823 * @radar_found: radar found event info
9824 * @len: length of buffer
9825 *
9826 * Return: 0 for success or error code
9827 */
9828static QDF_STATUS extract_dfs_radar_detection_event_tlv(
9829 wmi_unified_t wmi_handle,
9830 uint8_t *evt_buf,
9831 struct radar_found_info *radar_found,
9832 uint32_t len)
9833{
9834 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
9835 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
9836
9837 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
9838 if (!param_tlv) {
9839 WMI_LOGE("invalid radar detection event buf");
9840 return QDF_STATUS_E_FAILURE;
9841 }
9842
9843 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -07009844 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
9845 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009846 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009847 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009848 radar_found->chan_width = radar_event->chan_width;
9849 radar_found->detector_id = radar_event->detector_id;
9850 radar_found->segment_id = radar_event->segment_id;
9851 radar_found->timestamp = radar_event->timestamp;
9852 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009853 radar_found->freq_offset = radar_event->freq_offset;
9854 radar_found->sidx = radar_event->sidx;
9855
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009856 WMI_LOGI("processed radar found event pdev %d,"
9857 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
9858 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
9859 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309860 "is_chirp %d,detection mode %d",
Arif Hussainb522ac92018-06-27 10:51:06 -07009861 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009862 radar_event->timestamp, radar_event->chan_freq,
9863 radar_event->chan_width, radar_event->detector_id,
9864 radar_event->freq_offset, radar_event->segment_id,
9865 radar_event->sidx, radar_event->is_chirp,
9866 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009867
9868 return QDF_STATUS_SUCCESS;
9869}
bings1ea12532017-12-18 16:56:53 +08009870
9871#ifdef QCA_MCL_DFS_SUPPORT
9872/**
9873 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
9874 * @wmi_handle: wma handle
9875 * @evt_buf: event buffer
9876 * @wlan_radar_event: Pointer to struct radar_event_info
9877 * @len: length of buffer
9878 *
9879 * Return: QDF_STATUS
9880 */
9881static QDF_STATUS extract_wlan_radar_event_info_tlv(
9882 wmi_unified_t wmi_handle,
9883 uint8_t *evt_buf,
9884 struct radar_event_info *wlan_radar_event,
9885 uint32_t len)
9886{
9887 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
9888 wmi_dfs_radar_event_fixed_param *radar_event;
9889
9890 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
9891 if (!param_tlv) {
9892 WMI_LOGE("invalid wlan radar event buf");
9893 return QDF_STATUS_E_FAILURE;
9894 }
9895
9896 radar_event = param_tlv->fixed_param;
9897 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
9898 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
9899 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
9900 wlan_radar_event->rssi = radar_event->rssi;
9901 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
9902 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
9903 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
9904 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +08009905 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
9906 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +08009907 if (radar_event->pulse_flags &
9908 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
9909 wlan_radar_event->is_psidx_diff_valid = true;
9910 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
9911 } else {
9912 wlan_radar_event->is_psidx_diff_valid = false;
9913 }
9914
bings1ea12532017-12-18 16:56:53 +08009915 wlan_radar_event->pdev_id = radar_event->pdev_id;
9916
9917 return QDF_STATUS_SUCCESS;
9918}
9919#else
9920static QDF_STATUS extract_wlan_radar_event_info_tlv(
9921 wmi_unified_t wmi_handle,
9922 uint8_t *evt_buf,
9923 struct radar_event_info *wlan_radar_event,
9924 uint32_t len)
9925{
9926 return QDF_STATUS_SUCCESS;
9927}
9928#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009929#endif
9930
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009931/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309932 * send_get_rcpi_cmd_tlv() - send request for rcpi value
9933 * @wmi_handle: wmi handle
9934 * @get_rcpi_param: rcpi params
9935 *
9936 * Return: QDF status
9937 */
9938static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
9939 struct rcpi_req *get_rcpi_param)
9940{
9941 wmi_buf_t buf;
9942 wmi_request_rcpi_cmd_fixed_param *cmd;
9943 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
9944
9945 buf = wmi_buf_alloc(wmi_handle, len);
9946 if (!buf) {
9947 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
9948 return QDF_STATUS_E_NOMEM;
9949 }
9950
9951 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
9952 WMITLV_SET_HDR(&cmd->tlv_header,
9953 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
9954 WMITLV_GET_STRUCT_TLVLEN
9955 (wmi_request_rcpi_cmd_fixed_param));
9956
9957 cmd->vdev_id = get_rcpi_param->vdev_id;
9958 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
9959 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -07009960
9961 switch (get_rcpi_param->measurement_type) {
9962
9963 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
9964 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
9965 break;
9966
9967 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
9968 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
9969 break;
9970
9971 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
9972 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
9973 break;
9974
9975 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
9976 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
9977 break;
9978
9979 default:
9980 /*
9981 * invalid rcpi measurement type, fall back to
9982 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
9983 */
9984 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
9985 break;
9986 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309987 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309988 wmi_mtrace(WMI_REQUEST_RCPI_CMDID, cmd->vdev_id, 0);
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309989 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9990 WMI_REQUEST_RCPI_CMDID)) {
9991
9992 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
9993 __func__);
9994 wmi_buf_free(buf);
9995 return QDF_STATUS_E_FAILURE;
9996 }
9997
9998 return QDF_STATUS_SUCCESS;
9999}
10000
10001/**
10002 * extract_rcpi_response_event_tlv() - Extract RCPI event params
10003 * @wmi_handle: wmi handle
10004 * @evt_buf: pointer to event buffer
10005 * @res: pointer to hold rcpi response from firmware
10006 *
10007 * Return: QDF_STATUS_SUCCESS for successful event parse
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010008 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053010009 */
10010static QDF_STATUS
10011extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
10012 void *evt_buf, struct rcpi_res *res)
10013{
10014 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
10015 wmi_update_rcpi_event_fixed_param *event;
10016
10017 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
10018 if (!param_buf) {
10019 WMI_LOGE(FL("Invalid rcpi event"));
10020 return QDF_STATUS_E_INVAL;
10021 }
10022
10023 event = param_buf->fixed_param;
10024 res->vdev_id = event->vdev_id;
10025 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
10026
10027 switch (event->measurement_type) {
10028
10029 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
10030 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
10031 break;
10032
10033 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
10034 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
10035 break;
10036
10037 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
10038 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
10039 break;
10040
10041 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
10042 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
10043 break;
10044
10045 default:
10046 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
10047 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
10048 return QDF_STATUS_E_FAILURE;
10049 }
10050
10051 if (event->status)
10052 return QDF_STATUS_E_FAILURE;
10053 else
10054 return QDF_STATUS_SUCCESS;
10055}
10056
10057/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010058 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010059 * host to target defines. For legacy there is not conversion
10060 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010061 * @param pdev_id: host pdev_id to be converted.
10062 * Return: target pdev_id after conversion.
10063 */
10064static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
10065 uint32_t pdev_id)
10066{
10067 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
10068 return WMI_PDEV_ID_SOC;
10069
10070 /*No conversion required*/
10071 return pdev_id;
10072}
10073
10074/**
10075 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010076 * target to host defines. For legacy there is not conversion
10077 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010078 * @param pdev_id: target pdev_id to be converted.
10079 * Return: host pdev_id after conversion.
10080 */
10081static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
10082 uint32_t pdev_id)
10083{
10084 /*No conversion required*/
10085 return pdev_id;
10086}
10087
10088/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010089 * send_set_country_cmd_tlv() - WMI scan channel list function
10090 * @param wmi_handle : handle to WMI.
10091 * @param param : pointer to hold scan channel list parameter
10092 *
10093 * Return: 0 on success and -ve on failure.
10094 */
10095static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
10096 struct set_country *params)
10097{
10098 wmi_buf_t buf;
10099 QDF_STATUS qdf_status;
10100 wmi_set_current_country_cmd_fixed_param *cmd;
10101 uint16_t len = sizeof(*cmd);
10102
10103 buf = wmi_buf_alloc(wmi_handle, len);
10104 if (!buf) {
10105 WMI_LOGE("Failed to allocate memory");
10106 qdf_status = QDF_STATUS_E_NOMEM;
10107 goto end;
10108 }
10109
10110 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
10111 WMITLV_SET_HDR(&cmd->tlv_header,
10112 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
10113 WMITLV_GET_STRUCT_TLVLEN
10114 (wmi_set_current_country_cmd_fixed_param));
10115
10116 WMI_LOGD("setting cuurnet country to %s", params->country);
10117
10118 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
10119
10120 cmd->pdev_id = params->pdev_id;
10121
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010122 wmi_mtrace(WMI_SET_CURRENT_COUNTRY_CMDID, NO_SESSION, 0);
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010123 qdf_status = wmi_unified_cmd_send(wmi_handle,
10124 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
10125
10126 if (QDF_IS_STATUS_ERROR(qdf_status)) {
10127 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
10128 wmi_buf_free(buf);
10129 }
10130
10131end:
10132 return qdf_status;
10133}
10134
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010135#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010136 WMI_SET_BITS(alpha, 0, 8, val0); \
10137 WMI_SET_BITS(alpha, 8, 8, val1); \
10138 WMI_SET_BITS(alpha, 16, 8, val2); \
10139 } while (0)
10140
10141static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
10142 uint8_t pdev_id, struct cc_regdmn_s *rd)
10143{
10144 wmi_set_init_country_cmd_fixed_param *cmd;
10145 uint16_t len;
10146 wmi_buf_t buf;
10147 int ret;
10148
10149 len = sizeof(wmi_set_init_country_cmd_fixed_param);
10150 buf = wmi_buf_alloc(wmi_handle, len);
10151 if (!buf) {
10152 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10153 return QDF_STATUS_E_NOMEM;
10154 }
10155 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
10156 WMITLV_SET_HDR(&cmd->tlv_header,
10157 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
10158 WMITLV_GET_STRUCT_TLVLEN
10159 (wmi_set_init_country_cmd_fixed_param));
10160
10161 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
10162
10163 if (rd->flags == CC_IS_SET) {
10164 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
10165 cmd->country_code.country_id = rd->cc.country_code;
10166 } else if (rd->flags == ALPHA_IS_SET) {
10167 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
10168 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
10169 rd->cc.alpha[0],
10170 rd->cc.alpha[1],
10171 rd->cc.alpha[2]);
10172 } else if (rd->flags == REGDMN_IS_SET) {
10173 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
10174 cmd->country_code.domain_code = rd->cc.regdmn_id;
10175 }
10176
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010177 wmi_mtrace(WMI_SET_INIT_COUNTRY_CMDID, NO_SESSION, 0);
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010178 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10179 WMI_SET_INIT_COUNTRY_CMDID);
10180 if (ret) {
10181 WMI_LOGE("Failed to config wow wakeup event");
10182 wmi_buf_free(buf);
10183 return QDF_STATUS_E_FAILURE;
10184 }
10185
10186 return QDF_STATUS_SUCCESS;
10187}
10188
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053010189/**
Arif Hussainc5bfe072017-12-27 16:23:45 -080010190 * send_obss_detection_cfg_cmd_tlv() - send obss detection
10191 * configurations to firmware.
10192 * @wmi_handle: wmi handle
10193 * @obss_cfg_param: obss detection configurations
10194 *
10195 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
10196 *
10197 * Return: QDF_STATUS
10198 */
10199static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
10200 struct wmi_obss_detection_cfg_param *obss_cfg_param)
10201{
10202 wmi_buf_t buf;
10203 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
10204 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
10205
10206 buf = wmi_buf_alloc(wmi_handle, len);
10207 if (!buf) {
10208 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
10209 return QDF_STATUS_E_NOMEM;
10210 }
10211
10212 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
10213 WMITLV_SET_HDR(&cmd->tlv_header,
10214 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
10215 WMITLV_GET_STRUCT_TLVLEN
10216 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
10217
10218 cmd->vdev_id = obss_cfg_param->vdev_id;
10219 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
10220 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
10221 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
10222 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
10223 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
10224 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
10225 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
10226 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080010227
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010228 wmi_mtrace(WMI_SAP_OBSS_DETECTION_CFG_CMDID, cmd->vdev_id, 0);
Arif Hussainc5bfe072017-12-27 16:23:45 -080010229 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10230 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
10231 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
10232 wmi_buf_free(buf);
10233 return QDF_STATUS_E_FAILURE;
10234 }
10235
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053010236 return QDF_STATUS_SUCCESS;
10237}
10238
Arif Hussain33d98502018-01-12 13:15:04 -080010239/**
10240 * extract_obss_detection_info_tlv() - Extract obss detection info
10241 * received from firmware.
10242 * @evt_buf: pointer to event buffer
10243 * @obss_detection: Pointer to hold obss detection info
10244 *
10245 * Return: QDF_STATUS
10246 */
10247static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
10248 struct wmi_obss_detect_info
10249 *obss_detection)
10250{
10251 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
10252 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
10253
10254 if (!obss_detection) {
10255 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
10256 return QDF_STATUS_E_INVAL;
10257 }
10258
10259 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
10260 if (!param_buf) {
10261 WMI_LOGE("%s: Invalid evt_buf", __func__);
10262 return QDF_STATUS_E_INVAL;
10263 }
10264
10265 fix_param = param_buf->fixed_param;
10266 obss_detection->vdev_id = fix_param->vdev_id;
10267 obss_detection->matched_detection_masks =
10268 fix_param->matched_detection_masks;
10269 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
10270 &obss_detection->matched_bssid_addr[0]);
10271 switch (fix_param->reason) {
10272 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
10273 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
10274 break;
10275 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
10276 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
10277 break;
10278 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
10279 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
10280 break;
10281 default:
10282 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
10283 return QDF_STATUS_E_INVAL;
10284 }
10285
10286 return QDF_STATUS_SUCCESS;
10287}
10288
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053010289/**
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010290 * send_roam_scan_stats_cmd_tlv() - Send roam scan stats req command to fw
10291 * @wmi_handle: wmi handle
10292 * @params: pointer to request structure
10293 *
10294 * Return: QDF_STATUS
10295 */
10296static QDF_STATUS
10297send_roam_scan_stats_cmd_tlv(wmi_unified_t wmi_handle,
10298 struct wmi_roam_scan_stats_req *params)
10299{
10300 wmi_buf_t buf;
10301 wmi_request_roam_scan_stats_cmd_fixed_param *cmd;
10302 WMITLV_TAG_ID tag;
10303 uint32_t size;
10304 uint32_t len = sizeof(*cmd);
10305
10306 buf = wmi_buf_alloc(wmi_handle, len);
10307 if (!buf) {
10308 WMI_LOGE(FL("Failed to allocate wmi buffer"));
10309 return QDF_STATUS_E_FAILURE;
10310 }
10311
10312 cmd = (wmi_request_roam_scan_stats_cmd_fixed_param *)wmi_buf_data(buf);
10313
10314 tag = WMITLV_TAG_STRUC_wmi_request_roam_scan_stats_cmd_fixed_param;
10315 size = WMITLV_GET_STRUCT_TLVLEN(
10316 wmi_request_roam_scan_stats_cmd_fixed_param);
10317 WMITLV_SET_HDR(&cmd->tlv_header, tag, size);
10318
10319 cmd->vdev_id = params->vdev_id;
10320
10321 WMI_LOGD(FL("Roam Scan Stats Req vdev_id: %u"), cmd->vdev_id);
10322 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10323 WMI_REQUEST_ROAM_SCAN_STATS_CMDID)) {
10324 WMI_LOGE("%s: Failed to send WMI_REQUEST_ROAM_SCAN_STATS_CMDID",
10325 __func__);
10326 wmi_buf_free(buf);
10327 return QDF_STATUS_E_FAILURE;
10328 }
10329
10330 return QDF_STATUS_SUCCESS;
10331}
10332
10333/**
10334 * extract_roam_scan_stats_res_evt_tlv() - Extract roam scan stats event
10335 * @wmi_handle: wmi handle
10336 * @evt_buf: pointer to event buffer
10337 * @vdev_id: output pointer to hold vdev id
10338 * @res_param: output pointer to hold the allocated response
10339 *
10340 * Return: QDF_STATUS
10341 */
10342static QDF_STATUS
10343extract_roam_scan_stats_res_evt_tlv(wmi_unified_t wmi_handle, void *evt_buf,
10344 uint32_t *vdev_id,
10345 struct wmi_roam_scan_stats_res **res_param)
10346{
10347 WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *param_buf;
10348 wmi_roam_scan_stats_event_fixed_param *fixed_param;
10349 uint32_t *client_id = NULL;
10350 wmi_roaming_timestamp *timestamp = NULL;
10351 uint32_t *num_channels = NULL;
10352 uint32_t *chan_info = NULL;
10353 wmi_mac_addr *old_bssid = NULL;
10354 uint32_t *is_roaming_success = NULL;
10355 wmi_mac_addr *new_bssid = NULL;
10356 uint32_t *num_roam_candidates = NULL;
10357 wmi_roam_scan_trigger_reason *roam_reason = NULL;
10358 wmi_mac_addr *bssid = NULL;
10359 uint32_t *score = NULL;
10360 uint32_t *channel = NULL;
10361 uint32_t *rssi = NULL;
10362 int chan_idx = 0, cand_idx = 0;
10363 uint32_t total_len;
10364 struct wmi_roam_scan_stats_res *res;
10365 uint32_t i, j;
Arif Hussain100fabf2018-10-17 09:36:11 -070010366 uint32_t num_scans, scan_param_size;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010367
10368 *res_param = NULL;
10369 *vdev_id = 0xFF; /* Initialize to invalid vdev id */
10370 param_buf = (WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *)evt_buf;
10371 if (!param_buf) {
10372 WMI_LOGE(FL("Invalid roam scan stats event"));
10373 return QDF_STATUS_E_INVAL;
10374 }
10375
10376 fixed_param = param_buf->fixed_param;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010377
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010378 num_scans = fixed_param->num_roam_scans;
Arif Hussain100fabf2018-10-17 09:36:11 -070010379 scan_param_size = sizeof(struct wmi_roam_scan_stats_params);
10380 if ((num_scans > ((UINT_MAX - sizeof(*res)) / scan_param_size))) {
10381 wmi_err_rl("Invalid num_roam_scans %d", num_scans);
10382 return QDF_STATUS_E_INVAL;
10383 }
10384
10385 total_len = sizeof(*res) + num_scans * scan_param_size;
10386 *vdev_id = fixed_param->vdev_id;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010387
10388 res = qdf_mem_malloc(total_len);
10389 if (!res) {
10390 WMI_LOGE("Failed to allocate roam scan stats response memory");
10391 return QDF_STATUS_E_NOMEM;
10392 }
10393
10394 if (!num_scans) {
10395 *res_param = res;
10396 return QDF_STATUS_SUCCESS;
10397 }
10398
10399 if (param_buf->client_id &&
10400 param_buf->num_client_id == num_scans)
10401 client_id = param_buf->client_id;
10402
10403 if (param_buf->timestamp &&
10404 param_buf->num_timestamp == num_scans)
10405 timestamp = param_buf->timestamp;
10406
10407 if (param_buf->old_bssid &&
10408 param_buf->num_old_bssid == num_scans)
10409 old_bssid = param_buf->old_bssid;
10410
10411 if (param_buf->new_bssid &&
10412 param_buf->num_new_bssid == num_scans)
10413 new_bssid = param_buf->new_bssid;
10414
10415 if (param_buf->is_roaming_success &&
10416 param_buf->num_is_roaming_success == num_scans)
10417 is_roaming_success = param_buf->is_roaming_success;
10418
10419 if (param_buf->roam_reason &&
10420 param_buf->num_roam_reason == num_scans)
10421 roam_reason = param_buf->roam_reason;
10422
10423 if (param_buf->num_channels &&
10424 param_buf->num_num_channels == num_scans) {
10425 uint32_t count, chan_info_sum = 0;
10426
10427 num_channels = param_buf->num_channels;
10428 for (count = 0; count < param_buf->num_num_channels; count++)
10429 chan_info_sum += param_buf->num_channels[count];
10430
10431 if (param_buf->chan_info &&
10432 param_buf->num_chan_info == chan_info_sum)
10433 chan_info = param_buf->chan_info;
10434 }
10435
10436 if (param_buf->num_roam_candidates &&
10437 param_buf->num_num_roam_candidates == num_scans) {
10438 uint32_t count, roam_cand_sum = 0;
10439
10440 num_roam_candidates = param_buf->num_roam_candidates;
10441 for (count = 0; count < param_buf->num_num_roam_candidates;
10442 count++)
10443 roam_cand_sum += param_buf->num_roam_candidates[count];
10444
10445 if (param_buf->bssid &&
10446 param_buf->num_bssid == roam_cand_sum)
10447 bssid = param_buf->bssid;
10448
10449 if (param_buf->score &&
10450 param_buf->num_score == roam_cand_sum)
10451 score = param_buf->score;
10452
10453 if (param_buf->channel &&
10454 param_buf->num_channel == roam_cand_sum)
10455 channel = param_buf->channel;
10456
10457 if (param_buf->rssi &&
10458 param_buf->num_rssi == roam_cand_sum)
10459 rssi = param_buf->rssi;
10460 }
10461
10462 res->num_roam_scans = num_scans;
10463 for (i = 0; i < num_scans; i++) {
10464 struct wmi_roam_scan_stats_params *roam = &res->roam_scan[i];
10465
10466 if (timestamp)
10467 roam->time_stamp = timestamp[i].lower32bit |
10468 (timestamp[i].upper32bit << 31);
10469
10470 if (client_id)
10471 roam->client_id = client_id[i];
10472
10473 if (num_channels) {
10474 roam->num_scan_chans = num_channels[i];
10475 if (chan_info) {
10476 for (j = 0; j < num_channels[i]; j++)
10477 roam->scan_freqs[j] =
10478 chan_info[chan_idx++];
10479 }
10480 }
10481
10482 if (is_roaming_success)
10483 roam->is_roam_successful = is_roaming_success[i];
10484
10485 if (roam_reason) {
10486 roam->trigger_id = roam_reason[i].trigger_id;
10487 roam->trigger_value = roam_reason[i].trigger_value;
10488 }
10489
10490 if (num_roam_candidates) {
10491 roam->num_roam_candidates = num_roam_candidates[i];
10492
10493 for (j = 0; j < num_roam_candidates[i]; j++) {
10494 if (score)
10495 roam->cand[j].score = score[cand_idx];
10496 if (rssi)
10497 roam->cand[j].rssi = rssi[cand_idx];
10498 if (channel)
10499 roam->cand[j].freq =
10500 channel[cand_idx];
10501
10502 if (bssid)
10503 WMI_MAC_ADDR_TO_CHAR_ARRAY(
10504 &bssid[cand_idx],
10505 roam->cand[j].bssid);
10506
10507 cand_idx++;
10508 }
10509 }
10510
10511 if (old_bssid)
10512 WMI_MAC_ADDR_TO_CHAR_ARRAY(&old_bssid[i],
10513 roam->old_bssid);
10514
10515 if (new_bssid)
10516 WMI_MAC_ADDR_TO_CHAR_ARRAY(&new_bssid[i],
10517 roam->new_bssid);
10518 }
10519
10520 *res_param = res;
10521
10522 return QDF_STATUS_SUCCESS;
10523}
10524
10525/**
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070010526 * extract_offload_bcn_tx_status_evt() - Extract beacon-tx status event
10527 * @wmi_handle: wmi handle
10528 * @evt_buf: pointer to event buffer
10529 * @vdev_id: output pointer to hold vdev id
10530 * @tx_status: output pointer to hold the tx_status
10531 *
10532 * Return: QDF_STATUS
10533 */
10534static QDF_STATUS extract_offload_bcn_tx_status_evt(wmi_unified_t wmi_handle,
10535 void *evt_buf,
10536 uint32_t *vdev_id,
10537 uint32_t *tx_status) {
10538 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *param_buf;
10539 wmi_offload_bcn_tx_status_event_fixed_param *bcn_tx_status_event;
10540
10541 param_buf = (WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *)evt_buf;
10542 if (!param_buf) {
10543 WMI_LOGE("Invalid offload bcn tx status event buffer");
10544 return QDF_STATUS_E_INVAL;
10545 }
10546
10547 bcn_tx_status_event = param_buf->fixed_param;
10548 *vdev_id = bcn_tx_status_event->vdev_id;
10549 *tx_status = bcn_tx_status_event->tx_status;
10550
10551 return QDF_STATUS_SUCCESS;
10552}
10553
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010554#ifdef WLAN_SUPPORT_GREEN_AP
10555static QDF_STATUS extract_green_ap_egap_status_info_tlv(
10556 uint8_t *evt_buf,
10557 struct wlan_green_ap_egap_status_info *egap_status_info_params)
10558{
10559 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
10560 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
10561 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
10562
10563 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
10564 if (!param_buf) {
10565 WMI_LOGE("Invalid EGAP Info status event buffer");
10566 return QDF_STATUS_E_INVAL;
10567 }
10568
10569 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
10570 param_buf->fixed_param;
10571 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
10572 param_buf->chainmask_list;
10573
Ashish Kumar Dhanotiyaa90d8112018-10-17 16:45:54 +053010574 if (!egap_info_event || !chainmask_event) {
10575 WMI_LOGE("Invalid EGAP Info event or chainmask event");
10576 return QDF_STATUS_E_INVAL;
10577 }
10578
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010579 egap_status_info_params->status = egap_info_event->status;
10580 egap_status_info_params->mac_id = chainmask_event->mac_id;
10581 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
10582 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
10583
10584 return QDF_STATUS_SUCCESS;
10585}
10586#endif
10587
Arif Hussainec5cd3c2018-01-22 01:19:36 -080010588/*
Arif Hussaine0eb7302018-03-01 14:40:59 -080010589 * extract_comb_phyerr_tlv() - extract comb phy error from event
10590 * @wmi_handle: wmi handle
10591 * @evt_buf: pointer to event buffer
10592 * @datalen: data length of event buffer
10593 * @buf_offset: Pointer to hold value of current event buffer offset
10594 * post extraction
10595 * @phyerr: Pointer to hold phyerr
10596 *
10597 * Return: QDF_STATUS
10598 */
10599static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
10600 void *evt_buf,
10601 uint16_t datalen,
10602 uint16_t *buf_offset,
10603 wmi_host_phyerr_t *phyerr)
10604{
10605 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
10606 wmi_comb_phyerr_rx_hdr *pe_hdr;
10607
10608 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
10609 if (!param_tlvs) {
10610 WMI_LOGD("%s: Received null data from FW", __func__);
10611 return QDF_STATUS_E_FAILURE;
10612 }
10613
10614 pe_hdr = param_tlvs->hdr;
10615 if (!pe_hdr) {
10616 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
10617 return QDF_STATUS_E_FAILURE;
10618 }
10619
10620 /* Ensure it's at least the size of the header */
10621 if (datalen < sizeof(*pe_hdr)) {
10622 WMI_LOGD("%s: Expected minimum size %zu, received %d",
10623 __func__, sizeof(*pe_hdr), datalen);
10624 return QDF_STATUS_E_FAILURE;
10625 }
10626
10627 phyerr->pdev_id = wmi_handle->ops->
10628 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
10629 phyerr->tsf64 = pe_hdr->tsf_l32;
10630 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
10631 phyerr->bufp = param_tlvs->bufp;
Yeshwanth Sriram Guntuka19e51be2018-09-25 15:40:08 +053010632
10633 if (pe_hdr->buf_len > param_tlvs->num_bufp) {
10634 WMI_LOGD("Invalid buf_len %d, num_bufp %d",
10635 pe_hdr->buf_len, param_tlvs->num_bufp);
10636 return QDF_STATUS_E_FAILURE;
10637 }
10638
Arif Hussaine0eb7302018-03-01 14:40:59 -080010639 phyerr->buf_len = pe_hdr->buf_len;
10640 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
10641 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
10642 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
10643
10644 return QDF_STATUS_SUCCESS;
10645}
10646
10647/**
10648 * extract_single_phyerr_tlv() - extract single phy error from event
10649 * @wmi_handle: wmi handle
10650 * @evt_buf: pointer to event buffer
10651 * @datalen: data length of event buffer
10652 * @buf_offset: Pointer to hold value of current event buffer offset
10653 * post extraction
10654 * @phyerr: Pointer to hold phyerr
10655 *
10656 * Return: QDF_STATUS
10657 */
10658static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
10659 void *evt_buf,
10660 uint16_t datalen,
10661 uint16_t *buf_offset,
10662 wmi_host_phyerr_t *phyerr)
10663{
10664 wmi_single_phyerr_rx_event *ev;
10665 uint16_t n = *buf_offset;
10666 uint8_t *data = (uint8_t *)evt_buf;
10667
10668 if (n < datalen) {
10669 if ((datalen - n) < sizeof(ev->hdr)) {
10670 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
10671 __func__, datalen, n, sizeof(ev->hdr));
10672 return QDF_STATUS_E_FAILURE;
10673 }
10674
10675 /*
10676 * Obtain a pointer to the beginning of the current event.
10677 * data[0] is the beginning of the WMI payload.
10678 */
10679 ev = (wmi_single_phyerr_rx_event *)&data[n];
10680
10681 /*
10682 * Sanity check the buffer length of the event against
10683 * what we currently have.
10684 *
10685 * Since buf_len is 32 bits, we check if it overflows
10686 * a large 32 bit value. It's not 0x7fffffff because
10687 * we increase n by (buf_len + sizeof(hdr)), which would
10688 * in itself cause n to overflow.
10689 *
10690 * If "int" is 64 bits then this becomes a moot point.
10691 */
10692 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
10693 WMI_LOGD("%s: buf_len is garbage 0x%x",
10694 __func__, ev->hdr.buf_len);
10695 return QDF_STATUS_E_FAILURE;
10696 }
10697
10698 if ((n + ev->hdr.buf_len) > datalen) {
10699 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
10700 __func__, n, ev->hdr.buf_len, datalen);
10701 return QDF_STATUS_E_FAILURE;
10702 }
10703
10704 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
10705 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
10706 phyerr->bufp = &ev->bufp[0];
10707 phyerr->buf_len = ev->hdr.buf_len;
10708 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
10709
10710 /*
10711 * Advance the buffer pointer to the next PHY error.
10712 * buflen is the length of this payload, so we need to
10713 * advance past the current header _AND_ the payload.
10714 */
10715 n += sizeof(*ev) + ev->hdr.buf_len;
10716 }
10717 *buf_offset = n;
10718
10719 return QDF_STATUS_SUCCESS;
10720}
10721
Subrat Mishraa667b1c2018-08-02 15:02:04 +053010722/**
10723 * extract_esp_estimation_ev_param_tlv() - extract air time from event
10724 * @wmi_handle: wmi handle
10725 * @evt_buf: pointer to event buffer
10726 * @param: Pointer to hold esp event
10727 *
10728 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
10729 */
10730static QDF_STATUS
10731extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
10732 void *evt_buf,
10733 struct esp_estimation_event *param)
10734{
10735 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
10736 wmi_esp_estimate_event_fixed_param *esp_event;
10737
10738 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
10739 if (!param_buf) {
10740 WMI_LOGE("Invalid ESP Estimate Event buffer");
10741 return QDF_STATUS_E_INVAL;
10742 }
10743 esp_event = param_buf->fixed_param;
10744 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
10745 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
10746 esp_event->pdev_id);
10747
10748 return QDF_STATUS_SUCCESS;
10749}
10750
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080010751/*
10752 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
10753 * updating bss color change within firmware when AP announces bss color change.
10754 * @wmi_handle: wmi handle
10755 * @vdev_id: vdev ID
10756 * @enable: enable bss color change within firmware
10757 *
10758 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
10759 *
10760 * Return: QDF_STATUS
10761 */
10762static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
10763 uint32_t vdev_id,
10764 bool enable)
10765{
10766 wmi_buf_t buf;
10767 wmi_bss_color_change_enable_fixed_param *cmd;
10768 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
10769
10770 buf = wmi_buf_alloc(wmi_handle, len);
10771 if (!buf) {
10772 return QDF_STATUS_E_NOMEM;
10773 }
10774
10775 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
10776 WMITLV_SET_HDR(&cmd->tlv_header,
10777 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
10778 WMITLV_GET_STRUCT_TLVLEN
10779 (wmi_bss_color_change_enable_fixed_param));
10780 cmd->vdev_id = vdev_id;
10781 cmd->enable = enable;
10782 wmi_mtrace(WMI_BSS_COLOR_CHANGE_ENABLE_CMDID, cmd->vdev_id, 0);
10783 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10784 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
10785 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
10786 wmi_buf_free(buf);
10787 return QDF_STATUS_E_FAILURE;
10788 }
10789
10790 return QDF_STATUS_SUCCESS;
10791}
10792
10793/**
10794 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
10795 * configurations to firmware.
10796 * @wmi_handle: wmi handle
10797 * @cfg_param: obss detection configurations
10798 *
10799 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
10800 *
10801 * Return: QDF_STATUS
10802 */
10803static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
10804 wmi_unified_t wmi_handle,
10805 struct wmi_obss_color_collision_cfg_param *cfg_param)
10806{
10807 wmi_buf_t buf;
10808 wmi_obss_color_collision_det_config_fixed_param *cmd;
10809 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
10810
10811 buf = wmi_buf_alloc(wmi_handle, len);
10812 if (!buf) {
10813 return QDF_STATUS_E_NOMEM;
10814 }
10815
10816 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
10817 buf);
10818 WMITLV_SET_HDR(&cmd->tlv_header,
10819 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
10820 WMITLV_GET_STRUCT_TLVLEN
10821 (wmi_obss_color_collision_det_config_fixed_param));
10822 cmd->vdev_id = cfg_param->vdev_id;
10823 cmd->flags = cfg_param->flags;
10824 cmd->current_bss_color = cfg_param->current_bss_color;
10825 cmd->detection_period_ms = cfg_param->detection_period_ms;
10826 cmd->scan_period_ms = cfg_param->scan_period_ms;
10827 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
10828
10829 switch (cfg_param->evt_type) {
10830 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
10831 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
10832 break;
10833 case OBSS_COLOR_COLLISION_DETECTION:
10834 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
10835 break;
10836 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10837 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10838 break;
10839 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
10840 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
10841 break;
10842 default:
10843 WMI_LOGE("%s: invalid event type: %d",
10844 __func__, cfg_param->evt_type);
10845 wmi_buf_free(buf);
10846 return QDF_STATUS_E_FAILURE;
10847 }
10848
10849 WMI_LOGD("%s: evt_type: %d vdev id: %d current_bss_color: %d\n"
10850 "detection_period_ms: %d scan_period_ms: %d\n"
10851 "free_slot_expiry_timer_ms: %d",
10852 __func__, cmd->evt_type, cmd->vdev_id, cmd->current_bss_color,
10853 cmd->detection_period_ms, cmd->scan_period_ms,
10854 cmd->free_slot_expiry_time_ms);
10855
10856 wmi_mtrace(WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID, cmd->vdev_id, 0);
10857 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10858 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
10859 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
10860 __func__, cfg_param->vdev_id);
10861 wmi_buf_free(buf);
10862 return QDF_STATUS_E_FAILURE;
10863 }
10864
10865 return QDF_STATUS_SUCCESS;
10866}
10867
10868/**
10869 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
10870 * received from firmware.
10871 * @evt_buf: pointer to event buffer
10872 * @info: Pointer to hold bss collision info
10873 *
10874 * Return: QDF_STATUS
10875 */
10876static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
10877 struct wmi_obss_color_collision_info *info)
10878{
10879 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
10880 wmi_obss_color_collision_evt_fixed_param *fix_param;
10881
10882 if (!info) {
10883 WMI_LOGE("%s: Invalid obss color buffer", __func__);
10884 return QDF_STATUS_E_INVAL;
10885 }
10886
10887 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
10888 evt_buf;
10889 if (!param_buf) {
10890 WMI_LOGE("%s: Invalid evt_buf", __func__);
10891 return QDF_STATUS_E_INVAL;
10892 }
10893
10894 fix_param = param_buf->fixed_param;
10895 info->vdev_id = fix_param->vdev_id;
10896 info->obss_color_bitmap_bit0to31 =
10897 fix_param->bss_color_bitmap_bit0to31;
10898 info->obss_color_bitmap_bit32to63 =
10899 fix_param->bss_color_bitmap_bit32to63;
10900
10901 switch (fix_param->evt_type) {
10902 case WMI_BSS_COLOR_COLLISION_DISABLE:
10903 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
10904 break;
10905 case WMI_BSS_COLOR_COLLISION_DETECTION:
10906 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
10907 break;
10908 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10909 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10910 break;
10911 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
10912 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
10913 break;
10914 default:
10915 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
10916 __func__, fix_param->evt_type, fix_param->vdev_id);
10917 return QDF_STATUS_E_FAILURE;
10918 }
10919
10920 return QDF_STATUS_SUCCESS;
10921}
10922
10923static void wmi_11ax_bss_color_attach_tlv(struct wmi_unified *wmi_handle)
10924{
10925 struct wmi_ops *ops = wmi_handle->ops;
10926
10927 ops->send_obss_color_collision_cfg_cmd =
10928 send_obss_color_collision_cfg_cmd_tlv;
10929 ops->extract_obss_color_collision_info =
10930 extract_obss_color_collision_info_tlv;
10931}
10932
Govind Singh5eb51532016-03-09 11:34:12 +053010933struct wmi_ops tlv_ops = {
10934 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
10935 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
10936 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053010937 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
10938 .send_hidden_ssid_vdev_restart_cmd =
10939 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010940 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
10941 .send_peer_param_cmd = send_peer_param_cmd_tlv,
10942 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010943 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010944 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010945 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070010946 .send_peer_rx_reorder_queue_setup_cmd =
10947 send_peer_rx_reorder_queue_setup_cmd_tlv,
10948 .send_peer_rx_reorder_queue_remove_cmd =
10949 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010950 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
10951 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
10952 .send_suspend_cmd = send_suspend_cmd_tlv,
10953 .send_resume_cmd = send_resume_cmd_tlv,
10954 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
10955 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
10956 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
10957 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080010958#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053010959 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080010960#endif
Govind Singh5eb51532016-03-09 11:34:12 +053010961 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
10962 .send_stats_request_cmd = send_stats_request_cmd_tlv,
10963 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053010964 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070010965 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053010966 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010967 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
10968 .send_scan_start_cmd = send_scan_start_cmd_tlv,
10969 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
10970 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010971 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053010972 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010973 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
10974 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010975 .send_set_sta_uapsd_auto_trig_cmd =
10976 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010977 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010978 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
10979 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053010980 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
10981 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053010982 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010983 .send_probe_rsp_tmpl_send_cmd =
10984 send_probe_rsp_tmpl_send_cmd_tlv,
10985 .send_p2p_go_set_beacon_ie_cmd =
10986 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053010987 .send_setup_install_key_cmd =
10988 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010989 .send_scan_probe_setoui_cmd =
10990 send_scan_probe_setoui_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053010991#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053010992 .send_ipa_offload_control_cmd =
10993 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053010994#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053010995 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
10996 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070010997 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080010998#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053010999 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
11000 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
11001 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080011002#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053011003 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011004 .send_snr_request_cmd = send_snr_request_cmd_tlv,
11005 .send_snr_cmd = send_snr_cmd_tlv,
11006 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011007#ifdef CONFIG_MCL
Govind Singh87542482016-06-08 19:40:11 +053011008 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053011009#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053011010 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053011011#endif
Govind Singh87542482016-06-08 19:40:11 +053011012#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053011013#ifdef WLAN_SUPPORT_GREEN_AP
11014 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
11015 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053011016 .extract_green_ap_egap_status_info =
11017 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053011018#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053011019 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011020 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070011021#ifdef WLAN_FEATURE_CIF_CFR
11022 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
11023#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053011024 .send_dfs_phyerr_filter_offload_en_cmd =
11025 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011026 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011027 .send_process_dhcpserver_offload_cmd =
11028 send_process_dhcpserver_offload_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053011029 .send_pdev_set_regdomain_cmd =
11030 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011031 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053011032 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011033 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053011034 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011035 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
11036 .send_enable_specific_fw_logs_cmd =
11037 send_enable_specific_fw_logs_cmd_tlv,
11038 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011039 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011040 .send_unit_test_cmd = send_unit_test_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011041#ifdef FEATURE_WLAN_APF
11042 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
11043 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
11044 .send_apf_write_work_memory_cmd =
11045 wmi_send_apf_write_work_memory_cmd_tlv,
11046 .send_apf_read_work_memory_cmd =
11047 wmi_send_apf_read_work_memory_cmd_tlv,
11048 .extract_apf_read_memory_resp_event =
11049 wmi_extract_apf_read_memory_resp_event_tlv,
11050#endif /* FEATURE_WLAN_APF */
Govind Singhe7f2f342016-05-23 12:12:52 +053011051 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053011052 .send_vdev_set_custom_aggr_size_cmd =
11053 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011054 .send_vdev_set_qdepth_thresh_cmd =
11055 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053011056 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053011057 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011058 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
11059 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011060 .send_periodic_chan_stats_config_cmd =
11061 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011062 .send_vdev_spectral_configure_cmd =
11063 send_vdev_spectral_configure_cmd_tlv,
11064 .send_vdev_spectral_enable_cmd =
11065 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011066 .send_thermal_mitigation_param_cmd =
11067 send_thermal_mitigation_param_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053011068 .send_process_update_edca_param_cmd =
11069 send_process_update_edca_param_cmd_tlv,
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080011070 .send_bss_color_change_enable_cmd =
11071 send_bss_color_change_enable_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053011072 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070011073 .send_set_country_cmd = send_set_country_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080011074 .send_addba_send_cmd = send_addba_send_cmd_tlv,
11075 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080011076 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011077 .get_target_cap_from_service_ready = extract_service_ready_tlv,
11078 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
11079 .extract_host_mem_req = extract_host_mem_req_tlv,
11080 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011081 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011082 .is_service_enabled = is_service_enabled_tlv,
11083 .save_fw_version = save_fw_version_in_service_ready_tlv,
11084 .ready_extract_init_status = ready_extract_init_status_tlv,
11085 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070011086 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053011087 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011088 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011089 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011090 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
11091 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011092 .extract_all_stats_count = extract_all_stats_counts_tlv,
11093 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011094 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011095 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
11096 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070011097 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011098 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053011099 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011100 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
11101 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
11102 .extract_chan_stats = extract_chan_stats_tlv,
11103 .extract_profile_ctx = extract_profile_ctx_tlv,
11104 .extract_profile_data = extract_profile_data_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053011105 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053011106 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053011107 .extract_service_ready_ext = extract_service_ready_ext_tlv,
11108 .extract_hw_mode_cap_service_ready_ext =
11109 extract_hw_mode_cap_service_ready_ext_tlv,
11110 .extract_mac_phy_cap_service_ready_ext =
11111 extract_mac_phy_cap_service_ready_ext_tlv,
11112 .extract_reg_cap_service_ready_ext =
11113 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053011114 .extract_dbr_ring_cap_service_ready_ext =
11115 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011116 .extract_sar_cap_service_ready_ext =
11117 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053011118 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053011119 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053011120 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011121 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053011122 .is_management_record = is_management_record_tlv,
Rajeev Kumarb64e1282018-09-19 13:02:23 -070011123 .is_diag_event = is_diag_event_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053011124#ifdef WLAN_FEATURE_ACTION_OUI
11125 .send_action_oui_cmd = send_action_oui_cmd_tlv,
11126#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080011127 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
11128 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011129 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053011130 extract_reg_chan_list_update_event_tlv,
11131 .extract_chainmask_tables =
11132 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011133 .extract_thermal_stats = extract_thermal_stats_tlv,
11134 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011135 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
11136 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011137#ifdef DFS_COMPONENT_ENABLE
11138 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
11139 .extract_dfs_radar_detection_event =
11140 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080011141 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011142#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011143 .convert_pdev_id_host_to_target =
11144 convert_host_pdev_id_to_target_pdev_id_legacy,
11145 .convert_pdev_id_target_to_host =
11146 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070011147
11148 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
11149 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
11150 .extract_reg_11d_new_country_event =
11151 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053011152 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070011153 .extract_reg_ch_avoid_event =
11154 extract_reg_ch_avoid_event_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080011155 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080011156 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053011157 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
11158 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
11159 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
11160 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussaine0eb7302018-03-01 14:40:59 -080011161 .extract_comb_phyerr = extract_comb_phyerr_tlv,
11162 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070011163#ifdef QCA_SUPPORT_CP_STATS
11164 .extract_cca_stats = extract_cca_stats_tlv,
11165#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011166 .extract_esp_estimation_ev_param =
11167 extract_esp_estimation_ev_param_tlv,
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011168 .send_roam_scan_stats_cmd = send_roam_scan_stats_cmd_tlv,
11169 .extract_roam_scan_stats_res_evt = extract_roam_scan_stats_res_evt_tlv,
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011170#ifdef OBSS_PD
11171 .send_obss_spatial_reuse_set = send_obss_spatial_reuse_set_cmd_tlv,
11172#endif
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070011173 .extract_offload_bcn_tx_status_evt = extract_offload_bcn_tx_status_evt,
Alok Singh0243e7d2018-09-20 16:07:28 +053011174 .extract_ctl_failsafe_check_ev_param =
11175 extract_ctl_failsafe_check_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011176};
11177
Govind Singhe7f2f342016-05-23 12:12:52 +053011178/**
11179 * populate_tlv_event_id() - populates wmi event ids
11180 *
11181 * @param event_ids: Pointer to hold event ids
11182 * Return: None
11183 */
11184static void populate_tlv_events_id(uint32_t *event_ids)
11185{
11186 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
11187 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
11188 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
11189 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11190 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
11191 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
11192 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
11193 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
11194 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
11195 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
11196 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
11197 event_ids[wmi_service_ready_ext_event_id] =
11198 WMI_SERVICE_READY_EXT_EVENTID;
11199 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
11200 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
11201 event_ids[wmi_vdev_install_key_complete_event_id] =
11202 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
11203 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
11204 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
11205
11206 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
11207 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
11208 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
11209 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
11210 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
11211 event_ids[wmi_peer_estimated_linkspeed_event_id] =
11212 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
11213 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053011214 event_ids[wmi_peer_delete_response_event_id] =
11215 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011216 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
11217 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
11218 event_ids[wmi_tbttoffset_update_event_id] =
11219 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053011220 event_ids[wmi_ext_tbttoffset_update_event_id] =
11221 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011222 event_ids[wmi_offload_bcn_tx_status_event_id] =
11223 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
11224 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
11225 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
11226 event_ids[wmi_mgmt_tx_completion_event_id] =
11227 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080011228 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
11229 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011230 event_ids[wmi_tx_delba_complete_event_id] =
11231 WMI_TX_DELBA_COMPLETE_EVENTID;
11232 event_ids[wmi_tx_addba_complete_event_id] =
11233 WMI_TX_ADDBA_COMPLETE_EVENTID;
11234 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
11235
11236 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
11237
11238 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
11239 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
11240
11241 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053011242 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011243
11244 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
11245
11246 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080011247 event_ids[wmi_p2p_lo_stop_event_id] =
11248 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011249 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
11250 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080011251 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053011252 WMI_D0_WOW_DISABLE_ACK_EVENTID;
11253 event_ids[wmi_wow_initial_wakeup_event_id] =
11254 WMI_WOW_INITIAL_WAKEUP_EVENTID;
11255
11256 event_ids[wmi_rtt_meas_report_event_id] =
11257 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
11258 event_ids[wmi_tsf_meas_report_event_id] =
11259 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
11260 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
11261 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
11262 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
11263 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
11264 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011265 event_ids[wmi_diag_event_id_log_supported_event_id] =
11266 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
11267 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
11268 event_ids[wmi_nlo_scan_complete_event_id] =
11269 WMI_NLO_SCAN_COMPLETE_EVENTID;
11270 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
11271 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
11272
11273 event_ids[wmi_gtk_offload_status_event_id] =
11274 WMI_GTK_OFFLOAD_STATUS_EVENTID;
11275 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
11276 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
11277 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
11278
11279 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
11280
11281 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
11282
11283 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
11284 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
11285 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
11286 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
11287 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
11288 event_ids[wmi_wlan_profile_data_event_id] =
11289 WMI_WLAN_PROFILE_DATA_EVENTID;
11290 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
11291 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
11292 event_ids[wmi_vdev_get_keepalive_event_id] =
11293 WMI_VDEV_GET_KEEPALIVE_EVENTID;
11294 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
11295
11296 event_ids[wmi_diag_container_event_id] =
11297 WMI_DIAG_DATA_CONTAINER_EVENTID;
11298
11299 event_ids[wmi_host_auto_shutdown_event_id] =
11300 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
11301
11302 event_ids[wmi_update_whal_mib_stats_event_id] =
11303 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
11304
11305 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
11306 event_ids[wmi_update_vdev_rate_stats_event_id] =
11307 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
11308
11309 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011310 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011311
11312 /** Set OCB Sched Response, deprecated */
11313 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
11314
11315 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
11316 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
11317 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
11318
11319 /* GPIO Event */
11320 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
11321 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
11322
11323 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
11324 event_ids[wmi_rfkill_state_change_event_id] =
11325 WMI_RFKILL_STATE_CHANGE_EVENTID;
11326
11327 /* TDLS Event */
11328 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
11329
11330 event_ids[wmi_batch_scan_enabled_event_id] =
11331 WMI_BATCH_SCAN_ENABLED_EVENTID;
11332 event_ids[wmi_batch_scan_result_event_id] =
11333 WMI_BATCH_SCAN_RESULT_EVENTID;
11334 /* OEM Event */
11335 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
11336 event_ids[wmi_oem_meas_report_event_id] =
11337 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
11338 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
11339
11340 /* NAN Event */
11341 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
11342
11343 /* LPI Event */
11344 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
11345 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
11346 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
11347
11348 /* ExtScan events */
11349 event_ids[wmi_extscan_start_stop_event_id] =
11350 WMI_EXTSCAN_START_STOP_EVENTID;
11351 event_ids[wmi_extscan_operation_event_id] =
11352 WMI_EXTSCAN_OPERATION_EVENTID;
11353 event_ids[wmi_extscan_table_usage_event_id] =
11354 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
11355 event_ids[wmi_extscan_cached_results_event_id] =
11356 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
11357 event_ids[wmi_extscan_wlan_change_results_event_id] =
11358 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
11359 event_ids[wmi_extscan_hotlist_match_event_id] =
11360 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
11361 event_ids[wmi_extscan_capabilities_event_id] =
11362 WMI_EXTSCAN_CAPABILITIES_EVENTID;
11363 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
11364 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
11365
11366 /* mDNS offload events */
11367 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
11368
11369 /* SAP Authentication offload events */
11370 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
11371 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
11372
11373 /** Out-of-context-of-bss (OCB) events */
11374 event_ids[wmi_ocb_set_config_resp_event_id] =
11375 WMI_OCB_SET_CONFIG_RESP_EVENTID;
11376 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
11377 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
11378 event_ids[wmi_dcc_get_stats_resp_event_id] =
11379 WMI_DCC_GET_STATS_RESP_EVENTID;
11380 event_ids[wmi_dcc_update_ndl_resp_event_id] =
11381 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
11382 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
11383 /* System-On-Chip events */
11384 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
11385 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
11386 event_ids[wmi_soc_hw_mode_transition_event_id] =
11387 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
11388 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
11389 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011390 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053011391 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
11392 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011393 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053011394 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
11395 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11396 event_ids[wmi_peer_sta_ps_statechg_event_id] =
11397 WMI_PEER_STA_PS_STATECHG_EVENTID;
11398 event_ids[wmi_pdev_channel_hopping_event_id] =
11399 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053011400 event_ids[wmi_offchan_data_tx_completion_event] =
11401 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011402 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
11403 event_ids[wmi_dfs_radar_detection_event_id] =
11404 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011405 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070011406 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011407 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053011408 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011409 event_ids[wmi_service_available_event_id] =
11410 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011411 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053011412 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011413 /* NDP events */
11414 event_ids[wmi_ndp_initiator_rsp_event_id] =
11415 WMI_NDP_INITIATOR_RSP_EVENTID;
11416 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
11417 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
11418 event_ids[wmi_ndp_responder_rsp_event_id] =
11419 WMI_NDP_RESPONDER_RSP_EVENTID;
11420 event_ids[wmi_ndp_end_indication_event_id] =
11421 WMI_NDP_END_INDICATION_EVENTID;
11422 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080011423 event_ids[wmi_ndl_schedule_update_event_id] =
11424 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011425
11426 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
11427 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
11428 event_ids[wmi_pdev_chip_power_stats_event_id] =
11429 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
11430 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
11431 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
11432 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011433 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011434 WMI_BPF_CAPABILIY_INFO_EVENTID;
11435 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
11436 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
11437 event_ids[wmi_report_rx_aggr_failure_event_id] =
11438 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
11439 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
11440 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
11441 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
11442 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
11443 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
11444 event_ids[wmi_pdev_hw_mode_transition_event_id] =
11445 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
11446 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
11447 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
11448 event_ids[wmi_coex_bt_activity_event_id] =
11449 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
11450 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
11451 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
11452 event_ids[wmi_radio_tx_power_level_stats_event_id] =
11453 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
11454 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053011455 event_ids[wmi_dma_buf_release_event_id] =
11456 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080011457 event_ids[wmi_sap_obss_detection_report_event_id] =
11458 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053011459 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080011460 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080011461 event_ids[wmi_obss_color_collision_report_event_id] =
11462 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080011463 event_ids[wmi_pdev_div_rssi_antid_event_id] =
11464 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070011465 event_ids[wmi_twt_enable_complete_event_id] =
11466 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011467 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
11468 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011469 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011470 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011471 event_ids[wmi_roam_scan_stats_event_id] = WMI_ROAM_SCAN_STATS_EVENTID;
Kiran Venkatappad73f4eb2018-07-19 22:22:29 +053011472#ifdef AST_HKV1_WORKAROUND
11473 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
11474#endif
Alok Singh0243e7d2018-09-20 16:07:28 +053011475 event_ids[wmi_pdev_ctl_failsafe_check_event_id] =
11476 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011477}
11478
Soumya Bhat488092d2017-03-22 14:41:01 +053011479/**
11480 * populate_tlv_service() - populates wmi services
11481 *
11482 * @param wmi_service: Pointer to hold wmi_service
11483 * Return: None
11484 */
11485static void populate_tlv_service(uint32_t *wmi_service)
11486{
11487 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053011488 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011489 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
11490 wmi_service[wmi_service_roam_scan_offload] =
11491 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
11492 wmi_service[wmi_service_bcn_miss_offload] =
11493 WMI_SERVICE_BCN_MISS_OFFLOAD;
11494 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
11495 wmi_service[wmi_service_sta_advanced_pwrsave] =
11496 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
11497 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
11498 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
11499 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
11500 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
11501 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
11502 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
11503 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
11504 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
11505 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
11506 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
11507 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
11508 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
11509 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
11510 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
11511 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
11512 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
11513 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
11514 wmi_service[wmi_service_packet_power_save] =
11515 WMI_SERVICE_PACKET_POWER_SAVE;
11516 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
11517 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
11518 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
11519 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
11520 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
11521 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
11522 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
11523 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
11524 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
11525 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
11526 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
11527 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
11528 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
11529 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
11530 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
11531 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
11532 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
11533 wmi_service[wmi_service_mcc_bcn_interval_change] =
11534 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
11535 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
11536 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
11537 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
11538 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
11539 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
11540 wmi_service[wmi_service_lte_ant_share_support] =
11541 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
11542 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
11543 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
11544 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
11545 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
11546 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
11547 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
11548 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
11549 wmi_service[wmi_service_bcn_txrate_override] =
11550 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
11551 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
11552 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
11553 wmi_service[wmi_service_estimate_linkspeed] =
11554 WMI_SERVICE_ESTIMATE_LINKSPEED;
11555 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
11556 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
11557 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
11558 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
11559 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
11560 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
11561 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
11562 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
11563 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
11564 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
11565 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
11566 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
11567 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
11568 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
11569 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
11570 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
11571 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
11572 wmi_service[wmi_service_sap_auth_offload] =
11573 WMI_SERVICE_SAP_AUTH_OFFLOAD;
11574 wmi_service[wmi_service_dual_band_simultaneous_support] =
11575 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
11576 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
11577 wmi_service[wmi_service_ap_arpns_offload] =
11578 WMI_SERVICE_AP_ARPNS_OFFLOAD;
11579 wmi_service[wmi_service_per_band_chainmask_support] =
11580 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
11581 wmi_service[wmi_service_packet_filter_offload] =
11582 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
11583 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
11584 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
11585 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
11586 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
11587 wmi_service[wmi_service_multiple_vdev_restart] =
11588 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
11589
11590 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
11591 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
11592 wmi_service[wmi_service_smart_antenna_sw_support] =
11593 WMI_SERVICE_UNAVAILABLE;
11594 wmi_service[wmi_service_smart_antenna_hw_support] =
11595 WMI_SERVICE_UNAVAILABLE;
11596 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053011597 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011598 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053011599 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
11600 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
11601 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
11602 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
11603 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
11604 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
11605 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
11606 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053011607 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
11608 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
11609 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011610 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011611 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
11612 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
11613 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
11614 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
11615 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
11616 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011617 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
11618 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
11619 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
11620 wmi_service[wmi_service_unified_wow_capability] =
11621 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
11622 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011623 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011624 wmi_service[wmi_service_sync_delete_cmds] =
11625 WMI_SERVICE_SYNC_DELETE_CMDS;
11626 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
11627 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
11628 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
11629 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
11630 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
11631 wmi_service[wmi_service_deprecated_replace] =
11632 WMI_SERVICE_DEPRECATED_REPLACE;
11633 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
11634 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
11635 wmi_service[wmi_service_enhanced_mcast_filter] =
11636 WMI_SERVICE_ENHANCED_MCAST_FILTER;
11637 wmi_service[wmi_service_half_rate_quarter_rate_support] =
11638 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
11639 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
11640 wmi_service[wmi_service_p2p_listen_offload_support] =
11641 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
11642 wmi_service[wmi_service_mark_first_wakeup_packet] =
11643 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
11644 wmi_service[wmi_service_multiple_mcast_filter_set] =
11645 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
11646 wmi_service[wmi_service_host_managed_rx_reorder] =
11647 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
11648 wmi_service[wmi_service_flash_rdwr_support] =
11649 WMI_SERVICE_FLASH_RDWR_SUPPORT;
11650 wmi_service[wmi_service_wlan_stats_report] =
11651 WMI_SERVICE_WLAN_STATS_REPORT;
11652 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
11653 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
11654 wmi_service[wmi_service_dfs_phyerr_offload] =
11655 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
11656 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
11657 wmi_service[wmi_service_fw_mem_dump_support] =
11658 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
11659 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
11660 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
11661 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
11662 wmi_service[wmi_service_hw_data_filtering] =
11663 WMI_SERVICE_HW_DATA_FILTERING;
11664 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
11665 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053011666 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053011667 wmi_service[wmi_service_extended_nss_support] =
11668 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053011669 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053011670 wmi_service[wmi_service_bcn_offload_start_stop_support] =
11671 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053011672 wmi_service[wmi_service_offchan_data_tid_support] =
11673 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053011674 wmi_service[wmi_service_support_dma] =
11675 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011676 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
11677 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
11678 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080011679 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
11680 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053011681 wmi_service[wmi_service_11k_neighbour_report_support] =
11682 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080011683 wmi_service[wmi_service_ap_obss_detection_offload] =
11684 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
11685 wmi_service[wmi_service_bss_color_offload] =
11686 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053011687 wmi_service[wmi_service_gmac_offload_support] =
11688 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080011689 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
11690 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
11691 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
11692 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070011693 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
11694 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053011695 wmi_service[wmi_service_listen_interval_offload_support] =
11696 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053011697 wmi_service[wmi_service_esp_support] = WMI_SERVICE_ESP_SUPPORT;
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011698 wmi_service[wmi_service_obss_spatial_reuse] =
11699 WMI_SERVICE_OBSS_SPATIAL_REUSE;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011700
Soumya Bhat488092d2017-03-22 14:41:01 +053011701}
11702
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011703#ifndef CONFIG_MCL
11704
Govind Singhe7f2f342016-05-23 12:12:52 +053011705/**
11706 * populate_pdev_param_tlv() - populates pdev params
11707 *
11708 * @param pdev_param: Pointer to hold pdev params
11709 * Return: None
11710 */
11711static void populate_pdev_param_tlv(uint32_t *pdev_param)
11712{
11713 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
11714 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
11715 pdev_param[wmi_pdev_param_txpower_limit2g] =
11716 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
11717 pdev_param[wmi_pdev_param_txpower_limit5g] =
11718 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
11719 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
11720 pdev_param[wmi_pdev_param_beacon_gen_mode] =
11721 WMI_PDEV_PARAM_BEACON_GEN_MODE;
11722 pdev_param[wmi_pdev_param_beacon_tx_mode] =
11723 WMI_PDEV_PARAM_BEACON_TX_MODE;
11724 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
11725 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
11726 pdev_param[wmi_pdev_param_protection_mode] =
11727 WMI_PDEV_PARAM_PROTECTION_MODE;
11728 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
11729 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
11730 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
11731 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
11732 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
11733 pdev_param[wmi_pdev_param_sta_kickout_th] =
11734 WMI_PDEV_PARAM_STA_KICKOUT_TH;
11735 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
11736 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
11737 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
11738 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
11739 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
11740 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
11741 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
11742 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
11743 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
11744 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
11745 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
11746 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
11747 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
11748 pdev_param[wmi_pdev_param_ltr_sleep_override] =
11749 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
11750 pdev_param[wmi_pdev_param_ltr_rx_override] =
11751 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
11752 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
11753 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
11754 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
11755 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
11756 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
11757 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
11758 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
11759 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
11760 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
11761 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
11762 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
11763 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
11764 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
11765 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
11766 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
11767 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
11768 pdev_param[wmi_pdev_param_peer_stats_update_period] =
11769 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
11770 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
11771 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
11772 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
11773 pdev_param[wmi_pdev_param_arp_ac_override] =
11774 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
11775 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
11776 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
11777 pdev_param[wmi_pdev_param_ani_poll_period] =
11778 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
11779 pdev_param[wmi_pdev_param_ani_listen_period] =
11780 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
11781 pdev_param[wmi_pdev_param_ani_ofdm_level] =
11782 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
11783 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
11784 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
11785 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
11786 pdev_param[wmi_pdev_param_idle_ps_config] =
11787 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
11788 pdev_param[wmi_pdev_param_power_gating_sleep] =
11789 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
11790 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
11791 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
11792 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
11793 pdev_param[wmi_pdev_param_hw_rfkill_config] =
11794 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
11795 pdev_param[wmi_pdev_param_low_power_rf_enable] =
11796 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
11797 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
11798 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
11799 pdev_param[wmi_pdev_param_power_collapse_enable] =
11800 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
11801 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
11802 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
11803 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
11804 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
11805 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
11806 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
11807 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
11808 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
11809 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
11810 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
11811 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
11812 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
11813 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
11814 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
11815 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
11816 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
11817 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
11818 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
11819 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
11820 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
11821 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
11822 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
11823 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
11824 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
11825 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
11826 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
11827 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
11828 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
11829 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
11830 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
11831 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
11832 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
11833 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
11834 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
11835 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
11836 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
11837 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
11838 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
11839 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
11840 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
11841 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
11842 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
11843 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
11844 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011845 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
11846 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
11847 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053011848 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
11849 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011850 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053011851 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011852 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
11853 pdev_param[wmi_pdev_param_proxy_sta_mode] =
11854 WMI_PDEV_PARAM_PROXY_STA_MODE;
11855 pdev_param[wmi_pdev_param_mu_group_policy] =
11856 WMI_PDEV_PARAM_MU_GROUP_POLICY;
11857 pdev_param[wmi_pdev_param_noise_detection] =
11858 WMI_PDEV_PARAM_NOISE_DETECTION;
11859 pdev_param[wmi_pdev_param_noise_threshold] =
11860 WMI_PDEV_PARAM_NOISE_THRESHOLD;
11861 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
11862 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
11863 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011864 pdev_param[wmi_pdev_param_atf_strict_sch] =
11865 WMI_PDEV_PARAM_ATF_STRICT_SCH;
11866 pdev_param[wmi_pdev_param_atf_sched_duration] =
11867 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011868 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
11869 pdev_param[wmi_pdev_param_sensitivity_level] =
11870 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
11871 pdev_param[wmi_pdev_param_signed_txpower_2g] =
11872 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
11873 pdev_param[wmi_pdev_param_signed_txpower_5g] =
11874 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070011875 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
11876 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
11877 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
11878 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011879 pdev_param[wmi_pdev_param_cca_threshold] =
11880 WMI_PDEV_PARAM_CCA_THRESHOLD;
11881 pdev_param[wmi_pdev_param_rts_fixed_rate] =
11882 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011883 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011884 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
11885 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
11886 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
11887 pdev_param[wmi_pdev_param_arp_srcaddr] =
11888 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
11889 pdev_param[wmi_pdev_param_arp_dstaddr] =
11890 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
11891 pdev_param[wmi_pdev_param_txpower_decr_db] =
11892 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053011893 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
11894 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011895 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
11896 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053011897 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011898 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011899 pdev_param[wmi_pdev_param_cust_txpower_scale] =
11900 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011901 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
11902 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011903 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
11904 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053011905 pdev_param[wmi_pdev_param_igmpmld_override] =
11906 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
11907 pdev_param[wmi_pdev_param_igmpmld_tid] =
11908 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011909 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
11910 pdev_param[wmi_pdev_param_block_interbss] =
11911 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053011912 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011913 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
11914 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
11915 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011916 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011917 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053011918 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
11919 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011920 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053011921 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
11922 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053011923 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
11924 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
11925 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
11926 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053011927 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
11928 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
11929 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
11930 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
11931 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
11932 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
11933 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
11934 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
11935 pdev_param[wmi_pdev_param_fast_channel_reset] =
11936 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
11937 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053011938 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053011939 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053011940 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
11941 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011942 pdev_param[wmi_pdev_param_esp_indication_period] =
11943 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053011944 pdev_param[wmi_pdev_param_esp_ba_window] = WMI_PDEV_PARAM_ESP_BA_WINDOW;
11945 pdev_param[wmi_pdev_param_esp_airtime_fraction] =
11946 WMI_PDEV_PARAM_ESP_AIRTIME_FRACTION;
11947 pdev_param[wmi_pdev_param_esp_ppdu_duration] =
11948 WMI_PDEV_PARAM_ESP_PPDU_DURATION;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053011949#ifdef WLAN_RU26_SUPPORT
11950 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
11951#endif
Abhijit Pradhanf6694f82018-10-17 10:13:15 +053011952 pdev_param[wmi_pdev_param_use_nol] = WMI_PDEV_PARAM_USE_NOL;
Govind Singhe7f2f342016-05-23 12:12:52 +053011953}
11954
11955/**
11956 * populate_vdev_param_tlv() - populates vdev params
11957 *
11958 * @param vdev_param: Pointer to hold vdev params
11959 * Return: None
11960 */
11961static void populate_vdev_param_tlv(uint32_t *vdev_param)
11962{
11963 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
11964 vdev_param[wmi_vdev_param_fragmentation_threshold] =
11965 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
11966 vdev_param[wmi_vdev_param_beacon_interval] =
11967 WMI_VDEV_PARAM_BEACON_INTERVAL;
11968 vdev_param[wmi_vdev_param_listen_interval] =
11969 WMI_VDEV_PARAM_LISTEN_INTERVAL;
11970 vdev_param[wmi_vdev_param_multicast_rate] =
11971 WMI_VDEV_PARAM_MULTICAST_RATE;
11972 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
11973 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
11974 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
11975 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
11976 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
11977 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
11978 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
11979 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
11980 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
11981 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
11982 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
11983 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
11984 vdev_param[wmi_vdev_param_bmiss_count_max] =
11985 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
11986 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
11987 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
11988 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
11989 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
11990 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
11991 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
11992 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
11993 vdev_param[wmi_vdev_param_disable_htprotection] =
11994 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
11995 vdev_param[wmi_vdev_param_sta_quickkickout] =
11996 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
11997 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
11998 vdev_param[wmi_vdev_param_protection_mode] =
11999 WMI_VDEV_PARAM_PROTECTION_MODE;
12000 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
12001 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
12002 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
12003 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
12004 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
12005 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
12006 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
12007 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
12008 vdev_param[wmi_vdev_param_bcast_data_rate] =
12009 WMI_VDEV_PARAM_BCAST_DATA_RATE;
12010 vdev_param[wmi_vdev_param_mcast_data_rate] =
12011 WMI_VDEV_PARAM_MCAST_DATA_RATE;
12012 vdev_param[wmi_vdev_param_mcast_indicate] =
12013 WMI_VDEV_PARAM_MCAST_INDICATE;
12014 vdev_param[wmi_vdev_param_dhcp_indicate] =
12015 WMI_VDEV_PARAM_DHCP_INDICATE;
12016 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
12017 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
12018 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
12019 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
12020 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
12021 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
12022 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
12023 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
12024 vdev_param[wmi_vdev_param_ap_enable_nawds] =
12025 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
12026 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
12027 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
12028 vdev_param[wmi_vdev_param_packet_powersave] =
12029 WMI_VDEV_PARAM_PACKET_POWERSAVE;
12030 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
12031 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
12032 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
12033 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
12034 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
12035 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
12036 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
12037 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
12038 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
12039 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
12040 vdev_param[wmi_vdev_param_early_rx_slop_step] =
12041 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
12042 vdev_param[wmi_vdev_param_early_rx_init_slop] =
12043 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
12044 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
12045 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
12046 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
12047 vdev_param[wmi_vdev_param_snr_num_for_cal] =
12048 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
12049 vdev_param[wmi_vdev_param_roam_fw_offload] =
12050 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
12051 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
12052 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
12053 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
12054 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
12055 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
12056 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
12057 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
12058 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
12059 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
12060 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
12061 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
12062 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
12063 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
12064 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
12065 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
12066 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
12067 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
12068 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
12069 vdev_param[wmi_vdev_param_inactivity_cnt] =
12070 WMI_VDEV_PARAM_INACTIVITY_CNT;
12071 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
12072 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
12073 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
12074 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
12075 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
12076 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
12077 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
12078 vdev_param[wmi_vdev_param_rx_leak_window] =
12079 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
12080 vdev_param[wmi_vdev_param_stats_avg_factor] =
12081 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
12082 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
12083 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
12084 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
12085 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
12086 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
12087 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053012088 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
12089 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053012090 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080012091 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
12092 vdev_param[wmi_vdev_param_he_range_ext_enable] =
12093 WMI_VDEV_PARAM_HE_RANGE_EXT;
12094 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
12095 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070012096 vdev_param[wmi_vdev_param_set_he_sounding_mode]
12097 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070012098 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053012099 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
12100 vdev_param[wmi_vdev_param_dtim_enable_cts] =
12101 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
12102 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
12103 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
12104 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
12105 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053012106 vdev_param[wmi_vdev_param_mcast2ucast_set] =
12107 WMI_VDEV_PARAM_MCAST2UCAST_SET;
12108 vdev_param[wmi_vdev_param_rc_num_retries] =
12109 WMI_VDEV_PARAM_RC_NUM_RETRIES;
12110 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
12111 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
12112 vdev_param[wmi_vdev_param_rts_fixed_rate] =
12113 WMI_VDEV_PARAM_RTS_FIXED_RATE;
12114 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
12115 vdev_param[wmi_vdev_param_vht80_ratemask] =
12116 WMI_VDEV_PARAM_VHT80_RATEMASK;
12117 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
12118 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
12119 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012120 vdev_param[wmi_vdev_param_set_he_ltf] =
12121 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053012122 vdev_param[wmi_vdev_param_disable_cabq] =
12123 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053012124 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
12125 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080012126 vdev_param[wmi_vdev_param_set_ba_mode] =
12127 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080012128 vdev_param[wmi_vdev_param_capabilities] =
12129 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012130 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
12131 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053012132}
12133#endif
12134
Govind Singh5eb51532016-03-09 11:34:12 +053012135/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012136 * populate_target_defines_tlv() - Populate target defines and params
12137 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053012138 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012139 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053012140 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012141#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012142static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053012143{
Govind Singhe7f2f342016-05-23 12:12:52 +053012144 populate_pdev_param_tlv(wmi_handle->pdev_param);
12145 populate_vdev_param_tlv(wmi_handle->vdev_param);
12146}
12147#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012148static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
12149{ }
12150#endif
12151
12152/**
Zhang Qian537fca62018-01-03 16:33:24 +080012153 * wmi_ocb_ut_attach() - Attach OCB test framework
12154 * @wmi_handle: wmi handle
12155 *
12156 * Return: None
12157 */
12158#ifdef WLAN_OCB_UT
12159void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
12160#else
12161static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
12162{
12163 return;
12164}
12165#endif
12166
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012167/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012168 * wmi_tlv_attach() - Attach TLV APIs
12169 *
12170 * Return: None
12171 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012172void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053012173{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012174 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080012175 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053012176 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053012177#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053012178 /* Skip saving WMI_CMD_HDR and TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012179 wmi_handle->soc->buf_offset_command = 8;
Rakesh Pillai05110462017-12-27 14:08:59 +053012180 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012181 wmi_handle->soc->buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053012182#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053012183 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053012184 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012185 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053012186 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080012187 wmi_extscan_attach_tlv(wmi_handle);
Sathish Kumarefb25bf2018-10-02 11:03:59 +053012188 wmi_smart_ant_attach_tlv(wmi_handle);
12189 wmi_dbr_attach_tlv(wmi_handle);
12190 wmi_atf_attach_tlv(wmi_handle);
12191 wmi_ap_attach_tlv(wmi_handle);
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080012192 wmi_ocb_attach_tlv(wmi_handle);
12193 wmi_nan_attach_tlv(wmi_handle);
12194 wmi_p2p_attach_tlv(wmi_handle);
12195 wmi_roam_attach_tlv(wmi_handle);
12196 wmi_concurrency_attach_tlv(wmi_handle);
12197 wmi_pmo_attach_tlv(wmi_handle);
12198 wmi_sta_attach_tlv(wmi_handle);
12199 wmi_11ax_bss_color_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053012200}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080012201qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053012202
12203/**
12204 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
12205 *
12206 * Return: None
12207 */
12208void wmi_tlv_init(void)
12209{
12210 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
12211}