blob: 8472ee02305652d886a7df34ebde7405be91b786 [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>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053026#include <htc_services.h>
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053027#ifdef FEATURE_WLAN_APF
Nachiket Kukade7d4f04b2018-05-21 17:28:32 +053028#include "wmi_unified_apf_tlv.h"
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053029#endif
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053030#ifdef WLAN_FEATURE_ACTION_OUI
31#include "wmi_unified_action_oui_tlv.h"
32#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080033#ifdef CONVERGED_P2P_ENABLE
34#include "wlan_p2p_public_struct.h"
35#endif
Wu Gao52c0b772018-05-17 16:14:00 +080036#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070037#include "wlan_pmo_hw_filter_public_struct.h"
38#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053039#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053040#ifdef WLAN_SUPPORT_GREEN_AP
41#include "wlan_green_ap_api.h"
42#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053043
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080044#ifdef WLAN_FEATURE_NAN_CONVERGENCE
45#include "nan_public_structs.h"
46#endif
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070047#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080048
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080049#ifdef WLAN_POLICY_MGR_ENABLE
50#include "wlan_policy_mgr_public_struct.h"
51#endif
52
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053053/* HTC service ids for WMI for multi-radio */
54static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
55 WMI_CONTROL_SVC_WMAC1,
56 WMI_CONTROL_SVC_WMAC2};
57
Arif Hussainb522ac92018-06-27 10:51:06 -070058/**
59 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
60 * host to target defines.
61 * @param pdev_id: host pdev_id to be converted.
62 * Return: target pdev_id after conversion.
63 */
64static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
65{
66 switch (pdev_id) {
67 case WMI_HOST_PDEV_ID_SOC:
68 return WMI_PDEV_ID_SOC;
69 case WMI_HOST_PDEV_ID_0:
70 return WMI_PDEV_ID_1ST;
71 case WMI_HOST_PDEV_ID_1:
72 return WMI_PDEV_ID_2ND;
73 case WMI_HOST_PDEV_ID_2:
74 return WMI_PDEV_ID_3RD;
75 }
76
77 QDF_ASSERT(0);
78
79 return WMI_PDEV_ID_SOC;
80}
81
82/**
83 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
84 * target to host defines.
85 * @param pdev_id: target pdev_id to be converted.
86 * Return: host pdev_id after conversion.
87 */
88static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
89{
90 switch (pdev_id) {
91 case WMI_PDEV_ID_SOC:
92 return WMI_HOST_PDEV_ID_SOC;
93 case WMI_PDEV_ID_1ST:
94 return WMI_HOST_PDEV_ID_0;
95 case WMI_PDEV_ID_2ND:
96 return WMI_HOST_PDEV_ID_1;
97 case WMI_PDEV_ID_3RD:
98 return WMI_HOST_PDEV_ID_2;
99 }
100
101 QDF_ASSERT(0);
102
103 return WMI_HOST_PDEV_ID_SOC;
104}
105
106/**
107 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
108 *
109 * Return None.
110 */
111static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
112{
113 wmi_handle->ops->convert_pdev_id_host_to_target =
114 convert_host_pdev_id_to_target_pdev_id;
115 wmi_handle->ops->convert_pdev_id_target_to_host =
116 convert_target_pdev_id_to_host_pdev_id;
117}
118
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530119/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
120 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530121 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530122 * @cmd: pointer target vdev create command buffer
123 * @param: pointer host params for vdev create
124 *
125 * Return: None
126 */
127#ifdef CONFIG_MCL
128static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530129 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530130 wmi_vdev_create_cmd_fixed_param * cmd,
131 struct vdev_create_params *param)
132{
133 cmd->pdev_id = WMI_PDEV_ID_SOC;
134}
135#else
136static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530137 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530138 wmi_vdev_create_cmd_fixed_param * cmd,
139 struct vdev_create_params *param)
140{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530141 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
142 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530143}
144#endif
145
Govind Singh5eb51532016-03-09 11:34:12 +0530146/**
147 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
148 * @wmi_handle: wmi handle
149 * @param: pointer to hold vdev create parameter
150 * @macaddr: vdev mac address
151 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530152 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530153 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530154static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530155 uint8_t macaddr[IEEE80211_ADDR_LEN],
156 struct vdev_create_params *param)
157{
158 wmi_vdev_create_cmd_fixed_param *cmd;
159 wmi_buf_t buf;
160 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530161 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700162 int num_bands = 2;
163 uint8_t *buf_ptr;
164 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530165
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700166 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530167 buf = wmi_buf_alloc(wmi_handle, len);
168 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530169 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530170 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530171 }
172 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
173 WMITLV_SET_HDR(&cmd->tlv_header,
174 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
175 WMITLV_GET_STRUCT_TLVLEN
176 (wmi_vdev_create_cmd_fixed_param));
177 cmd->vdev_id = param->if_id;
178 cmd->vdev_type = param->type;
179 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700180 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530181 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530182 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700183 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
184 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530185 macaddr[0], macaddr[1], macaddr[2],
186 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700187 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
188 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
189 (num_bands * sizeof(wmi_vdev_txrx_streams)));
190 buf_ptr += WMI_TLV_HDR_SIZE;
191
Govind Singh224a7312016-06-21 14:33:26 +0530192 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700193 param->type, param->subtype,
194 param->nss_2g, param->nss_5g);
195 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
196 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
197 txrx_streams->supported_tx_streams = param->nss_2g;
198 txrx_streams->supported_rx_streams = param->nss_2g;
199 WMITLV_SET_HDR(&txrx_streams->tlv_header,
200 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
201 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
202
203 txrx_streams++;
204 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
205 txrx_streams->supported_tx_streams = param->nss_5g;
206 txrx_streams->supported_rx_streams = param->nss_5g;
207 WMITLV_SET_HDR(&txrx_streams->tlv_header,
208 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
209 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530210 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530211 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530212 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530213 wmi_buf_free(buf);
214 }
215
216 return ret;
217}
218
219/**
220 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
221 * @wmi_handle: wmi handle
222 * @if_id: vdev id
223 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530224 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530225 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530226static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530227 uint8_t if_id)
228{
229 wmi_vdev_delete_cmd_fixed_param *cmd;
230 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530231 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530232
233 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
234 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530235 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530236 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530237 }
238
239 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
240 WMITLV_SET_HDR(&cmd->tlv_header,
241 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
242 WMITLV_GET_STRUCT_TLVLEN
243 (wmi_vdev_delete_cmd_fixed_param));
244 cmd->vdev_id = if_id;
245 ret = wmi_unified_cmd_send(wmi_handle, buf,
246 sizeof(wmi_vdev_delete_cmd_fixed_param),
247 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530248 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530249 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530250 wmi_buf_free(buf);
251 }
Govind Singhb53420c2016-03-09 14:32:57 +0530252 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530253
254 return ret;
255}
256
257/**
258 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
259 * @wmi: wmi handle
260 * @vdev_id: vdev id
261 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530262 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530263 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530264static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530265 uint8_t vdev_id)
266{
267 wmi_vdev_stop_cmd_fixed_param *cmd;
268 wmi_buf_t buf;
269 int32_t len = sizeof(*cmd);
270
271 buf = wmi_buf_alloc(wmi, len);
272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530273 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530274 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530275 }
276 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
277 WMITLV_SET_HDR(&cmd->tlv_header,
278 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
279 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
280 cmd->vdev_id = vdev_id;
281 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530282 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530283 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530284 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530285 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530286 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530287
288 return 0;
289}
290
291/**
292 * send_vdev_down_cmd_tlv() - send vdev down command to fw
293 * @wmi: wmi handle
294 * @vdev_id: vdev id
295 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530296 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530297 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530298static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530299{
300 wmi_vdev_down_cmd_fixed_param *cmd;
301 wmi_buf_t buf;
302 int32_t len = sizeof(*cmd);
303
304 buf = wmi_buf_alloc(wmi, len);
305 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530306 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530307 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530308 }
309 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
310 WMITLV_SET_HDR(&cmd->tlv_header,
311 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
312 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
313 cmd->vdev_id = vdev_id;
314 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530315 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530316 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530317 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530318 }
Govind Singhb53420c2016-03-09 14:32:57 +0530319 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530320
321 return 0;
322}
323
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530324#ifdef CONFIG_MCL
325static inline void copy_channel_info(
326 wmi_vdev_start_request_cmd_fixed_param * cmd,
327 wmi_channel *chan,
328 struct vdev_start_params *req)
329{
330 chan->mhz = req->chan_freq;
331
332 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
333
334 chan->band_center_freq1 = req->band_center_freq1;
335 chan->band_center_freq2 = req->band_center_freq2;
336
337 if (req->is_half_rate)
338 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
339 else if (req->is_quarter_rate)
340 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
341
Naveen Rawat44f2f432016-12-01 12:58:57 -0800342 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530343 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
344 cmd->disable_hw_ack = req->dis_hw_ack;
345 }
346
347 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
348 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
349
350}
351#else
352static inline void copy_channel_info(
353 wmi_vdev_start_request_cmd_fixed_param * cmd,
354 wmi_channel *chan,
355 struct vdev_start_params *req)
356{
357 chan->mhz = req->channel.mhz;
358
359 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
360
361 chan->band_center_freq1 = req->channel.cfreq1;
362 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800363 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530364
365 if (req->channel.half_rate)
366 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
367 else if (req->channel.quarter_rate)
368 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
369
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800370 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
371
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530372 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530373 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530374 cmd->disable_hw_ack = req->disable_hw_ack;
375 }
376
Krishna Rao0b952ea2017-03-20 13:30:10 +0530377 if (req->channel.dfs_set_cfreq2)
378 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
379
Kai Chen4710d462017-12-15 14:06:06 -0800380 /* According to firmware both reg power and max tx power
381 * on set channel power is used and set it to max reg
382 * power from regulatory.
383 */
384 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
385 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530386 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800387 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
388 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
389 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530390
391}
392#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530393/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 * send_vdev_start_cmd_tlv() - send vdev start request to fw
395 * @wmi_handle: wmi handle
396 * @req: vdev start params
397 *
398 * Return: QDF status
399 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530400static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401 struct vdev_start_params *req)
402{
403 wmi_vdev_start_request_cmd_fixed_param *cmd;
404 wmi_buf_t buf;
405 wmi_channel *chan;
406 int32_t len, ret;
407 uint8_t *buf_ptr;
408
409 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
410 buf = wmi_buf_alloc(wmi_handle, len);
411 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530412 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 return QDF_STATUS_E_NOMEM;
414 }
415 buf_ptr = (uint8_t *) wmi_buf_data(buf);
416 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
417 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
418 WMITLV_SET_HDR(&cmd->tlv_header,
419 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
420 WMITLV_GET_STRUCT_TLVLEN
421 (wmi_vdev_start_request_cmd_fixed_param));
422 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
423 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
424 cmd->vdev_id = req->vdev_id;
425
426 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530427 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530428
429 cmd->beacon_interval = req->beacon_intval;
430 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800432 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
433 if (req->bcn_tx_rate_code)
434 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
435
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530436 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530437 cmd->beacon_interval = req->beacon_intval;
438 cmd->dtim_period = req->dtim_period;
439
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530440 /* Copy the SSID */
441 if (req->ssid.length) {
442 if (req->ssid.length < sizeof(cmd->ssid.ssid))
443 cmd->ssid.ssid_len = req->ssid.length;
444 else
445 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
446 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
447 cmd->ssid.ssid_len);
448 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530449
450 if (req->hidden_ssid)
451 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
452
453 if (req->pmf_enabled)
454 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530455 }
456
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700457 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530458 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530459 cmd->preferred_rx_streams = req->preferred_rx_streams;
460 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700461 cmd->cac_duration_ms = req->cac_duration_ms;
462 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700463 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530464
465 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
466 sizeof(wmi_channel));
467 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
468 cmd->num_noa_descriptors *
469 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800470 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530471 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
472 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800473 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
474 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
475 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530476 req->is_dfs, req->beacon_intval, cmd->dtim_period,
477 chan->band_center_freq1, chan->band_center_freq2,
478 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700479 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700480 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800481 req->regdomain, req->he_ops,
482 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530483
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530484 if (req->is_restart)
485 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
486 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530487 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530488 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
489 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530490 if (ret) {
491 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530492 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530493 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530494 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530495
496 return QDF_STATUS_SUCCESS;
497}
498
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530499/**
500 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
501 * @wmi_handle: wmi handle
502 * @restart_params: vdev restart params
503 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530504 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530505 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530506static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530507 struct hidden_ssid_vdev_restart_params *restart_params)
508{
509 wmi_vdev_start_request_cmd_fixed_param *cmd;
510 wmi_buf_t buf;
511 wmi_channel *chan;
512 int32_t len;
513 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530514 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530515
516 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
517 buf = wmi_buf_alloc(wmi_handle, len);
518 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530519 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530520 return QDF_STATUS_E_NOMEM;
521 }
522 buf_ptr = (uint8_t *) wmi_buf_data(buf);
523 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
524 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
525
526 WMITLV_SET_HDR(&cmd->tlv_header,
527 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
528 WMITLV_GET_STRUCT_TLVLEN
529 (wmi_vdev_start_request_cmd_fixed_param));
530
531 WMITLV_SET_HDR(&chan->tlv_header,
532 WMITLV_TAG_STRUC_wmi_channel,
533 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
534
535 cmd->vdev_id = restart_params->session_id;
536 cmd->ssid.ssid_len = restart_params->ssid_len;
537 qdf_mem_copy(cmd->ssid.ssid,
538 restart_params->ssid,
539 cmd->ssid.ssid_len);
540 cmd->flags = restart_params->flags;
541 cmd->requestor_id = restart_params->requestor_id;
542 cmd->disable_hw_ack = restart_params->disable_hw_ack;
543
544 chan->mhz = restart_params->mhz;
545 chan->band_center_freq1 =
546 restart_params->band_center_freq1;
547 chan->band_center_freq2 =
548 restart_params->band_center_freq2;
549 chan->info = restart_params->info;
550 chan->reg_info_1 = restart_params->reg_info_1;
551 chan->reg_info_2 = restart_params->reg_info_2;
552
553 cmd->num_noa_descriptors = 0;
554 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
555 sizeof(wmi_channel));
556 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
557 cmd->num_noa_descriptors *
558 sizeof(wmi_p2p_noa_descriptor));
559
560 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
561 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530562 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530563 wmi_buf_free(buf);
564 return QDF_STATUS_E_FAILURE;
565 }
566 return QDF_STATUS_SUCCESS;
567}
568
569
570/**
Govind Singh5eb51532016-03-09 11:34:12 +0530571 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
572 * @wmi: wmi handle
573 * @peer_addr: peer mac address
574 * @param: pointer to hold peer flush tid parameter
575 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700576 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530577 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530578static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530579 uint8_t peer_addr[IEEE80211_ADDR_LEN],
580 struct peer_flush_params *param)
581{
582 wmi_peer_flush_tids_cmd_fixed_param *cmd;
583 wmi_buf_t buf;
584 int32_t len = sizeof(*cmd);
585
586 buf = wmi_buf_alloc(wmi, len);
587 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530588 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530589 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530590 }
591 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
592 WMITLV_SET_HDR(&cmd->tlv_header,
593 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
594 WMITLV_GET_STRUCT_TLVLEN
595 (wmi_peer_flush_tids_cmd_fixed_param));
596 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
597 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
598 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530599 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530600 peer_addr, param->vdev_id,
601 param->peer_tid_bitmap);
602 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530603 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530604 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530605 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530606 }
607
608 return 0;
609}
610
611/**
612 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
613 * @wmi: wmi handle
614 * @peer_addr: peer mac addr
615 * @vdev_id: vdev id
616 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530617 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530618 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530619static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530620 uint8_t peer_addr[IEEE80211_ADDR_LEN],
621 uint8_t vdev_id)
622{
623 wmi_peer_delete_cmd_fixed_param *cmd;
624 wmi_buf_t buf;
625 int32_t len = sizeof(*cmd);
626 buf = wmi_buf_alloc(wmi, len);
627 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530628 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530629 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530630 }
631 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
632 WMITLV_SET_HDR(&cmd->tlv_header,
633 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
634 WMITLV_GET_STRUCT_TLVLEN
635 (wmi_peer_delete_cmd_fixed_param));
636 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
637 cmd->vdev_id = vdev_id;
638
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800639 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530640 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530641 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530642 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530643 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530644 }
Govind Singh5eb51532016-03-09 11:34:12 +0530645
646 return 0;
647}
648
649/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530650 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
651 * to target id.
652 * @targ_paramid: Target parameter id to hold the result.
653 * @peer_param_id: host param id.
654 *
655 * Return: QDF_STATUS_SUCCESS for success
656 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
657 */
658#ifdef CONFIG_MCL
659static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
660 uint32_t *targ_paramid,
661 uint32_t peer_param_id)
662{
663 *targ_paramid = peer_param_id;
664 return QDF_STATUS_SUCCESS;
665}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700666
667/**
668 * crash_on_send_peer_rx_reorder_queue_remove_cmd() - crash on reorder queue cmd
669 *
670 * On MCL side, we are suspecting this cmd to trigger drop of ARP
671 * response frames from REO by the FW. This function causes a crash if this
672 * command is sent out by the host, so we can track this issue. Ideally no one
673 * should be calling this API from the MCL side
674 *
675 * Return: None
676 */
677static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
678{
679 QDF_BUG(0);
680}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530681#else
682static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
683 uint32_t *targ_paramid,
684 uint32_t peer_param_id)
685{
686 switch (peer_param_id) {
687 case WMI_HOST_PEER_MIMO_PS_STATE:
688 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
689 break;
690 case WMI_HOST_PEER_AMPDU:
691 *targ_paramid = WMI_PEER_AMPDU;
692 break;
693 case WMI_HOST_PEER_AUTHORIZE:
694 *targ_paramid = WMI_PEER_AUTHORIZE;
695 break;
696 case WMI_HOST_PEER_CHWIDTH:
697 *targ_paramid = WMI_PEER_CHWIDTH;
698 break;
699 case WMI_HOST_PEER_NSS:
700 *targ_paramid = WMI_PEER_NSS;
701 break;
702 case WMI_HOST_PEER_USE_4ADDR:
703 *targ_paramid = WMI_PEER_USE_4ADDR;
704 break;
705 case WMI_HOST_PEER_MEMBERSHIP:
706 *targ_paramid = WMI_PEER_MEMBERSHIP;
707 break;
708 case WMI_HOST_PEER_USERPOS:
709 *targ_paramid = WMI_PEER_USERPOS;
710 break;
711 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
712 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
713 break;
714 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
715 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
716 break;
717 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
718 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
719 break;
720 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
721 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
722 break;
723 case WMI_HOST_PEER_PHYMODE:
724 *targ_paramid = WMI_PEER_PHYMODE;
725 break;
726 case WMI_HOST_PEER_USE_FIXED_PWR:
727 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
728 break;
729 case WMI_HOST_PEER_PARAM_FIXED_RATE:
730 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
731 break;
732 case WMI_HOST_PEER_SET_MU_WHITELIST:
733 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
734 break;
735 case WMI_HOST_PEER_SET_MAC_TX_RATE:
736 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
737 break;
738 case WMI_HOST_PEER_SET_MIN_TX_RATE:
739 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
740 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530741 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
742 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
743 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530744 case WMI_HOST_PEER_NSS_VHT160:
745 *targ_paramid = WMI_PEER_NSS_VHT160;
746 break;
747 case WMI_HOST_PEER_NSS_VHT80_80:
748 *targ_paramid = WMI_PEER_NSS_VHT80_80;
749 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530750 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
751 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
752 break;
753 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
754 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
755 break;
756 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
757 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
758 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530759 case WMI_HOST_PEER_PARAM_MU_ENABLE:
760 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
761 break;
762 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
763 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
764 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530765 default:
766 return QDF_STATUS_E_NOSUPPORT;
767 }
768
769 return QDF_STATUS_SUCCESS;
770}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700771
772static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
773{
774 /* No-OP */
775}
776
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530777#endif
778/**
Govind Singh5eb51532016-03-09 11:34:12 +0530779 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530780 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530781 * @peer_addr: peer mac address
782 * @param : pointer to hold peer set parameter
783 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530784 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530785 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530786static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530787 uint8_t peer_addr[IEEE80211_ADDR_LEN],
788 struct peer_set_params *param)
789{
790 wmi_peer_set_param_cmd_fixed_param *cmd;
791 wmi_buf_t buf;
792 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530793 uint32_t param_id;
794
795 if (convert_host_peer_id_to_target_id_tlv(&param_id,
796 param->param_id) != QDF_STATUS_SUCCESS)
797 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530798
799 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
800 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530801 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530802 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530803 }
804 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
805 WMITLV_SET_HDR(&cmd->tlv_header,
806 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
807 WMITLV_GET_STRUCT_TLVLEN
808 (wmi_peer_set_param_cmd_fixed_param));
809 cmd->vdev_id = param->vdev_id;
810 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530811 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530812 cmd->param_value = param->param_value;
813 err = wmi_unified_cmd_send(wmi, buf,
814 sizeof(wmi_peer_set_param_cmd_fixed_param),
815 WMI_PEER_SET_PARAM_CMDID);
816 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530817 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530818 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530819 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530820 }
821
822 return 0;
823}
824
825/**
826 * send_vdev_up_cmd_tlv() - send vdev up command in fw
827 * @wmi: wmi handle
828 * @bssid: bssid
829 * @vdev_up_params: pointer to hold vdev up parameter
830 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530831 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530832 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530833static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530834 uint8_t bssid[IEEE80211_ADDR_LEN],
835 struct vdev_up_params *params)
836{
837 wmi_vdev_up_cmd_fixed_param *cmd;
838 wmi_buf_t buf;
839 int32_t len = sizeof(*cmd);
840
Govind Singhb53420c2016-03-09 14:32:57 +0530841 WMI_LOGD("%s: VDEV_UP", __func__);
842 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530843 params->vdev_id, params->assoc_id, bssid);
844 buf = wmi_buf_alloc(wmi, len);
845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530846 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530847 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530848 }
849 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
850 WMITLV_SET_HDR(&cmd->tlv_header,
851 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
852 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
853 cmd->vdev_id = params->vdev_id;
854 cmd->vdev_assoc_id = params->assoc_id;
855 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
856 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530857 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530858 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530859 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530860 }
861
862 return 0;
863}
864
865/**
866 * send_peer_create_cmd_tlv() - send peer create command to fw
867 * @wmi: wmi handle
868 * @peer_addr: peer mac address
869 * @peer_type: peer type
870 * @vdev_id: vdev id
871 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530872 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530873 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530874static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530875 struct peer_create_params *param)
876{
877 wmi_peer_create_cmd_fixed_param *cmd;
878 wmi_buf_t buf;
879 int32_t len = sizeof(*cmd);
880
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_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
887 WMITLV_SET_HDR(&cmd->tlv_header,
888 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
889 WMITLV_GET_STRUCT_TLVLEN
890 (wmi_peer_create_cmd_fixed_param));
891 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
892 cmd->peer_type = param->peer_type;
893 cmd->vdev_id = param->vdev_id;
894
895 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530896 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530897 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530898 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530899 }
Govind Singhb53420c2016-03-09 14:32:57 +0530900 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530901 param->vdev_id);
902
903 return 0;
904}
905
906/**
Leo Changeee40872016-09-28 13:43:36 -0700907 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
908 * command to fw
909 * @wmi: wmi handle
910 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
911 *
912 * Return: 0 for success or error code
913 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700914static
Leo Changeee40872016-09-28 13:43:36 -0700915QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
916 struct rx_reorder_queue_setup_params *param)
917{
918 wmi_peer_reorder_queue_setup_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) {
924 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
925 return QDF_STATUS_E_NOMEM;
926 }
927 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
928 WMITLV_SET_HDR(&cmd->tlv_header,
929 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
930 WMITLV_GET_STRUCT_TLVLEN
931 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
932 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
933 cmd->vdev_id = param->vdev_id;
934 cmd->tid = param->tid;
935 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
936 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
937 cmd->queue_no = param->queue_no;
Gyanranjan Hazarikad6c4d782018-07-25 23:26:16 -0700938 cmd->ba_window_size_valid = param->ba_window_size_valid;
939 cmd->ba_window_size = param->ba_window_size;
940
Leo Changeee40872016-09-28 13:43:36 -0700941
942 if (wmi_unified_cmd_send(wmi, buf, len,
943 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
944 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
945 __func__);
946 qdf_nbuf_free(buf);
947 return QDF_STATUS_E_FAILURE;
948 }
949 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
950 param->peer_macaddr, param->vdev_id, param->tid);
951
952 return QDF_STATUS_SUCCESS;
953}
954
955/**
956 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
957 * command to fw
958 * @wmi: wmi handle
959 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
960 *
961 * Return: 0 for success or error code
962 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700963static
Leo Changeee40872016-09-28 13:43:36 -0700964QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
965 struct rx_reorder_queue_remove_params *param)
966{
967 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
968 wmi_buf_t buf;
969 int32_t len = sizeof(*cmd);
970
Mohit Khannab9e1e542018-07-24 15:28:04 -0700971 crash_on_send_peer_rx_reorder_queue_remove_cmd();
972
Leo Changeee40872016-09-28 13:43:36 -0700973 buf = wmi_buf_alloc(wmi, len);
974 if (!buf) {
975 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
976 return QDF_STATUS_E_NOMEM;
977 }
978 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
979 wmi_buf_data(buf);
980 WMITLV_SET_HDR(&cmd->tlv_header,
981 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
982 WMITLV_GET_STRUCT_TLVLEN
983 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
984 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
985 cmd->vdev_id = param->vdev_id;
986 cmd->tid_mask = param->peer_tid_bitmap;
987
988 if (wmi_unified_cmd_send(wmi, buf, len,
989 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
990 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
991 __func__);
992 qdf_nbuf_free(buf);
993 return QDF_STATUS_E_FAILURE;
994 }
995 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
996 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
997
998 return QDF_STATUS_SUCCESS;
999}
1000
1001/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301002 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
1003 * @wmi_handle: wmi handle
1004 * @param: pointer holding peer details
1005 *
1006 * Return: 0 for success or error code
1007 */
1008static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1009 struct peer_add_wds_entry_params *param)
1010{
1011 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
1012 wmi_buf_t buf;
1013 int len = sizeof(*cmd);
1014
1015 buf = wmi_buf_alloc(wmi_handle, len);
1016 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301017 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301018 return QDF_STATUS_E_FAILURE;
1019 }
1020 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
1021 WMITLV_SET_HDR(&cmd->tlv_header,
1022 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
1023 WMITLV_GET_STRUCT_TLVLEN
1024 (wmi_peer_add_wds_entry_cmd_fixed_param));
1025 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
1026 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001027 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1028 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301029
1030 return wmi_unified_cmd_send(wmi_handle, buf, len,
1031 WMI_PEER_ADD_WDS_ENTRY_CMDID);
1032}
1033
1034/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05301035 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301036 * @wmi_handle: wmi handle
1037 * @param: pointer holding peer details
1038 *
1039 * Return: 0 for success or error code
1040 */
1041static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1042 struct peer_del_wds_entry_params *param)
1043{
1044 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
1045 wmi_buf_t buf;
1046 int len = sizeof(*cmd);
1047
1048 buf = wmi_buf_alloc(wmi_handle, len);
1049 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301050 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301051 return QDF_STATUS_E_NOMEM;
1052 }
1053 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1054 WMITLV_SET_HDR(&cmd->tlv_header,
1055 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
1056 WMITLV_GET_STRUCT_TLVLEN
1057 (wmi_peer_remove_wds_entry_cmd_fixed_param));
1058 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001059 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301060 return wmi_unified_cmd_send(wmi_handle, buf, len,
1061 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
1062}
1063
1064/**
1065 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
1066 * @wmi_handle: wmi handle
1067 * @param: pointer holding peer details
1068 *
1069 * Return: 0 for success or error code
1070 */
1071static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1072 struct peer_update_wds_entry_params *param)
1073{
1074 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
1075 wmi_buf_t buf;
1076 int len = sizeof(*cmd);
1077
1078 buf = wmi_buf_alloc(wmi_handle, len);
1079 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301080 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301081 return QDF_STATUS_E_NOMEM;
1082 }
1083
1084 /* wmi_buf_alloc returns zeroed command buffer */
1085 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1086 WMITLV_SET_HDR(&cmd->tlv_header,
1087 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1088 WMITLV_GET_STRUCT_TLVLEN
1089 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001090 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1091 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301092 if (param->wds_macaddr)
1093 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1094 &cmd->wds_macaddr);
1095 if (param->peer_macaddr)
1096 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1097 &cmd->peer_macaddr);
1098 return wmi_unified_cmd_send(wmi_handle, buf, len,
1099 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1100}
1101
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001102/**
1103 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1104 * @wmi_handle: wmi handle
1105 * @param: pointer to get tpc config params
1106 *
1107 * Return: 0 for success or error code
1108 */
1109static QDF_STATUS
1110send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1111 uint32_t param)
1112{
1113 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1114 wmi_buf_t buf;
1115 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1116
1117 buf = wmi_buf_alloc(wmi_handle, len);
1118 if (!buf) {
1119 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1120 return QDF_STATUS_E_NOMEM;
1121 }
1122 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1123 WMITLV_SET_HDR(&cmd->tlv_header,
1124 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1125 WMITLV_GET_STRUCT_TLVLEN
1126 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1127
1128 cmd->param = param;
1129 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1130 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1131 WMI_LOGE("Send pdev get tpc config cmd failed");
1132 wmi_buf_free(buf);
1133 return QDF_STATUS_E_FAILURE;
1134
1135 }
1136 WMI_LOGD("%s:send success", __func__);
1137
1138 return QDF_STATUS_SUCCESS;
1139}
1140
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301141#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301142/**
Govind Singh5eb51532016-03-09 11:34:12 +05301143 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1144 * @wmi_handle: wmi handle
1145 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301146 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301147 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301148 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301149 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301150static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301151 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301152{
1153 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1154 wmi_buf_t buf;
1155 int32_t len = sizeof(*cmd);
1156
Govind Singhb53420c2016-03-09 14:32:57 +05301157 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301158
1159 buf = wmi_buf_alloc(wmi_handle, len);
1160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301161 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301162 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301163 }
1164
1165 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1166 WMITLV_SET_HDR(&cmd->tlv_header,
1167 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1168 WMITLV_GET_STRUCT_TLVLEN
1169 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301170 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301171 cmd->enable = value;
1172
1173 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1174 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301175 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301176 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301177 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301178 }
1179
1180 return 0;
1181}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301182#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301183
1184/**
1185 * send_pdev_utf_cmd_tlv() - send utf command to fw
1186 * @wmi_handle: wmi handle
1187 * @param: pointer to pdev_utf_params
1188 * @mac_id: mac id to have radio context
1189 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301190 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301191 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301192static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301193send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1194 struct pdev_utf_params *param,
1195 uint8_t mac_id)
1196{
1197 wmi_buf_t buf;
1198 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001199 /* if param->len is 0 no data is sent, return error */
1200 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301201 static uint8_t msgref = 1;
1202 uint8_t segNumber = 0, segInfo, numSegments;
1203 uint16_t chunk_len, total_bytes;
1204 uint8_t *bufpos;
1205 struct seg_hdr_info segHdrInfo;
1206
1207 bufpos = param->utf_payload;
1208 total_bytes = param->len;
1209 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1210 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1211 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1212
1213 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1214 numSegments++;
1215
1216 while (param->len) {
1217 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001218 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301219 else
1220 chunk_len = param->len;
1221
1222 buf = wmi_buf_alloc(wmi_handle,
1223 (chunk_len + sizeof(segHdrInfo) +
1224 WMI_TLV_HDR_SIZE));
1225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301226 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301227 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301228 }
1229
1230 cmd = (uint8_t *) wmi_buf_data(buf);
1231
1232 segHdrInfo.len = total_bytes;
1233 segHdrInfo.msgref = msgref;
1234 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1235 segHdrInfo.segmentInfo = segInfo;
1236 segHdrInfo.pad = 0;
1237
Govind Singhb53420c2016-03-09 14:32:57 +05301238 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301239 " segHdrInfo.segmentInfo = %d",
1240 __func__, segHdrInfo.len, segHdrInfo.msgref,
1241 segHdrInfo.segmentInfo);
1242
Govind Singhb53420c2016-03-09 14:32:57 +05301243 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301244 "chunk len %d", __func__, total_bytes, segNumber,
1245 numSegments, chunk_len);
1246
1247 segNumber++;
1248
1249 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1250 (chunk_len + sizeof(segHdrInfo)));
1251 cmd += WMI_TLV_HDR_SIZE;
1252 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1253 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1254
1255 ret = wmi_unified_cmd_send(wmi_handle, buf,
1256 (chunk_len + sizeof(segHdrInfo) +
1257 WMI_TLV_HDR_SIZE),
1258 WMI_PDEV_UTF_CMDID);
1259
Govind Singh67922e82016-04-01 16:48:57 +05301260 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301261 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301262 wmi_buf_free(buf);
1263 break;
1264 }
1265
1266 param->len -= chunk_len;
1267 bufpos += chunk_len;
1268 }
1269
1270 msgref++;
1271
1272 return ret;
1273}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301274#ifdef CONFIG_MCL
1275static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1276 uint32_t host_param)
1277{
1278 return host_param;
1279}
1280#else
1281static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1282 uint32_t host_param)
1283{
1284 if (host_param < wmi_pdev_param_max)
1285 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301286
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301287 return WMI_UNAVAILABLE_PARAM;
1288}
1289#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301290/**
1291 * send_pdev_param_cmd_tlv() - set pdev parameters
1292 * @wmi_handle: wmi handle
1293 * @param: pointer to pdev parameter
1294 * @mac_id: radio context
1295 *
1296 * Return: 0 on success, errno on failure
1297 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301298static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301299send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1300 struct pdev_params *param,
1301 uint8_t mac_id)
1302{
Govind Singh67922e82016-04-01 16:48:57 +05301303 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301304 wmi_pdev_set_param_cmd_fixed_param *cmd;
1305 wmi_buf_t buf;
1306 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301307 uint32_t pdev_param;
1308
1309 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1310 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1311 WMI_LOGW("%s: Unavailable param %d\n",
1312 __func__, param->param_id);
1313 return QDF_STATUS_E_INVAL;
1314 }
Govind Singh5eb51532016-03-09 11:34:12 +05301315
1316 buf = wmi_buf_alloc(wmi_handle, len);
1317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301318 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301319 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301320 }
1321 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1322 WMITLV_SET_HDR(&cmd->tlv_header,
1323 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1324 WMITLV_GET_STRUCT_TLVLEN
1325 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301326 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301327 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301328 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301329 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301330 param->param_value);
1331 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1332 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301333 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301334 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301335 wmi_buf_free(buf);
1336 }
1337 return ret;
1338}
1339
1340/**
1341 * send_suspend_cmd_tlv() - WMI suspend function
1342 * @param wmi_handle : handle to WMI.
1343 * @param param : pointer to hold suspend parameter
1344 * @mac_id: radio context
1345 *
1346 * Return 0 on success and -ve on failure.
1347 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301348static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301349 struct suspend_params *param,
1350 uint8_t mac_id)
1351{
1352 wmi_pdev_suspend_cmd_fixed_param *cmd;
1353 wmi_buf_t wmibuf;
1354 uint32_t len = sizeof(*cmd);
1355 int32_t ret;
1356
1357 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001358 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301359 * PCIE reset so as to ensure that Host and target
1360 * states are in sync
1361 */
1362 wmibuf = wmi_buf_alloc(wmi_handle, len);
1363 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301364 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301365
1366 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1367 WMITLV_SET_HDR(&cmd->tlv_header,
1368 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1369 WMITLV_GET_STRUCT_TLVLEN
1370 (wmi_pdev_suspend_cmd_fixed_param));
1371 if (param->disable_target_intr)
1372 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1373 else
1374 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301375
1376 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1377
Govind Singh5eb51532016-03-09 11:34:12 +05301378 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1379 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301380 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301381 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301382 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301383 }
1384
1385 return ret;
1386}
1387
1388/**
1389 * send_resume_cmd_tlv() - WMI resume function
1390 * @param wmi_handle : handle to WMI.
1391 * @mac_id: radio context
1392 *
1393 * Return: 0 on success and -ve on failure.
1394 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301395static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301396 uint8_t mac_id)
1397{
1398 wmi_buf_t wmibuf;
1399 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301400 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301401
1402 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1403 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301404 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301405 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1406 WMITLV_SET_HDR(&cmd->tlv_header,
1407 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1408 WMITLV_GET_STRUCT_TLVLEN
1409 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301410 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301411 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1412 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301413 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301414 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301415 wmi_buf_free(wmibuf);
1416 }
1417
1418 return ret;
1419}
1420
Will Huang422ac9a2017-11-17 13:19:16 +08001421#ifdef FEATURE_WLAN_D0WOW
1422/**
1423 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1424 * @param wmi_handle: handle to WMI.
1425 * @mac_id: radio context
1426 *
1427 * Return: 0 on success and error code on failure.
1428 */
1429static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1430 uint8_t mac_id)
1431{
1432 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1433 wmi_buf_t buf;
1434 int32_t len;
1435 QDF_STATUS status;
1436
1437 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1438
1439 buf = wmi_buf_alloc(wmi_handle, len);
1440 if (!buf) {
1441 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1442 return QDF_STATUS_E_NOMEM;
1443 }
1444 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1445 WMITLV_SET_HDR(&cmd->tlv_header,
1446 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1447 WMITLV_GET_STRUCT_TLVLEN
1448 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1449
1450 cmd->enable = true;
1451
1452 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1453 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1454 if (QDF_IS_STATUS_ERROR(status))
1455 wmi_buf_free(buf);
1456
1457 return status;
1458}
1459
1460/**
1461 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1462 * @param wmi_handle: handle to WMI.
1463 * @mac_id: radio context
1464 *
1465 * Return: 0 on success and error code on failure.
1466 */
1467static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1468 uint8_t mac_id)
1469{
1470 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1471 wmi_buf_t buf;
1472 int32_t len;
1473 QDF_STATUS status;
1474
1475 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1476
1477 buf = wmi_buf_alloc(wmi_handle, len);
1478 if (!buf) {
1479 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1480 return QDF_STATUS_E_NOMEM;
1481 }
1482 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1483 WMITLV_SET_HDR(&cmd->tlv_header,
1484 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1485 WMITLV_GET_STRUCT_TLVLEN
1486 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1487
1488 cmd->enable = false;
1489
1490 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1491 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1492 if (QDF_IS_STATUS_ERROR(status))
1493 wmi_buf_free(buf);
1494
1495 return status;
1496}
1497#endif
1498
Govind Singh5eb51532016-03-09 11:34:12 +05301499/**
1500 * send_wow_enable_cmd_tlv() - WMI wow enable function
1501 * @param wmi_handle : handle to WMI.
1502 * @param param : pointer to hold wow enable parameter
1503 * @mac_id: radio context
1504 *
1505 * Return: 0 on success and -ve on failure.
1506 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301507static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301508 struct wow_cmd_params *param,
1509 uint8_t mac_id)
1510{
1511 wmi_wow_enable_cmd_fixed_param *cmd;
1512 wmi_buf_t buf;
1513 int32_t len;
1514 int32_t ret;
1515
1516 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1517
1518 buf = wmi_buf_alloc(wmi_handle, len);
1519 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301520 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1521 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301522 }
1523 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1524 WMITLV_SET_HDR(&cmd->tlv_header,
1525 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1526 WMITLV_GET_STRUCT_TLVLEN
1527 (wmi_wow_enable_cmd_fixed_param));
1528 cmd->enable = param->enable;
1529 if (param->can_suspend_link)
1530 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1531 else
1532 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001533 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301534
Govind Singhb53420c2016-03-09 14:32:57 +05301535 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301536 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1537 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1538
1539 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1540 WMI_WOW_ENABLE_CMDID);
1541 if (ret)
1542 wmi_buf_free(buf);
1543
1544 return ret;
1545}
1546
1547/**
1548 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301549 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301550 * @peer_addr: peer mac address
1551 * @param: pointer to ap_ps parameter structure
1552 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301553 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301554 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301555static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301556 uint8_t *peer_addr,
1557 struct ap_ps_params *param)
1558{
1559 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1560 wmi_buf_t buf;
1561 int32_t err;
1562
1563 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1564 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301565 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301566 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301567 }
1568 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1569 WMITLV_SET_HDR(&cmd->tlv_header,
1570 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1571 WMITLV_GET_STRUCT_TLVLEN
1572 (wmi_ap_ps_peer_cmd_fixed_param));
1573 cmd->vdev_id = param->vdev_id;
1574 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1575 cmd->param = param->param;
1576 cmd->value = param->value;
1577 err = wmi_unified_cmd_send(wmi_handle, buf,
1578 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1579 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301580 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301581 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301582 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301583 }
1584
1585 return 0;
1586}
1587
1588/**
1589 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301590 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301591 * @peer_addr: peer mac address
1592 * @param: pointer to sta_ps parameter structure
1593 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301594 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301595 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301596static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301597 struct sta_ps_params *param)
1598{
1599 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1600 wmi_buf_t buf;
1601 int32_t len = sizeof(*cmd);
1602
1603 buf = wmi_buf_alloc(wmi_handle, len);
1604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301605 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301606 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301607 }
1608
1609 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1610 WMITLV_SET_HDR(&cmd->tlv_header,
1611 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1612 WMITLV_GET_STRUCT_TLVLEN
1613 (wmi_sta_powersave_param_cmd_fixed_param));
1614 cmd->vdev_id = param->vdev_id;
1615 cmd->param = param->param;
1616 cmd->value = param->value;
1617
1618 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1619 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301620 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301621 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301622 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301623 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301624 }
1625
1626 return 0;
1627}
1628
1629/**
1630 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301631 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001632 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301633 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301634 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301635 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301636static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301637 struct crash_inject *param)
1638{
1639 int32_t ret = 0;
1640 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1641 uint16_t len = sizeof(*cmd);
1642 wmi_buf_t buf;
1643
1644 buf = wmi_buf_alloc(wmi_handle, len);
1645 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301646 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301647 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301648 }
1649
1650 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1651 WMITLV_SET_HDR(&cmd->tlv_header,
1652 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1653 WMITLV_GET_STRUCT_TLVLEN
1654 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1655 cmd->type = param->type;
1656 cmd->delay_time_ms = param->delay_time_ms;
1657
1658 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1659 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301660 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301661 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301662 __func__, ret);
1663 wmi_buf_free(buf);
1664 }
1665
1666 return ret;
1667}
1668
Wen Gongca174012018-04-20 16:56:28 +08001669#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301670/**
1671 * send_dbglog_cmd_tlv() - set debug log level
1672 * @param wmi_handle : handle to WMI.
1673 * @param param : pointer to hold dbglog level parameter
1674 *
1675 * Return: 0 on success and -ve on failure.
1676 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301677 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301678send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1679 struct dbglog_params *dbglog_param)
1680{
1681 wmi_buf_t buf;
1682 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001683 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301684 int32_t i;
1685 int32_t len;
1686 int8_t *buf_ptr;
1687 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1688
Alok Kumar240afea2017-08-30 14:45:34 +05301689 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301690
1691 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1692 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1693 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1694 buf = wmi_buf_alloc(wmi_handle, len);
1695 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001696 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301697
1698 configmsg =
1699 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1700 buf_ptr = (int8_t *) configmsg;
1701 WMITLV_SET_HDR(&configmsg->tlv_header,
1702 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1703 WMITLV_GET_STRUCT_TLVLEN
1704 (wmi_debug_log_config_cmd_fixed_param));
1705 configmsg->dbg_log_param = dbglog_param->param;
1706 configmsg->value = dbglog_param->val;
1707 /* Filling in the data part of second tlv -- should
1708 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301709 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301710 sizeof
1711 (wmi_debug_log_config_cmd_fixed_param)
1712 + WMI_TLV_HDR_SIZE);
1713 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1714 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301715 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301716 if (dbglog_param->module_id_bitmap) {
1717 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1718 module_id_bitmap_array[i] =
1719 dbglog_param->module_id_bitmap[i];
1720 }
1721 }
1722
1723 status = wmi_unified_cmd_send(wmi_handle, buf,
1724 len, WMI_DBGLOG_CFG_CMDID);
1725
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001726 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301727 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301728
1729 return status;
1730}
Wen Gongca174012018-04-20 16:56:28 +08001731#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301732
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301733#ifdef CONFIG_MCL
1734static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1735 uint32_t host_param)
1736{
1737 return host_param;
1738}
1739#else
1740static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1741 uint32_t host_param)
1742{
1743 if (host_param < wmi_vdev_param_max)
1744 return wmi_handle->vdev_param[host_param];
1745
1746 return WMI_UNAVAILABLE_PARAM;
1747}
1748#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301749/**
1750 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1751 * @param wmi_handle : handle to WMI.
1752 * @param macaddr : MAC address
1753 * @param param : pointer to hold vdev set parameter
1754 *
1755 * Return: 0 on success and -ve on failure.
1756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301757static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301758 struct vdev_set_params *param)
1759{
Govind Singh67922e82016-04-01 16:48:57 +05301760 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301761 wmi_vdev_set_param_cmd_fixed_param *cmd;
1762 wmi_buf_t buf;
1763 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301764 uint32_t vdev_param;
1765
1766 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1767 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1768 WMI_LOGW("%s:Vdev param %d not available", __func__,
1769 param->param_id);
1770 return QDF_STATUS_E_INVAL;
1771
1772 }
Govind Singh5eb51532016-03-09 11:34:12 +05301773
1774 buf = wmi_buf_alloc(wmi_handle, len);
1775 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301776 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301777 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301778 }
1779 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1780 WMITLV_SET_HDR(&cmd->tlv_header,
1781 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1782 WMITLV_GET_STRUCT_TLVLEN
1783 (wmi_vdev_set_param_cmd_fixed_param));
1784 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301785 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301786 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301787 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001788 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301789 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1790 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301791 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301792 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301793 wmi_buf_free(buf);
1794 }
1795
1796 return ret;
1797}
1798
1799/**
1800 * send_stats_request_cmd_tlv() - WMI request stats function
1801 * @param wmi_handle : handle to WMI.
1802 * @param macaddr : MAC address
1803 * @param param : pointer to hold stats request parameter
1804 *
1805 * Return: 0 on success and -ve on failure.
1806 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301807static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301808 uint8_t macaddr[IEEE80211_ADDR_LEN],
1809 struct stats_request_params *param)
1810{
Govind Singhd3156eb2016-02-26 17:50:39 +05301811 int32_t ret;
1812 wmi_request_stats_cmd_fixed_param *cmd;
1813 wmi_buf_t buf;
1814 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1815
1816 buf = wmi_buf_alloc(wmi_handle, len);
1817 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301818 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1819 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301820 }
1821
1822 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1823 WMITLV_SET_HDR(&cmd->tlv_header,
1824 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1825 WMITLV_GET_STRUCT_TLVLEN
1826 (wmi_request_stats_cmd_fixed_param));
1827 cmd->stats_id = param->stats_id;
1828 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301829 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1830 param->pdev_id);
1831 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001832
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301833 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1834 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001835
1836 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1837 WMI_REQUEST_STATS_CMDID);
1838
Govind Singhd3156eb2016-02-26 17:50:39 +05301839 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301840 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301841 wmi_buf_free(buf);
1842 }
1843
1844 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301845}
1846
Govind Singh87542482016-06-08 19:40:11 +05301847#ifdef CONFIG_WIN
1848/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001849 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301850 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001851 * @param PKTLOG_EVENT : packet log event
1852 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301853 *
1854 * Return: 0 on success and -ve on failure.
1855 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301856static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001857 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301858{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001859 int32_t ret;
1860 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1861 wmi_buf_t buf;
1862 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1863
1864 buf = wmi_buf_alloc(wmi_handle, len);
1865 if (!buf) {
1866 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1867 return -QDF_STATUS_E_NOMEM;
1868 }
1869
1870 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1871 WMITLV_SET_HDR(&cmd->tlv_header,
1872 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1873 WMITLV_GET_STRUCT_TLVLEN
1874 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1875 cmd->evlist = PKTLOG_EVENT;
1876 cmd->pdev_id = mac_id;
1877 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1878 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1879 if (ret) {
1880 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1881 wmi_buf_free(buf);
1882 }
1883
1884 return ret;
1885}
1886
1887/**
1888 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1889 * @param wmi_handle : handle to WMI.
1890 * @mac_id: mac id to have radio context
1891 *
1892 * Return: 0 on success and -ve on failure.
1893 */
1894static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001895 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001896{
1897 int32_t ret;
1898 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1899 wmi_buf_t buf;
1900 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1901
1902 buf = wmi_buf_alloc(wmi_handle, len);
1903 if (!buf) {
1904 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1905 return -QDF_STATUS_E_NOMEM;
1906 }
1907
1908 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1909 WMITLV_SET_HDR(&cmd->tlv_header,
1910 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1911 WMITLV_GET_STRUCT_TLVLEN
1912 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1913 cmd->pdev_id = mac_id;
1914 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1915 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1916 if (ret) {
1917 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1918 wmi_buf_free(buf);
1919 }
1920
1921 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301922}
1923#else
Govind Singh5eb51532016-03-09 11:34:12 +05301924/**
Keyur Parekhde522342017-08-18 14:01:05 -07001925 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1926 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301927 * @param wmi_handle : handle to WMI.
1928 * @param macaddr : MAC address
1929 * @param param : pointer to hold stats request parameter
1930 *
1931 * Return: 0 on success and -ve on failure.
1932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301933static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301934 uint8_t macaddr[IEEE80211_ADDR_LEN],
1935 struct packet_enable_params *param)
1936{
1937 return 0;
1938}
Keyur Parekhde522342017-08-18 14:01:05 -07001939/**
1940 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1941 * packet-log
1942 * @param wmi_handle : handle to WMI.
1943 * @mac_id: mac id to have radio context
1944 *
1945 * Return: 0 on success and -ve on failure.
1946 */
1947static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1948 uint8_t mac_id)
1949{
1950 return 0;
1951}
Govind Singh87542482016-06-08 19:40:11 +05301952#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301953
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301954#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1955/**
1956 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1957 * sync time between bwtween host and firmware
1958 * @param wmi_handle : handle to WMI.
1959 *
1960 * Return: None
1961 */
1962static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1963{
1964 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001965 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301966 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1967 int32_t len;
1968 qdf_time_t time_ms;
1969
1970 len = sizeof(*time_stamp);
1971 buf = wmi_buf_alloc(wmi_handle, len);
1972
1973 if (!buf) {
1974 WMI_LOGP(FL("wmi_buf_alloc failed"));
1975 return;
1976 }
1977 time_stamp =
1978 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1979 (wmi_buf_data(buf));
1980 WMITLV_SET_HDR(&time_stamp->tlv_header,
1981 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1982 WMITLV_GET_STRUCT_TLVLEN(
1983 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1984
1985 time_ms = qdf_get_time_of_the_day_ms();
1986 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1987 time_stamp->time_stamp_low = time_ms &
1988 WMI_FW_TIME_STAMP_LOW_MASK;
1989 /*
1990 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1991 * wont exceed 27 bit
1992 */
1993 time_stamp->time_stamp_high = 0;
1994 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1995 time_stamp->mode, time_stamp->time_stamp_low,
1996 time_stamp->time_stamp_high);
1997
1998 status = wmi_unified_cmd_send(wmi_handle, buf,
1999 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
2000 if (status) {
2001 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
2002 wmi_buf_free(buf);
2003 }
2004
2005}
2006
Subrat Mishrad7c7a562017-09-27 14:41:20 +05302007#ifdef WLAN_SUPPORT_FILS
2008/**
2009 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
2010 * @wmi_handle: wmi handle
2011 * @evt_buf: pointer to event buffer
2012 * @vdev_id: pointer to hold vdev id
2013 *
2014 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
2015 */
2016static QDF_STATUS
2017extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
2018 void *evt_buf, uint32_t *vdev_id)
2019{
2020 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
2021 wmi_host_swfda_event_fixed_param *swfda_event;
2022
2023 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
2024 if (!param_buf) {
2025 WMI_LOGE("Invalid swfda event buffer");
2026 return QDF_STATUS_E_INVAL;
2027 }
2028 swfda_event = param_buf->fixed_param;
2029 *vdev_id = swfda_event->vdev_id;
2030
2031 return QDF_STATUS_SUCCESS;
2032}
2033
2034/**
2035 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
2036 * @wmi_handle: wmi handle
2037 * @param: pointer to hold FILS discovery enable param
2038 *
2039 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
2040 */
2041static QDF_STATUS
2042send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
2043 struct config_fils_params *param)
2044{
2045 wmi_enable_fils_cmd_fixed_param *cmd;
2046 wmi_buf_t buf;
2047 QDF_STATUS status;
2048 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
2049
2050 buf = wmi_buf_alloc(wmi_handle, len);
2051 if (!buf) {
2052 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2053 return QDF_STATUS_E_NOMEM;
2054 }
2055 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
2056 WMITLV_SET_HDR(&cmd->tlv_header,
2057 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
2058 WMITLV_GET_STRUCT_TLVLEN(
2059 wmi_enable_fils_cmd_fixed_param));
2060 cmd->vdev_id = param->vdev_id;
2061 cmd->fd_period = param->fd_period;
2062 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
2063 param->fd_period, param->vdev_id);
2064
2065 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2066 WMI_ENABLE_FILS_CMDID);
2067 if (status != QDF_STATUS_SUCCESS) {
2068 wmi_buf_free(buf);
2069 return QDF_STATUS_E_FAILURE;
2070 }
2071
2072 return QDF_STATUS_SUCCESS;
2073}
2074
2075/**
2076 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
2077 * @wmi_handle: wmi handle
2078 * @param: pointer to hold FD send cmd parameter
2079 *
2080 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
2081 */
2082static QDF_STATUS
2083send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
2084 struct fd_params *param)
2085{
2086 QDF_STATUS ret;
2087 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2088 wmi_buf_t wmi_buf;
2089 qdf_dma_addr_t dma_addr;
2090
2091 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2092 if (!wmi_buf) {
2093 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2094 return QDF_STATUS_E_NOMEM;
2095 }
2096 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2097 WMITLV_SET_HDR(&cmd->tlv_header,
2098 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2099 WMITLV_GET_STRUCT_TLVLEN(
2100 wmi_fd_send_from_host_cmd_fixed_param));
2101 cmd->vdev_id = param->vdev_id;
2102 cmd->data_len = qdf_nbuf_len(param->wbuf);
2103 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2104 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2105 cmd->frame_ctrl = param->frame_ctrl;
2106
2107 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2108 WMI_PDEV_SEND_FD_CMDID);
2109 if (ret != QDF_STATUS_SUCCESS) {
2110 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2111 __func__, ret);
2112 wmi_buf_free(wmi_buf);
2113 }
2114
2115 return ret;
2116}
2117#endif /* WLAN_SUPPORT_FILS */
2118
Sathish Kumarfd347372017-02-13 12:29:09 +05302119static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302120 struct beacon_params *param)
2121{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302122 QDF_STATUS ret;
2123 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2124 wmi_buf_t wmi_buf;
2125 qdf_dma_addr_t dma_addr;
2126 uint32_t dtim_flag = 0;
2127
2128 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2129 if (!wmi_buf) {
2130 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2131 return QDF_STATUS_E_NOMEM;
2132 }
2133 if (param->is_dtim_count_zero) {
2134 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2135 if (param->is_bitctl_reqd) {
2136 /* deliver CAB traffic in next DTIM beacon */
2137 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2138 }
2139 }
2140 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2141 WMITLV_SET_HDR(&cmd->tlv_header,
2142 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2143 WMITLV_GET_STRUCT_TLVLEN
2144 (wmi_bcn_send_from_host_cmd_fixed_param));
2145 cmd->vdev_id = param->vdev_id;
2146 cmd->data_len = qdf_nbuf_len(param->wbuf);
2147 cmd->frame_ctrl = param->frame_ctrl;
2148 cmd->dtim_flag = dtim_flag;
2149 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2150 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2151#if defined(HTT_PADDR64)
2152 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2153#endif
2154 cmd->bcn_antenna = param->bcn_txant;
2155
2156 ret = wmi_unified_cmd_send(wmi_handle,
2157 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2158 if (ret != QDF_STATUS_SUCCESS) {
2159 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2160 wmi_buf_free(wmi_buf);
2161 }
2162
2163 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302164}
2165
2166/**
2167 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2168 * @param wmi_handle : handle to WMI.
2169 * @param param : pointer to hold beacon send cmd parameter
2170 *
2171 * Return: 0 on success and -ve on failure.
2172 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302173static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302174 struct beacon_tmpl_params *param)
2175{
2176 int32_t ret;
2177 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2178 wmi_bcn_prb_info *bcn_prb_info;
2179 wmi_buf_t wmi_buf;
2180 uint8_t *buf_ptr;
2181 uint32_t wmi_buf_len;
2182
2183 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2184 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2185 param->tmpl_len_aligned;
2186 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2187 if (!wmi_buf) {
2188 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2189 return QDF_STATUS_E_NOMEM;
2190 }
2191 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2192 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2193 WMITLV_SET_HDR(&cmd->tlv_header,
2194 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2195 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2196 cmd->vdev_id = param->vdev_id;
2197 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302198 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2199 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Subrat Mishraa667b1c2018-08-02 15:02:04 +05302200 cmd->esp_ie_offset = param->esp_ie_offset;
Govind Singh87542482016-06-08 19:40:11 +05302201 cmd->buf_len = param->tmpl_len;
2202 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2203
2204 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2205 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2206 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2207 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2208 bcn_prb_info->caps = 0;
2209 bcn_prb_info->erp = 0;
2210 buf_ptr += sizeof(wmi_bcn_prb_info);
2211
2212 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2213 buf_ptr += WMI_TLV_HDR_SIZE;
2214 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2215
2216 ret = wmi_unified_cmd_send(wmi_handle,
2217 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2218 if (ret) {
2219 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2220 wmi_buf_free(wmi_buf);
2221 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302222
Govind Singh87542482016-06-08 19:40:11 +05302223 return 0;
2224}
Govind Singh5eb51532016-03-09 11:34:12 +05302225
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302226#ifdef CONFIG_MCL
2227static inline void copy_peer_flags_tlv(
2228 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2229 struct peer_assoc_params *param)
2230{
2231 cmd->peer_flags = param->peer_flags;
2232}
2233#else
2234static inline void copy_peer_flags_tlv(
2235 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2236 struct peer_assoc_params *param)
2237{
2238 /*
2239 * The target only needs a subset of the flags maintained in the host.
2240 * Just populate those flags and send it down
2241 */
2242 cmd->peer_flags = 0;
2243
2244 /*
2245 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2246 */
2247 if (param->is_wme_set) {
2248
2249 if (param->qos_flag)
2250 cmd->peer_flags |= WMI_PEER_QOS;
2251 if (param->apsd_flag)
2252 cmd->peer_flags |= WMI_PEER_APSD;
2253 if (param->ht_flag)
2254 cmd->peer_flags |= WMI_PEER_HT;
2255 if (param->bw_40)
2256 cmd->peer_flags |= WMI_PEER_40MHZ;
2257 if (param->bw_80)
2258 cmd->peer_flags |= WMI_PEER_80MHZ;
2259 if (param->bw_160)
2260 cmd->peer_flags |= WMI_PEER_160MHZ;
2261
2262 /* Typically if STBC is enabled for VHT it should be enabled
2263 * for HT as well
2264 **/
2265 if (param->stbc_flag)
2266 cmd->peer_flags |= WMI_PEER_STBC;
2267
2268 /* Typically if LDPC is enabled for VHT it should be enabled
2269 * for HT as well
2270 **/
2271 if (param->ldpc_flag)
2272 cmd->peer_flags |= WMI_PEER_LDPC;
2273
2274 if (param->static_mimops_flag)
2275 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2276 if (param->dynamic_mimops_flag)
2277 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2278 if (param->spatial_mux_flag)
2279 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2280 if (param->vht_flag)
2281 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002282 if (param->he_flag)
2283 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302284 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002285
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302286 if (param->is_pmf_enabled)
2287 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302288 /*
2289 * Suppress authorization for all AUTH modes that need 4-way handshake
2290 * (during re-association).
2291 * Authorization will be done for these modes on key installation.
2292 */
2293 if (param->auth_flag)
2294 cmd->peer_flags |= WMI_PEER_AUTH;
2295 if (param->need_ptk_4_way)
2296 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2297 else
2298 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2299 if (param->need_gtk_2_way)
2300 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2301 /* safe mode bypass the 4-way handshake */
2302 if (param->safe_mode_enabled)
2303 cmd->peer_flags &=
2304 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2305 /* Disable AMSDU for station transmit, if user configures it */
2306 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2307 * it
2308 * if (param->amsdu_disable) Add after FW support
2309 **/
2310
2311 /* Target asserts if node is marked HT and all MCS is set to 0.
2312 * Mark the node as non-HT if all the mcs rates are disabled through
2313 * iwpriv
2314 **/
2315 if (param->peer_ht_rates.num_rates == 0)
2316 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302317
2318 if (param->twt_requester)
2319 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2320
2321 if (param->twt_responder)
2322 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302323}
2324#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302325
2326#ifdef CONFIG_MCL
2327static inline void copy_peer_mac_addr_tlv(
2328 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2329 struct peer_assoc_params *param)
2330{
2331 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2332 sizeof(param->peer_macaddr));
2333}
2334#else
2335static inline void copy_peer_mac_addr_tlv(
2336 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2337 struct peer_assoc_params *param)
2338{
2339 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2340}
2341#endif
2342
Govind Singh5eb51532016-03-09 11:34:12 +05302343/**
2344 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2345 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302346 * @param param : pointer to peer assoc parameter
2347 *
2348 * Return: 0 on success and -ve on failure.
2349 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302350static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302351 struct peer_assoc_params *param)
2352{
Govind Singhd3156eb2016-02-26 17:50:39 +05302353 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2354 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002355 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302356 wmi_buf_t buf;
2357 int32_t len;
2358 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302359 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302360 uint32_t peer_legacy_rates_align;
2361 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002362 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302363
2364
2365 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2366 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302367
2368 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002369 (peer_legacy_rates_align * sizeof(uint8_t)) +
2370 WMI_TLV_HDR_SIZE +
2371 (peer_ht_rates_align * sizeof(uint8_t)) +
2372 sizeof(wmi_vht_rate_set) +
2373 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2374 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302375
2376 buf = wmi_buf_alloc(wmi_handle, len);
2377 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302378 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302379 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 }
2381
2382 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2383 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2384 WMITLV_SET_HDR(&cmd->tlv_header,
2385 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2386 WMITLV_GET_STRUCT_TLVLEN
2387 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302388
Govind Singhd3156eb2016-02-26 17:50:39 +05302389 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302390
Govind Singhd3156eb2016-02-26 17:50:39 +05302391 cmd->peer_new_assoc = param->peer_new_assoc;
2392 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302393
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302394 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302395 copy_peer_mac_addr_tlv(cmd, param);
2396
Govind Singhd3156eb2016-02-26 17:50:39 +05302397 cmd->peer_rate_caps = param->peer_rate_caps;
2398 cmd->peer_caps = param->peer_caps;
2399 cmd->peer_listen_intval = param->peer_listen_intval;
2400 cmd->peer_ht_caps = param->peer_ht_caps;
2401 cmd->peer_max_mpdu = param->peer_max_mpdu;
2402 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302403 cmd->peer_vht_caps = param->peer_vht_caps;
2404 cmd->peer_phymode = param->peer_phymode;
2405
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002406 /* Update 11ax capabilities */
2407 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2408 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002409 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2410 sizeof(param->peer_he_cap_phyinfo));
2411 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2412 sizeof(param->peer_ppet));
2413
Govind Singhd3156eb2016-02-26 17:50:39 +05302414 /* Update peer legacy rate information */
2415 buf_ptr += sizeof(*cmd);
2416 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302417 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302418 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302419 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302420 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302421 param->peer_legacy_rates.num_rates);
2422
2423 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002424 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302425 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302426 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302427 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302428 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302429 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302430 param->peer_ht_rates.num_rates);
2431
2432 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002433 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2435 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2436
2437 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302438
2439 /* Update bandwidth-NSS mapping */
2440 cmd->peer_bw_rxnss_override = 0;
2441 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2442
Govind Singhd3156eb2016-02-26 17:50:39 +05302443 mcs = (wmi_vht_rate_set *) buf_ptr;
2444 if (param->vht_capable) {
2445 mcs->rx_max_rate = param->rx_max_rate;
2446 mcs->rx_mcs_set = param->rx_mcs_set;
2447 mcs->tx_max_rate = param->tx_max_rate;
2448 mcs->tx_mcs_set = param->tx_mcs_set;
2449 }
2450
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002451 /* HE Rates */
2452 cmd->peer_he_mcs = param->peer_he_mcs_count;
2453 buf_ptr += sizeof(wmi_vht_rate_set);
2454 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2455 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2456 buf_ptr += WMI_TLV_HDR_SIZE;
2457
2458 /* Loop through the HE rate set */
2459 for (i = 0; i < param->peer_he_mcs_count; i++) {
2460 he_mcs = (wmi_he_rate_set *) buf_ptr;
2461 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2462 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2463
2464 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2465 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2466 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2467 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2468 buf_ptr += sizeof(wmi_he_rate_set);
2469 }
2470
2471
Govind Singhb53420c2016-03-09 14:32:57 +05302472 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302473 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2474 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002475 "cmd->peer_vht_caps %x "
2476 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302477 "HE phy %x %x %x "
2478 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302479 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2480 cmd->peer_rate_caps, cmd->peer_caps,
2481 cmd->peer_listen_intval, cmd->peer_ht_caps,
2482 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2483 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002484 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2485 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302486 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2487 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302488
2489 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2490 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302491 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302492 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302493 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302494 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302495 }
2496
2497 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302498}
2499
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302500/* copy_scan_notify_events() - Helper routine to copy scan notify events
2501 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302502static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302503 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302504 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302505{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302506
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302507 /* Scan events subscription */
2508 if (param->scan_ev_started)
2509 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2510 if (param->scan_ev_completed)
2511 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2512 if (param->scan_ev_bss_chan)
2513 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2514 if (param->scan_ev_foreign_chan)
2515 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2516 if (param->scan_ev_dequeued)
2517 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2518 if (param->scan_ev_preempted)
2519 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2520 if (param->scan_ev_start_failed)
2521 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2522 if (param->scan_ev_restarted)
2523 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2524 if (param->scan_ev_foreign_chn_exit)
2525 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2526 if (param->scan_ev_suspended)
2527 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2528 if (param->scan_ev_resumed)
2529 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302530
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302531 /** Set scan control flags */
2532 cmd->scan_ctrl_flags = 0;
2533 if (param->scan_f_passive)
2534 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2535 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302536 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302537 if (param->scan_f_promisc_mode)
2538 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2539 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302540 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302541 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302542 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302543 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302544 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302545 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302546 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302547 if (param->scan_f_ofdm_rates)
2548 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2549 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302550 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302551 if (param->scan_f_filter_prb_req)
2552 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2553 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302554 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302555 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302556 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302557 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302558 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302559 if (param->scan_f_force_active_dfs_chn)
2560 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2561 if (param->scan_f_add_tpc_ie_in_probe)
2562 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2563 if (param->scan_f_add_ds_ie_in_probe)
2564 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2565 if (param->scan_f_add_spoofed_mac_in_probe)
2566 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2567 if (param->scan_f_add_rand_seq_in_probe)
2568 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2569 if (param->scan_f_en_ie_whitelist_in_probe)
2570 cmd->scan_ctrl_flags |=
2571 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302572
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302573 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2574 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2575 param->adaptive_dwell_time_mode);
2576}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302577
2578/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302579static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302580 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302581{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302582 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302583}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302584
Govind Singh5eb51532016-03-09 11:34:12 +05302585/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302586 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2587 * @mac: random mac addr
2588 * @mask: random mac mask
2589 * @mac_addr: wmi random mac
2590 * @mac_mask: wmi random mac mask
2591 *
2592 * Return None.
2593 */
2594static inline
2595void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2596 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2597{
2598 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2599 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2600}
2601
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302602/*
2603 * wmi_fill_vendor_oui() - fill vendor OUIs
2604 * @buf_ptr: pointer to wmi tlv buffer
2605 * @num_vendor_oui: number of vendor OUIs to be filled
2606 * @param_voui: pointer to OUI buffer
2607 *
2608 * This function populates the wmi tlv buffer when vendor specific OUIs are
2609 * present.
2610 *
2611 * Return: None
2612 */
2613static inline
2614void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2615 uint32_t *pvoui)
2616{
2617 wmi_vendor_oui *voui = NULL;
2618 uint32_t i;
2619
2620 voui = (wmi_vendor_oui *)buf_ptr;
2621
2622 for (i = 0; i < num_vendor_oui; i++) {
2623 WMITLV_SET_HDR(&voui[i].tlv_header,
2624 WMITLV_TAG_STRUC_wmi_vendor_oui,
2625 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2626 voui[i].oui_type_subtype = pvoui[i];
2627 }
2628}
2629
2630/*
2631 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2632 * @ie_bitmap: output pointer to ie bit map in cmd
2633 * @num_vendor_oui: output pointer to num vendor OUIs
2634 * @ie_whitelist: input parameter
2635 *
2636 * This function populates the IE whitelist attrs of scan, pno and
2637 * scan oui commands for ie_whitelist parameter.
2638 *
2639 * Return: None
2640 */
2641static inline
2642void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2643 uint32_t *num_vendor_oui,
2644 struct probe_req_whitelist_attr *ie_whitelist)
2645{
2646 uint32_t i = 0;
2647
2648 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2649 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2650
2651 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2652}
2653
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302654/**
Govind Singh5eb51532016-03-09 11:34:12 +05302655 * send_scan_start_cmd_tlv() - WMI scan start function
2656 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302657 * @param param : pointer to hold scan start cmd parameter
2658 *
2659 * Return: 0 on success and -ve on failure.
2660 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302661static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302662 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302663{
Govind Singhd3156eb2016-02-26 17:50:39 +05302664 int32_t ret = 0;
2665 int32_t i;
2666 wmi_buf_t wmi_buf;
2667 wmi_start_scan_cmd_fixed_param *cmd;
2668 uint8_t *buf_ptr;
2669 uint32_t *tmp_ptr;
2670 wmi_ssid *ssid = NULL;
2671 wmi_mac_addr *bssid;
2672 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302673 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302674 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302675 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302676
2677 /* Length TLV placeholder for array of uint32_t */
2678 len += WMI_TLV_HDR_SIZE;
2679 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302680 if (params->chan_list.num_chan)
2681 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302682
2683 /* Length TLV placeholder for array of wmi_ssid structures */
2684 len += WMI_TLV_HDR_SIZE;
2685 if (params->num_ssids)
2686 len += params->num_ssids * sizeof(wmi_ssid);
2687
2688 /* Length TLV placeholder for array of wmi_mac_addr structures */
2689 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302690 if (params->num_bssid)
2691 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302692
2693 /* Length TLV placeholder for array of bytes */
2694 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302695 if (params->extraie.len)
2696 extraie_len_with_pad =
2697 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002698 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302699
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302700 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2701 if (ie_whitelist->num_vendor_oui)
2702 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2703
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302704 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2705 if (params->scan_f_wide_band)
2706 phymode_roundup =
2707 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2708 sizeof(uint32_t));
2709 len += phymode_roundup;
2710
Govind Singhd3156eb2016-02-26 17:50:39 +05302711 /* Allocate the memory */
2712 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2713 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302714 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302715 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302716 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302717 }
2718 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2719 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2720 WMITLV_SET_HDR(&cmd->tlv_header,
2721 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2722 WMITLV_GET_STRUCT_TLVLEN
2723 (wmi_start_scan_cmd_fixed_param));
2724
2725 cmd->scan_id = params->scan_id;
2726 cmd->scan_req_id = params->scan_req_id;
2727 cmd->vdev_id = params->vdev_id;
2728 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302729
2730 copy_scan_event_cntrl_flags(cmd, params);
2731
Govind Singhd3156eb2016-02-26 17:50:39 +05302732 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002733 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302734 cmd->dwell_time_passive = params->dwell_time_passive;
2735 cmd->min_rest_time = params->min_rest_time;
2736 cmd->max_rest_time = params->max_rest_time;
2737 cmd->repeat_probe_time = params->repeat_probe_time;
2738 cmd->probe_spacing_time = params->probe_spacing_time;
2739 cmd->idle_time = params->idle_time;
2740 cmd->max_scan_time = params->max_scan_time;
2741 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302742 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302743 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302744 cmd->num_bssid = params->num_bssid;
2745 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302746 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302747 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302748 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2749
2750 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2751
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302752 if (params->scan_random.randomize)
2753 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2754 params->scan_random.mac_mask,
2755 &cmd->mac_addr,
2756 &cmd->mac_mask);
2757
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302758 if (ie_whitelist->white_list)
2759 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2760 &cmd->num_vendor_oui,
2761 ie_whitelist);
2762
Govind Singhd3156eb2016-02-26 17:50:39 +05302763 buf_ptr += sizeof(*cmd);
2764 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302765 for (i = 0; i < params->chan_list.num_chan; ++i)
2766 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302767
2768 WMITLV_SET_HDR(buf_ptr,
2769 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302770 (params->chan_list.num_chan * sizeof(uint32_t)));
2771 buf_ptr += WMI_TLV_HDR_SIZE +
2772 (params->chan_list.num_chan * sizeof(uint32_t));
2773
Govind Singh4eacd2b2016-03-07 14:24:22 +05302774 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302775 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302776 goto error;
2777 }
2778
2779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2780 (params->num_ssids * sizeof(wmi_ssid)));
2781
2782 if (params->num_ssids) {
2783 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2784 for (i = 0; i < params->num_ssids; ++i) {
2785 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302786 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302787 params->ssid[i].length);
2788 ssid++;
2789 }
2790 }
2791 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2792
2793 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2794 (params->num_bssid * sizeof(wmi_mac_addr)));
2795 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302796
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302797 if (params->num_bssid) {
2798 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302799 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2800 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302801 bssid++;
2802 }
2803 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302804
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302805 buf_ptr += WMI_TLV_HDR_SIZE +
2806 (params->num_bssid * sizeof(wmi_mac_addr));
2807
2808 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2809 if (params->extraie.len)
2810 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2811 params);
2812
2813 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302814
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302815 /* probe req ie whitelisting */
2816 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2817 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2818
2819 buf_ptr += WMI_TLV_HDR_SIZE;
2820
2821 if (cmd->num_vendor_oui) {
2822 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2823 ie_whitelist->voui);
2824 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2825 }
2826
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302827 /* Add phy mode TLV if it's a wide band scan */
2828 if (params->scan_f_wide_band) {
2829 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2830 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2831 for (i = 0; i < params->chan_list.num_chan; ++i)
2832 buf_ptr[i] =
2833 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2834 buf_ptr += phymode_roundup;
2835 } else {
2836 /* Add ZERO legth phy mode TLV */
2837 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2838 }
2839
Santosh Anbu1e11b472018-03-07 15:33:27 +05302840 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002841 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302842 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302843 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302844 wmi_buf_free(wmi_buf);
2845 }
2846 return ret;
2847error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302848 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302849 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302850}
2851
2852/**
2853 * send_scan_stop_cmd_tlv() - WMI scan start function
2854 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302855 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302856 *
2857 * Return: 0 on success and -ve on failure.
2858 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302859static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302860 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302861{
Govind Singhd3156eb2016-02-26 17:50:39 +05302862 wmi_stop_scan_cmd_fixed_param *cmd;
2863 int ret;
2864 int len = sizeof(*cmd);
2865 wmi_buf_t wmi_buf;
2866
2867 /* Allocate the memory */
2868 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2869 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302870 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302871 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302872 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302873 goto error;
2874 }
2875
2876 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2877 WMITLV_SET_HDR(&cmd->tlv_header,
2878 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2879 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2880 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302881 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302882 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302883 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2884 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302885 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302886 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2887 /* Cancelling all scans */
2888 cmd->req_type = WMI_SCAN_STOP_ALL;
2889 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2890 /* Cancelling VAP scans */
2891 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2892 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2893 /* Cancelling specific scan */
2894 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302895 } else {
2896 WMI_LOGE("%s: Invalid Command : ", __func__);
2897 wmi_buf_free(wmi_buf);
2898 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302899 }
2900
Santosh Anbu1e11b472018-03-07 15:33:27 +05302901 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002902 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302903 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302904 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302905 wmi_buf_free(wmi_buf);
2906 }
2907
2908error:
2909 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302910}
2911
Govind Singh87542482016-06-08 19:40:11 +05302912#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302913/**
2914 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2915 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302916 * @param param : pointer to hold scan channel list parameter
2917 *
2918 * Return: 0 on success and -ve on failure.
2919 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302920static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302921 struct scan_chan_list_params *chan_list)
2922{
2923 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302924 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302925 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302926 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302927 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302928 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302929 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2930
2931 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2932 buf = wmi_buf_alloc(wmi_handle, len);
2933 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302934 WMI_LOGE("Failed to allocate memory");
2935 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302936 goto end;
2937 }
2938
2939 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2940 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2941 WMITLV_SET_HDR(&cmd->tlv_header,
2942 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2943 WMITLV_GET_STRUCT_TLVLEN
2944 (wmi_scan_chan_list_cmd_fixed_param));
2945
Govind Singhb53420c2016-03-09 14:32:57 +05302946 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302947
2948 cmd->num_scan_chans = chan_list->num_scan_chans;
2949 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2950 WMITLV_TAG_ARRAY_STRUC,
2951 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302952 chan_info = (wmi_channel_param *)
2953 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302954 tchan_info = chan_list->chan_info;
2955
2956 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2957 WMITLV_SET_HDR(&chan_info->tlv_header,
2958 WMITLV_TAG_STRUC_wmi_channel,
2959 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2960 chan_info->mhz = tchan_info->mhz;
2961 chan_info->band_center_freq1 =
2962 tchan_info->band_center_freq1;
2963 chan_info->band_center_freq2 =
2964 tchan_info->band_center_freq2;
2965 chan_info->info = tchan_info->info;
2966 chan_info->reg_info_1 = tchan_info->reg_info_1;
2967 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302968 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302969
2970 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2971 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2972 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2973 tchan_info++;
2974 chan_info++;
2975 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302976 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2977 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302978
Anish Natarajdd855152017-03-20 12:49:08 +05302979 qdf_status = wmi_unified_cmd_send(wmi_handle,
2980 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302981
Govind Singh67922e82016-04-01 16:48:57 +05302982 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302983 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302984 wmi_buf_free(buf);
2985 }
Govind Singh67922e82016-04-01 16:48:57 +05302986
Govind Singhd3156eb2016-02-26 17:50:39 +05302987end:
Govind Singhb53420c2016-03-09 14:32:57 +05302988 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302989}
Govind Singh87542482016-06-08 19:40:11 +05302990#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302991static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302992 struct scan_chan_list_params *chan_list)
2993{
2994 wmi_buf_t buf;
2995 QDF_STATUS qdf_status;
2996 wmi_scan_chan_list_cmd_fixed_param *cmd;
2997 int i;
2998 uint8_t *buf_ptr;
2999 wmi_channel *chan_info;
3000 struct channel_param *tchan_info;
3001 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05303002
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303003 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303004 buf = wmi_buf_alloc(wmi_handle, len);
3005 if (!buf) {
3006 WMI_LOGE("Failed to allocate memory");
3007 qdf_status = QDF_STATUS_E_NOMEM;
3008 goto end;
3009 }
3010
3011 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3012 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
3013 WMITLV_SET_HDR(&cmd->tlv_header,
3014 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
3015 WMITLV_GET_STRUCT_TLVLEN
3016 (wmi_scan_chan_list_cmd_fixed_param));
3017
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303018 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05303019
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05303020 if (chan_list->append)
3021 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
3022
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303023 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3024 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303025 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303026 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
3027 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303028 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05303029 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
3030 tchan_info = &(chan_list->ch_param[0]);
3031
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303032 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05303033 WMITLV_SET_HDR(&chan_info->tlv_header,
3034 WMITLV_TAG_STRUC_wmi_channel,
3035 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3036 chan_info->mhz = tchan_info->mhz;
3037 chan_info->band_center_freq1 =
3038 tchan_info->cfreq1;
3039 chan_info->band_center_freq2 =
3040 tchan_info->cfreq2;
3041
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303042 if (tchan_info->is_chan_passive)
3043 WMI_SET_CHANNEL_FLAG(chan_info,
3044 WMI_CHAN_FLAG_PASSIVE);
3045
3046 if (tchan_info->allow_vht)
3047 WMI_SET_CHANNEL_FLAG(chan_info,
3048 WMI_CHAN_FLAG_ALLOW_VHT);
3049 else if (tchan_info->allow_ht)
3050 WMI_SET_CHANNEL_FLAG(chan_info,
3051 WMI_CHAN_FLAG_ALLOW_HT);
3052 WMI_SET_CHANNEL_MODE(chan_info,
3053 tchan_info->phy_mode);
3054
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303055 if (tchan_info->half_rate)
3056 WMI_SET_CHANNEL_FLAG(chan_info,
3057 WMI_CHAN_FLAG_HALF_RATE);
3058
3059 if (tchan_info->quarter_rate)
3060 WMI_SET_CHANNEL_FLAG(chan_info,
3061 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303062
3063 /* also fill in power information */
3064 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3065 tchan_info->minpower);
3066 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3067 tchan_info->maxpower);
3068 WMI_SET_CHANNEL_REG_POWER(chan_info,
3069 tchan_info->maxregpower);
3070 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3071 tchan_info->antennamax);
3072 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3073 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003074 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3075 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303076
Govind Singh87542482016-06-08 19:40:11 +05303077 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3078
Govind Singh87542482016-06-08 19:40:11 +05303079 tchan_info++;
3080 chan_info++;
3081 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303082 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3083 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303084
Anish Natarajdd855152017-03-20 12:49:08 +05303085 qdf_status = wmi_unified_cmd_send(
3086 wmi_handle,
3087 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303088
3089 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3090 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3091 wmi_buf_free(buf);
3092 }
3093
3094end:
3095 return qdf_status;
3096}
3097#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303098
3099/**
3100 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3101 *
3102 * @bufp: Pointer to buffer
3103 * @param: Pointer to tx param
3104 *
3105 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3106 */
3107static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3108 struct tx_send_params param)
3109{
3110 wmi_tx_send_params *tx_param;
3111 QDF_STATUS status = QDF_STATUS_SUCCESS;
3112
3113 if (!bufp) {
3114 status = QDF_STATUS_E_FAILURE;
3115 return status;
3116 }
3117 tx_param = (wmi_tx_send_params *)bufp;
3118 WMITLV_SET_HDR(&tx_param->tlv_header,
3119 WMITLV_TAG_STRUC_wmi_tx_send_params,
3120 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3121 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3122 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3123 param.mcs_mask);
3124 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3125 param.nss_mask);
3126 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3127 param.retry_limit);
3128 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3129 param.chain_mask);
3130 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3131 param.bw_mask);
3132 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3133 param.preamble_type);
3134 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3135 param.frame_type);
3136
3137 return status;
3138}
3139
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303140#ifdef CONFIG_HL_SUPPORT
3141/**
3142 * send_mgmt_cmd_tlv() - WMI scan start function
3143 * @wmi_handle : handle to WMI.
3144 * @param : pointer to hold mgmt cmd parameter
3145 *
3146 * Return: 0 on success and -ve on failure.
3147 */
3148static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3149 struct wmi_mgmt_params *param)
3150{
3151 wmi_buf_t buf;
3152 uint8_t *bufp;
3153 int32_t cmd_len;
3154 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3155 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3156 mgmt_tx_dl_frm_len;
3157
3158 if (param->frm_len > mgmt_tx_dl_frm_len) {
3159 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3160 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3161 return QDF_STATUS_E_INVAL;
3162 }
3163
3164 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3165 WMI_TLV_HDR_SIZE +
3166 roundup(bufp_len, sizeof(uint32_t));
3167
3168 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3169 if (!buf) {
3170 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3171 return QDF_STATUS_E_NOMEM;
3172 }
3173
3174 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3175 bufp = (uint8_t *) cmd;
3176 WMITLV_SET_HDR(&cmd->tlv_header,
3177 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3178 WMITLV_GET_STRUCT_TLVLEN
3179 (wmi_mgmt_tx_send_cmd_fixed_param));
3180
3181 cmd->vdev_id = param->vdev_id;
3182
3183 cmd->desc_id = param->desc_id;
3184 cmd->chanfreq = param->chanfreq;
3185 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3186 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3187 sizeof(uint32_t)));
3188 bufp += WMI_TLV_HDR_SIZE;
3189 qdf_mem_copy(bufp, param->pdata, bufp_len);
3190
3191 cmd->frame_len = param->frm_len;
3192 cmd->buf_len = bufp_len;
3193 cmd->tx_params_valid = param->tx_params_valid;
3194
3195 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3196 bufp, cmd->vdev_id, cmd->chanfreq);
3197
3198 bufp += roundup(bufp_len, sizeof(uint32_t));
3199 if (param->tx_params_valid) {
3200 if (populate_tx_send_params(bufp, param->tx_param) !=
3201 QDF_STATUS_SUCCESS) {
3202 WMI_LOGE("%s: Populate TX send params failed",
3203 __func__);
3204 goto free_buf;
3205 }
3206 cmd_len += sizeof(wmi_tx_send_params);
3207 }
3208
3209 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3210 WMI_MGMT_TX_SEND_CMDID)) {
3211 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3212 goto free_buf;
3213 }
3214 return QDF_STATUS_SUCCESS;
3215
3216free_buf:
3217 wmi_buf_free(buf);
3218 return QDF_STATUS_E_FAILURE;
3219}
3220#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303221/**
3222 * send_mgmt_cmd_tlv() - WMI scan start function
3223 * @wmi_handle : handle to WMI.
3224 * @param : pointer to hold mgmt cmd parameter
3225 *
3226 * Return: 0 on success and -ve on failure.
3227 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303228static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303229 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303230{
Govind Singh427ee5a2016-02-26 18:09:36 +05303231 wmi_buf_t buf;
3232 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3233 int32_t cmd_len;
3234 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303235 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303236 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303237 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303238 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3239 mgmt_tx_dl_frm_len;
3240
3241 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303242 WMI_TLV_HDR_SIZE +
3243 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303244
Sathish Kumar5b636932017-06-28 14:40:32 +05303245 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3248 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303249 }
3250
3251 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3252 bufp = (uint8_t *) cmd;
3253 WMITLV_SET_HDR(&cmd->tlv_header,
3254 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3255 WMITLV_GET_STRUCT_TLVLEN
3256 (wmi_mgmt_tx_send_cmd_fixed_param));
3257
3258 cmd->vdev_id = param->vdev_id;
3259
Govind Singh224a7312016-06-21 14:33:26 +05303260 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303261 cmd->chanfreq = param->chanfreq;
3262 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3263 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3264 sizeof(uint32_t)));
3265 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303266 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303267
3268 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3269 QDF_DMA_TO_DEVICE);
3270 if (status != QDF_STATUS_SUCCESS) {
3271 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303272 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303273 }
3274
Govind Singhb53420c2016-03-09 14:32:57 +05303275 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303276 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003277#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303278 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3279#endif
3280 cmd->frame_len = param->frm_len;
3281 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303282 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303283
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003284 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003285 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003286
Sathish Kumar5b636932017-06-28 14:40:32 +05303287 bufp += roundup(bufp_len, sizeof(uint32_t));
3288 if (param->tx_params_valid) {
3289 status = populate_tx_send_params(bufp, param->tx_param);
3290 if (status != QDF_STATUS_SUCCESS) {
3291 WMI_LOGE("%s: Populate TX send params failed",
3292 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303293 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303294 }
3295 cmd_len += sizeof(wmi_tx_send_params);
3296 }
3297
Govind Singh427ee5a2016-02-26 18:09:36 +05303298 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3299 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303300 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303301 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303302 }
Govind Singhb53420c2016-03-09 14:32:57 +05303303 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303304
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303305unmap_tx_frame:
3306 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3307 QDF_DMA_TO_DEVICE);
3308free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303309 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303310 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303311}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303312#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303313
3314/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303315 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3316 * @wmi_handle : handle to WMI.
3317 * @param : pointer to offchan data tx cmd parameter
3318 *
3319 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3320 */
3321static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3322 struct wmi_offchan_data_tx_params *param)
3323{
3324 wmi_buf_t buf;
3325 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3326 int32_t cmd_len;
3327 uint64_t dma_addr;
3328 void *qdf_ctx = param->qdf_ctx;
3329 uint8_t *bufp;
3330 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3331 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303332 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303333
3334 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303335 WMI_TLV_HDR_SIZE +
3336 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303337
Sathish Kumar5b636932017-06-28 14:40:32 +05303338 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303339 if (!buf) {
3340 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3341 return QDF_STATUS_E_NOMEM;
3342 }
3343
3344 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3345 bufp = (uint8_t *) cmd;
3346 WMITLV_SET_HDR(&cmd->tlv_header,
3347 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3348 WMITLV_GET_STRUCT_TLVLEN
3349 (wmi_offchan_data_tx_send_cmd_fixed_param));
3350
3351 cmd->vdev_id = param->vdev_id;
3352
3353 cmd->desc_id = param->desc_id;
3354 cmd->chanfreq = param->chanfreq;
3355 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3356 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3357 sizeof(uint32_t)));
3358 bufp += WMI_TLV_HDR_SIZE;
3359 qdf_mem_copy(bufp, param->pdata, bufp_len);
3360 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3361 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3362 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3363#if defined(HTT_PADDR64)
3364 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3365#endif
3366 cmd->frame_len = param->frm_len;
3367 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303368 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303369
3370 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3371 bufp, cmd->vdev_id, cmd->chanfreq);
3372
Sathish Kumar5b636932017-06-28 14:40:32 +05303373 bufp += roundup(bufp_len, sizeof(uint32_t));
3374 if (param->tx_params_valid) {
3375 status = populate_tx_send_params(bufp, param->tx_param);
3376 if (status != QDF_STATUS_SUCCESS) {
3377 WMI_LOGE("%s: Populate TX send params failed",
3378 __func__);
3379 goto err1;
3380 }
3381 cmd_len += sizeof(wmi_tx_send_params);
3382 }
3383
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303384 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3385 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3386 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303387 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303388 }
3389
3390 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303391
3392err1:
3393 wmi_buf_free(buf);
3394 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303395}
3396
3397/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303398 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3399 * @wmi_handle: wmi handle
3400 * @param_value: parameter value
3401 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303402 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303403 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303404static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303405 uint32_t param_value)
3406{
Govind Singh67922e82016-04-01 16:48:57 +05303407 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303408 wmi_modem_power_state_cmd_param *cmd;
3409 wmi_buf_t buf;
3410 uint16_t len = sizeof(*cmd);
3411
3412 buf = wmi_buf_alloc(wmi_handle, len);
3413 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303414 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303415 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303416 }
3417 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3418 WMITLV_SET_HDR(&cmd->tlv_header,
3419 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3420 WMITLV_GET_STRUCT_TLVLEN
3421 (wmi_modem_power_state_cmd_param));
3422 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303423 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303424 param_value);
3425 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3426 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303427 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303429 wmi_buf_free(buf);
3430 }
Govind Singh67922e82016-04-01 16:48:57 +05303431
Govind Singh427ee5a2016-02-26 18:09:36 +05303432 return ret;
3433}
3434
3435/**
3436 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3437 * @wmi_handle: wmi handle
3438 * @vdev_id: vdev id
3439 * @val: value
3440 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303441 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303442 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303443static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303444 uint32_t vdev_id, uint8_t val)
3445{
3446 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3447 wmi_buf_t buf;
3448 int32_t len = sizeof(*cmd);
3449
Govind Singhb53420c2016-03-09 14:32:57 +05303450 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303451
3452 buf = wmi_buf_alloc(wmi_handle, len);
3453 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303454 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303455 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303456 }
3457 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3458 WMITLV_SET_HDR(&cmd->tlv_header,
3459 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3460 WMITLV_GET_STRUCT_TLVLEN
3461 (wmi_sta_powersave_mode_cmd_fixed_param));
3462 cmd->vdev_id = vdev_id;
3463 if (val)
3464 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3465 else
3466 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3467
3468 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3469 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303470 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303471 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303472 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303473 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303474 }
Govind Singh5eb51532016-03-09 11:34:12 +05303475 return 0;
3476}
3477
Govind Singh427ee5a2016-02-26 18:09:36 +05303478/**
3479 * send_set_mimops_cmd_tlv() - set MIMO powersave
3480 * @wmi_handle: wmi handle
3481 * @vdev_id: vdev id
3482 * @value: value
3483 *
Govind Singhb53420c2016-03-09 14:32:57 +05303484 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303485 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303486static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303487 uint8_t vdev_id, int value)
3488{
Govind Singh67922e82016-04-01 16:48:57 +05303489 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303490 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3491 wmi_buf_t buf;
3492 uint16_t len = sizeof(*cmd);
3493
3494 buf = wmi_buf_alloc(wmi_handle, len);
3495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303496 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303497 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303498 }
3499 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3500 WMITLV_SET_HDR(&cmd->tlv_header,
3501 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3502 WMITLV_GET_STRUCT_TLVLEN
3503 (wmi_sta_smps_force_mode_cmd_fixed_param));
3504
3505 cmd->vdev_id = vdev_id;
3506
Houston Hoffmanb5168052016-04-14 02:18:01 -07003507 /* WMI_SMPS_FORCED_MODE values do not directly map
3508 * to SM power save values defined in the specification.
3509 * Make sure to send the right mapping.
3510 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303511 switch (value) {
3512 case 0:
3513 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3514 break;
3515 case 1:
3516 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3517 break;
3518 case 2:
3519 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3520 break;
3521 case 3:
3522 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3523 break;
3524 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303525 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303526 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303527 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303528 }
3529
Govind Singhb53420c2016-03-09 14:32:57 +05303530 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303531
3532 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3533 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303534 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303535 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303536 wmi_buf_free(buf);
3537 }
3538
3539 return ret;
3540}
3541
3542/**
3543 * send_set_smps_params_cmd_tlv() - set smps params
3544 * @wmi_handle: wmi handle
3545 * @vdev_id: vdev id
3546 * @value: value
3547 *
Govind Singhb53420c2016-03-09 14:32:57 +05303548 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303550static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303551 int value)
3552{
Govind Singh67922e82016-04-01 16:48:57 +05303553 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303554 wmi_sta_smps_param_cmd_fixed_param *cmd;
3555 wmi_buf_t buf;
3556 uint16_t len = sizeof(*cmd);
3557
3558 buf = wmi_buf_alloc(wmi_handle, len);
3559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303560 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303561 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303562 }
3563 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3564 WMITLV_SET_HDR(&cmd->tlv_header,
3565 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3566 WMITLV_GET_STRUCT_TLVLEN
3567 (wmi_sta_smps_param_cmd_fixed_param));
3568
3569 cmd->vdev_id = vdev_id;
3570 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3571 cmd->param =
3572 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3573
Govind Singhb53420c2016-03-09 14:32:57 +05303574 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303575 cmd->param);
3576
3577 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3578 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303579 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303580 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303581 wmi_buf_free(buf);
3582 }
3583
3584 return ret;
3585}
3586
3587/**
3588 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3589 * @wmi_handle: wmi handle
3590 * @noa: p2p power save parameters
3591 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303592 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303594static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303595 struct p2p_ps_params *noa)
3596{
3597 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3598 wmi_p2p_noa_descriptor *noa_discriptor;
3599 wmi_buf_t buf;
3600 uint8_t *buf_ptr;
3601 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303602 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303603 uint32_t duration;
3604
Govind Singhb53420c2016-03-09 14:32:57 +05303605 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303606 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3607 buf = wmi_buf_alloc(wmi_handle, len);
3608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303609 WMI_LOGE("Failed to allocate memory");
3610 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303611 goto end;
3612 }
3613
3614 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3615 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3616 WMITLV_SET_HDR(&cmd->tlv_header,
3617 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3618 WMITLV_GET_STRUCT_TLVLEN
3619 (wmi_p2p_set_noa_cmd_fixed_param));
3620 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3621 cmd->vdev_id = noa->session_id;
3622 cmd->enable = (duration) ? true : false;
3623 cmd->num_noa = 1;
3624
3625 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3626 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3627 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3628 sizeof
3629 (wmi_p2p_set_noa_cmd_fixed_param)
3630 + WMI_TLV_HDR_SIZE);
3631 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3632 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3633 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3634 noa_discriptor->type_count = noa->count;
3635 noa_discriptor->duration = duration;
3636 noa_discriptor->interval = noa->interval;
3637 noa_discriptor->start_time = 0;
3638
Govind Singhb53420c2016-03-09 14:32:57 +05303639 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303640 cmd->vdev_id, noa->count, noa_discriptor->duration,
3641 noa->interval);
3642 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3643 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303644 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303645 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303646 wmi_buf_free(buf);
3647 }
3648
3649end:
Govind Singhb53420c2016-03-09 14:32:57 +05303650 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303651 return status;
3652}
3653
3654
3655/**
3656 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3657 * @wmi_handle: wmi handle
3658 * @noa: p2p opp power save parameters
3659 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303660 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303661 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303662static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303663 struct p2p_ps_params *oppps)
3664{
3665 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3666 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303667 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303668
Govind Singhb53420c2016-03-09 14:32:57 +05303669 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303670 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3671 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303672 WMI_LOGE("Failed to allocate memory");
3673 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303674 goto end;
3675 }
3676
3677 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3678 WMITLV_SET_HDR(&cmd->tlv_header,
3679 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3680 WMITLV_GET_STRUCT_TLVLEN
3681 (wmi_p2p_set_oppps_cmd_fixed_param));
3682 cmd->vdev_id = oppps->session_id;
3683 if (oppps->ctwindow)
3684 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3685
3686 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303687 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303688 cmd->vdev_id, oppps->ctwindow);
3689 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3690 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303691 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303692 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303693 wmi_buf_free(buf);
3694 }
3695
3696end:
Govind Singhb53420c2016-03-09 14:32:57 +05303697 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303698 return status;
3699}
3700
Wu Gaocd3a8512017-03-13 20:17:34 +08003701#ifdef CONVERGED_P2P_ENABLE
3702/**
3703 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3704 * @wmi_handle: wmi handle
3705 * @param: p2p listen offload start parameters
3706 *
3707 * Return: QDF status
3708 */
3709static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3710 struct p2p_lo_start *param)
3711{
3712 wmi_buf_t buf;
3713 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3714 int32_t len = sizeof(*cmd);
3715 uint8_t *buf_ptr;
3716 QDF_STATUS status;
3717 int device_types_len_aligned;
3718 int probe_resp_len_aligned;
3719
3720 if (!param) {
3721 WMI_LOGE("lo start param is null");
3722 return QDF_STATUS_E_INVAL;
3723 }
3724
3725 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3726
3727 device_types_len_aligned =
3728 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303729 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003730 probe_resp_len_aligned =
3731 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303732 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003733
3734 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3735 probe_resp_len_aligned;
3736
3737 buf = wmi_buf_alloc(wmi_handle, len);
3738 if (!buf) {
3739 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3740 __func__);
3741 return QDF_STATUS_E_NOMEM;
3742 }
3743
3744 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3745 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3746
3747 WMITLV_SET_HDR(&cmd->tlv_header,
3748 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3749 WMITLV_GET_STRUCT_TLVLEN(
3750 wmi_p2p_lo_start_cmd_fixed_param));
3751
3752 cmd->vdev_id = param->vdev_id;
3753 cmd->ctl_flags = param->ctl_flags;
3754 cmd->channel = param->freq;
3755 cmd->period = param->period;
3756 cmd->interval = param->interval;
3757 cmd->count = param->count;
3758 cmd->device_types_len = param->dev_types_len;
3759 cmd->prob_resp_len = param->probe_resp_len;
3760
3761 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3763 device_types_len_aligned);
3764 buf_ptr += WMI_TLV_HDR_SIZE;
3765 qdf_mem_copy(buf_ptr, param->device_types,
3766 param->dev_types_len);
3767
3768 buf_ptr += device_types_len_aligned;
3769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3770 probe_resp_len_aligned);
3771 buf_ptr += WMI_TLV_HDR_SIZE;
3772 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3773 param->probe_resp_len);
3774
3775 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3776 cmd->channel, cmd->period, cmd->interval, cmd->count);
3777
3778 status = wmi_unified_cmd_send(wmi_handle,
3779 buf, len,
3780 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3781 if (status != QDF_STATUS_SUCCESS) {
3782 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3783 __func__, status);
3784 wmi_buf_free(buf);
3785 return status;
3786 }
3787
3788 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3789
3790 return QDF_STATUS_SUCCESS;
3791}
3792
3793/**
3794 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3795 * @wmi_handle: wmi handle
3796 * @param: p2p listen offload stop parameters
3797 *
3798 * Return: QDF status
3799 */
3800static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3801 uint8_t vdev_id)
3802{
3803 wmi_buf_t buf;
3804 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3805 int32_t len;
3806 QDF_STATUS status;
3807
3808 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3809
3810 len = sizeof(*cmd);
3811 buf = wmi_buf_alloc(wmi_handle, len);
3812 if (!buf) {
3813 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3814 __func__);
3815 return QDF_STATUS_E_NOMEM;
3816 }
3817 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3818
3819 WMITLV_SET_HDR(&cmd->tlv_header,
3820 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3821 WMITLV_GET_STRUCT_TLVLEN(
3822 wmi_p2p_lo_stop_cmd_fixed_param));
3823
3824 cmd->vdev_id = vdev_id;
3825
3826 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3827
3828 status = wmi_unified_cmd_send(wmi_handle,
3829 buf, len,
3830 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3831 if (status != QDF_STATUS_SUCCESS) {
3832 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3833 __func__, status);
3834 wmi_buf_free(buf);
3835 return status;
3836 }
3837
3838 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3839
3840 return QDF_STATUS_SUCCESS;
3841}
3842#endif /* End of CONVERGED_P2P_ENABLE */
3843
Govind Singh427ee5a2016-02-26 18:09:36 +05303844/**
3845 * send_get_temperature_cmd_tlv() - get pdev temperature req
3846 * @wmi_handle: wmi handle
3847 *
Govind Singhb53420c2016-03-09 14:32:57 +05303848 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303850static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303851{
3852 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3853 wmi_buf_t wmi_buf;
3854 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3855 uint8_t *buf_ptr;
3856
3857 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303858 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3859 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303860 }
3861
3862 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3863 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303864 WMI_LOGE(FL("wmi_buf_alloc failed"));
3865 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303866 }
3867
3868 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3869
3870 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3871 WMITLV_SET_HDR(&cmd->tlv_header,
3872 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3873 WMITLV_GET_STRUCT_TLVLEN
3874 (wmi_pdev_get_temperature_cmd_fixed_param));
3875
3876 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3877 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303878 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303879 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303880 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303881 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303882
Govind Singhb53420c2016-03-09 14:32:57 +05303883 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303884}
3885
3886/**
3887 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3888 * @wmi_handle: wmi handle
3889 * @vdevid: vdev id
3890 * @peer_addr: peer mac address
3891 * @auto_triggerparam: auto trigger parameters
3892 * @num_ac: number of access category
3893 *
3894 * This function sets the trigger
3895 * uapsd params such as service interval, delay interval
3896 * and suspend interval which will be used by the firmware
3897 * to send trigger frames periodically when there is no
3898 * traffic on the transmit side.
3899 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303900 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303901 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303902static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303903 struct sta_uapsd_trig_params *param)
3904{
3905 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303906 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303907 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3908 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3909 uint32_t i;
3910 wmi_buf_t buf;
3911 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003912 struct sta_uapsd_params *uapsd_param;
3913 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303914
3915 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303917 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303918 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303919 }
3920
3921 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3922 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3923 WMITLV_SET_HDR(&cmd->tlv_header,
3924 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3925 WMITLV_GET_STRUCT_TLVLEN
3926 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3927 cmd->vdev_id = param->vdevid;
3928 cmd->num_ac = param->num_ac;
3929 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3930
3931 /* TLV indicating array of structures to follow */
3932 buf_ptr += sizeof(*cmd);
3933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3934
3935 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303936
3937 /*
3938 * Update tag and length for uapsd auto trigger params (this will take
3939 * care of updating tag and length if it is not pre-filled by caller).
3940 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003941 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3942 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303943 for (i = 0; i < param->num_ac; i++) {
3944 WMITLV_SET_HDR((buf_ptr +
3945 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3946 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3947 WMITLV_GET_STRUCT_TLVLEN
3948 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003949 trig_param->wmm_ac = uapsd_param->wmm_ac;
3950 trig_param->user_priority = uapsd_param->user_priority;
3951 trig_param->service_interval = uapsd_param->service_interval;
3952 trig_param->suspend_interval = uapsd_param->suspend_interval;
3953 trig_param->delay_interval = uapsd_param->delay_interval;
3954 trig_param++;
3955 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303956 }
3957
3958 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3959 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303960 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303961 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303962 wmi_buf_free(buf);
3963 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303964
Govind Singh427ee5a2016-02-26 18:09:36 +05303965 return ret;
3966}
3967
Zhang Qian11c0de32018-01-05 16:50:53 +08003968#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303969/**
3970 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3971 * @wmi_handle: pointer to the wmi handle
3972 * @utc: pointer to the UTC time struct
3973 *
3974 * Return: 0 on succes
3975 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303976static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303977 struct ocb_utc_param *utc)
3978{
Govind Singh67922e82016-04-01 16:48:57 +05303979 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303980 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3981 uint8_t *buf_ptr;
3982 uint32_t len, i;
3983 wmi_buf_t buf;
3984
3985 len = sizeof(*cmd);
3986 buf = wmi_buf_alloc(wmi_handle, len);
3987 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303988 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303989 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303990 }
3991
3992 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3993 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3994 WMITLV_SET_HDR(&cmd->tlv_header,
3995 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3996 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3997 cmd->vdev_id = utc->vdev_id;
3998
3999 for (i = 0; i < SIZE_UTC_TIME; i++)
4000 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
4001
4002 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
4003 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
4004
4005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4006 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304008 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304009 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304010 }
4011
Govind Singh67922e82016-04-01 16:48:57 +05304012 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304013}
4014
4015/**
4016 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
4017 * frames on a channel
4018 * @wmi_handle: pointer to the wmi handle
4019 * @timing_advert: pointer to the timing advertisement struct
4020 *
4021 * Return: 0 on succes
4022 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304023static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304024 struct ocb_timing_advert_param *timing_advert)
4025{
Govind Singh67922e82016-04-01 16:48:57 +05304026 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304027 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
4028 uint8_t *buf_ptr;
4029 uint32_t len, len_template;
4030 wmi_buf_t buf;
4031
4032 len = sizeof(*cmd) +
4033 WMI_TLV_HDR_SIZE;
4034
4035 len_template = timing_advert->template_length;
4036 /* Add padding to the template if needed */
4037 if (len_template % 4 != 0)
4038 len_template += 4 - (len_template % 4);
4039 len += len_template;
4040
4041 buf = wmi_buf_alloc(wmi_handle, len);
4042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304043 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304044 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304045 }
4046
4047 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4048 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4049 WMITLV_SET_HDR(&cmd->tlv_header,
4050 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4051 WMITLV_GET_STRUCT_TLVLEN(
4052 wmi_ocb_start_timing_advert_cmd_fixed_param));
4053 cmd->vdev_id = timing_advert->vdev_id;
4054 cmd->repeat_rate = timing_advert->repeat_rate;
4055 cmd->channel_freq = timing_advert->chan_freq;
4056 cmd->timestamp_offset = timing_advert->timestamp_offset;
4057 cmd->time_value_offset = timing_advert->time_value_offset;
4058 cmd->timing_advert_template_length = timing_advert->template_length;
4059 buf_ptr += sizeof(*cmd);
4060
4061 /* Add the timing advert template */
4062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4063 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304064 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304065 (uint8_t *)timing_advert->template_value,
4066 timing_advert->template_length);
4067
4068 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4069 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304070 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304071 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304072 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304073 }
4074
Govind Singh67922e82016-04-01 16:48:57 +05304075 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304076}
4077
4078/**
4079 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4080 * on a channel
4081 * @wmi_handle: pointer to the wmi handle
4082 * @timing_advert: pointer to the timing advertisement struct
4083 *
4084 * Return: 0 on succes
4085 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304086static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304087 struct ocb_timing_advert_param *timing_advert)
4088{
Govind Singh67922e82016-04-01 16:48:57 +05304089 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304090 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4091 uint8_t *buf_ptr;
4092 uint32_t len;
4093 wmi_buf_t buf;
4094
4095 len = sizeof(*cmd);
4096 buf = wmi_buf_alloc(wmi_handle, len);
4097 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304098 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304099 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304100 }
4101
4102 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4103 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4104 WMITLV_SET_HDR(&cmd->tlv_header,
4105 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4106 WMITLV_GET_STRUCT_TLVLEN(
4107 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4108 cmd->vdev_id = timing_advert->vdev_id;
4109 cmd->channel_freq = timing_advert->chan_freq;
4110
4111 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4112 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304113 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304114 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304115 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304116 }
4117
Govind Singh67922e82016-04-01 16:48:57 +05304118 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304119}
4120
4121/**
4122 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4123 * @wmi_handle: pointer to the wmi handle
4124 * @request: pointer to the request
4125 *
4126 * Return: 0 on succes
4127 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304128static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304129 uint8_t vdev_id)
4130{
Govind Singhb53420c2016-03-09 14:32:57 +05304131 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304132 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4133 uint8_t *buf_ptr;
4134 wmi_buf_t buf;
4135 int32_t len;
4136
4137 len = sizeof(*cmd);
4138 buf = wmi_buf_alloc(wmi_handle, len);
4139 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304140 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304141 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304142 }
4143 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4144
4145 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304146 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304147 WMITLV_SET_HDR(&cmd->tlv_header,
4148 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4149 WMITLV_GET_STRUCT_TLVLEN(
4150 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4151 cmd->vdev_id = vdev_id;
4152
4153 /* Send the WMI command */
4154 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4155 WMI_OCB_GET_TSF_TIMER_CMDID);
4156 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304157 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304158 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304159 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304160 }
4161
Govind Singh67922e82016-04-01 16:48:57 +05304162 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304163}
4164
4165/**
4166 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4167 * @wmi_handle: pointer to the wmi handle
4168 * @get_stats_param: pointer to the dcc stats
4169 *
4170 * Return: 0 on succes
4171 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304172static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004173 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304174{
Govind Singh67922e82016-04-01 16:48:57 +05304175 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304176 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4177 wmi_dcc_channel_stats_request *channel_stats_array;
4178 wmi_buf_t buf;
4179 uint8_t *buf_ptr;
4180 uint32_t len;
4181 uint32_t i;
4182
4183 /* Validate the input */
4184 if (get_stats_param->request_array_len !=
4185 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304186 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304187 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304188 }
4189
4190 /* Allocate memory for the WMI command */
4191 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4192 get_stats_param->request_array_len;
4193
4194 buf = wmi_buf_alloc(wmi_handle, len);
4195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304196 WMI_LOGE(FL("wmi_buf_alloc failed"));
4197 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304198 }
4199
4200 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304201 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304202
4203 /* Populate the WMI command */
4204 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4205 buf_ptr += sizeof(*cmd);
4206
4207 WMITLV_SET_HDR(&cmd->tlv_header,
4208 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4209 WMITLV_GET_STRUCT_TLVLEN(
4210 wmi_dcc_get_stats_cmd_fixed_param));
4211 cmd->vdev_id = get_stats_param->vdev_id;
4212 cmd->num_channels = get_stats_param->channel_count;
4213
4214 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4215 get_stats_param->request_array_len);
4216 buf_ptr += WMI_TLV_HDR_SIZE;
4217
4218 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304219 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304220 get_stats_param->request_array_len);
4221 for (i = 0; i < cmd->num_channels; i++)
4222 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4223 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4224 WMITLV_GET_STRUCT_TLVLEN(
4225 wmi_dcc_channel_stats_request));
4226
4227 /* Send the WMI command */
4228 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4229 WMI_DCC_GET_STATS_CMDID);
4230
Govind Singh67922e82016-04-01 16:48:57 +05304231 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304232 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304233 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304234 }
4235
Govind Singh67922e82016-04-01 16:48:57 +05304236 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304237}
4238
4239/**
4240 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4241 * @wmi_handle: pointer to the wmi handle
4242 * @vdev_id: vdev id
4243 * @dcc_stats_bitmap: dcc status bitmap
4244 *
4245 * Return: 0 on succes
4246 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304247static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304248 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4249{
Govind Singh67922e82016-04-01 16:48:57 +05304250 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304251 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4252 wmi_buf_t buf;
4253 uint8_t *buf_ptr;
4254 uint32_t len;
4255
4256 /* Allocate memory for the WMI command */
4257 len = sizeof(*cmd);
4258
4259 buf = wmi_buf_alloc(wmi_handle, len);
4260 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304261 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304262 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304263 }
4264
4265 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304266 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304267
4268 /* Populate the WMI command */
4269 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4270
4271 WMITLV_SET_HDR(&cmd->tlv_header,
4272 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4273 WMITLV_GET_STRUCT_TLVLEN(
4274 wmi_dcc_clear_stats_cmd_fixed_param));
4275 cmd->vdev_id = vdev_id;
4276 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4277
4278 /* Send the WMI command */
4279 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4280 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304281 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304282 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304283 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304284 }
4285
Govind Singh67922e82016-04-01 16:48:57 +05304286 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304287}
4288
4289/**
4290 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4291 * @wmi_handle: pointer to the wmi handle
4292 * @update_ndl_param: pointer to the request parameters
4293 *
4294 * Return: 0 on success
4295 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304296static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004297 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304298{
Govind Singhb53420c2016-03-09 14:32:57 +05304299 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304300 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4301 wmi_dcc_ndl_chan *ndl_chan_array;
4302 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4303 uint32_t active_state_count;
4304 wmi_buf_t buf;
4305 uint8_t *buf_ptr;
4306 uint32_t len;
4307 uint32_t i;
4308
4309 /* validate the input */
4310 if (update_ndl_param->dcc_ndl_chan_list_len !=
4311 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304312 WMI_LOGE(FL("Invalid parameter"));
4313 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304314 }
4315 active_state_count = 0;
4316 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4317 for (i = 0; i < update_ndl_param->channel_count; i++)
4318 active_state_count +=
4319 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4320 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4321 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304322 WMI_LOGE(FL("Invalid parameter"));
4323 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304324 }
4325
4326 /* Allocate memory for the WMI command */
4327 len = sizeof(*cmd) +
4328 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4329 WMI_TLV_HDR_SIZE +
4330 update_ndl_param->dcc_ndl_active_state_list_len;
4331
4332 buf = wmi_buf_alloc(wmi_handle, len);
4333 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304334 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304335 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304336 }
4337
4338 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304339 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304340
4341 /* Populate the WMI command */
4342 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4343 buf_ptr += sizeof(*cmd);
4344
4345 WMITLV_SET_HDR(&cmd->tlv_header,
4346 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4347 WMITLV_GET_STRUCT_TLVLEN(
4348 wmi_dcc_update_ndl_cmd_fixed_param));
4349 cmd->vdev_id = update_ndl_param->vdev_id;
4350 cmd->num_channel = update_ndl_param->channel_count;
4351
4352 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4353 update_ndl_param->dcc_ndl_chan_list_len);
4354 buf_ptr += WMI_TLV_HDR_SIZE;
4355
4356 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304357 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304358 update_ndl_param->dcc_ndl_chan_list_len);
4359 for (i = 0; i < cmd->num_channel; i++)
4360 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4361 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4362 WMITLV_GET_STRUCT_TLVLEN(
4363 wmi_dcc_ndl_chan));
4364 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4365
4366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4367 update_ndl_param->dcc_ndl_active_state_list_len);
4368 buf_ptr += WMI_TLV_HDR_SIZE;
4369
4370 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304371 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304372 update_ndl_param->dcc_ndl_active_state_list,
4373 update_ndl_param->dcc_ndl_active_state_list_len);
4374 for (i = 0; i < active_state_count; i++) {
4375 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4376 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4377 WMITLV_GET_STRUCT_TLVLEN(
4378 wmi_dcc_ndl_active_state_config));
4379 }
4380 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4381
4382 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304383 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304384 WMI_DCC_UPDATE_NDL_CMDID);
4385 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304386 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304387 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304388 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304389 }
4390
Govind Singh67922e82016-04-01 16:48:57 +05304391 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304392}
4393
4394/**
4395 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4396 * @wmi_handle: pointer to the wmi handle
4397 * @config: the OCB configuration
4398 *
4399 * Return: 0 on success
4400 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304401static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004402 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304403{
Govind Singh67922e82016-04-01 16:48:57 +05304404 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304405 wmi_ocb_set_config_cmd_fixed_param *cmd;
4406 wmi_channel *chan;
4407 wmi_ocb_channel *ocb_chan;
4408 wmi_qos_parameter *qos_param;
4409 wmi_dcc_ndl_chan *ndl_chan;
4410 wmi_dcc_ndl_active_state_config *ndl_active_config;
4411 wmi_ocb_schedule_element *sched_elem;
4412 uint8_t *buf_ptr;
4413 wmi_buf_t buf;
4414 int32_t len;
4415 int32_t i, j, active_state_count;
4416
4417 /*
4418 * Validate the dcc_ndl_chan_list_len and count the number of active
4419 * states. Validate dcc_ndl_active_state_list_len.
4420 */
4421 active_state_count = 0;
4422 if (config->dcc_ndl_chan_list_len) {
4423 if (!config->dcc_ndl_chan_list ||
4424 config->dcc_ndl_chan_list_len !=
4425 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304426 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304427 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304428 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304429 }
4430
4431 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4432 i < config->channel_count; ++i, ++ndl_chan)
4433 active_state_count +=
4434 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4435
4436 if (active_state_count) {
4437 if (!config->dcc_ndl_active_state_list ||
4438 config->dcc_ndl_active_state_list_len !=
4439 active_state_count *
4440 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304441 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304442 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304443 }
4444 }
4445 }
4446
4447 len = sizeof(*cmd) +
4448 WMI_TLV_HDR_SIZE + config->channel_count *
4449 sizeof(wmi_channel) +
4450 WMI_TLV_HDR_SIZE + config->channel_count *
4451 sizeof(wmi_ocb_channel) +
4452 WMI_TLV_HDR_SIZE + config->channel_count *
4453 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4454 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4455 WMI_TLV_HDR_SIZE + active_state_count *
4456 sizeof(wmi_dcc_ndl_active_state_config) +
4457 WMI_TLV_HDR_SIZE + config->schedule_size *
4458 sizeof(wmi_ocb_schedule_element);
4459 buf = wmi_buf_alloc(wmi_handle, len);
4460 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304461 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304462 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304463 }
4464
4465 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4466 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4467 WMITLV_SET_HDR(&cmd->tlv_header,
4468 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4469 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004470 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304471 cmd->channel_count = config->channel_count;
4472 cmd->schedule_size = config->schedule_size;
4473 cmd->flags = config->flags;
4474 buf_ptr += sizeof(*cmd);
4475
4476 /* Add the wmi_channel info */
4477 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4478 config->channel_count*sizeof(wmi_channel));
4479 buf_ptr += WMI_TLV_HDR_SIZE;
4480 for (i = 0; i < config->channel_count; i++) {
4481 chan = (wmi_channel *)buf_ptr;
4482 WMITLV_SET_HDR(&chan->tlv_header,
4483 WMITLV_TAG_STRUC_wmi_channel,
4484 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4485 chan->mhz = config->channels[i].chan_freq;
4486 chan->band_center_freq1 = config->channels[i].chan_freq;
4487 chan->band_center_freq2 = 0;
4488 chan->info = 0;
4489
Zhang Qian11c0de32018-01-05 16:50:53 +08004490 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304491 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4492 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4493 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4494 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4495 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4496 config->channels[i].antenna_max);
4497
4498 if (config->channels[i].bandwidth < 10)
4499 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4500 else if (config->channels[i].bandwidth < 20)
4501 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4502 buf_ptr += sizeof(*chan);
4503 }
4504
4505 /* Add the wmi_ocb_channel info */
4506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4507 config->channel_count*sizeof(wmi_ocb_channel));
4508 buf_ptr += WMI_TLV_HDR_SIZE;
4509 for (i = 0; i < config->channel_count; i++) {
4510 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4511 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4512 WMITLV_TAG_STRUC_wmi_ocb_channel,
4513 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4514 ocb_chan->bandwidth = config->channels[i].bandwidth;
4515 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4516 config->channels[i].mac_address.bytes,
4517 &ocb_chan->mac_address);
4518 buf_ptr += sizeof(*ocb_chan);
4519 }
4520
4521 /* Add the wmi_qos_parameter info */
4522 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4523 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4524 buf_ptr += WMI_TLV_HDR_SIZE;
4525 /* WMI_MAX_NUM_AC parameters for each channel */
4526 for (i = 0; i < config->channel_count; i++) {
4527 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4528 qos_param = (wmi_qos_parameter *)buf_ptr;
4529 WMITLV_SET_HDR(&qos_param->tlv_header,
4530 WMITLV_TAG_STRUC_wmi_qos_parameter,
4531 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4532 qos_param->aifsn =
4533 config->channels[i].qos_params[j].aifsn;
4534 qos_param->cwmin =
4535 config->channels[i].qos_params[j].cwmin;
4536 qos_param->cwmax =
4537 config->channels[i].qos_params[j].cwmax;
4538 buf_ptr += sizeof(*qos_param);
4539 }
4540 }
4541
4542 /* Add the wmi_dcc_ndl_chan (per channel) */
4543 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4544 config->dcc_ndl_chan_list_len);
4545 buf_ptr += WMI_TLV_HDR_SIZE;
4546 if (config->dcc_ndl_chan_list_len) {
4547 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304548 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304549 config->dcc_ndl_chan_list_len);
4550 for (i = 0; i < config->channel_count; i++)
4551 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4552 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4553 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4554 buf_ptr += config->dcc_ndl_chan_list_len;
4555 }
4556
4557 /* Add the wmi_dcc_ndl_active_state_config */
4558 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4559 sizeof(wmi_dcc_ndl_active_state_config));
4560 buf_ptr += WMI_TLV_HDR_SIZE;
4561 if (active_state_count) {
4562 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304563 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304564 config->dcc_ndl_active_state_list,
4565 active_state_count * sizeof(*ndl_active_config));
4566 for (i = 0; i < active_state_count; ++i)
4567 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4568 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4569 WMITLV_GET_STRUCT_TLVLEN(
4570 wmi_dcc_ndl_active_state_config));
4571 buf_ptr += active_state_count *
4572 sizeof(*ndl_active_config);
4573 }
4574
4575 /* Add the wmi_ocb_schedule_element info */
4576 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4577 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4578 buf_ptr += WMI_TLV_HDR_SIZE;
4579 for (i = 0; i < config->schedule_size; i++) {
4580 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4581 WMITLV_SET_HDR(&sched_elem->tlv_header,
4582 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4583 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4584 sched_elem->channel_freq = config->schedule[i].chan_freq;
4585 sched_elem->total_duration = config->schedule[i].total_duration;
4586 sched_elem->guard_interval = config->schedule[i].guard_interval;
4587 buf_ptr += sizeof(*sched_elem);
4588 }
4589
4590
4591 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4592 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304593 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304594 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304595 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304596 }
4597
Govind Singh67922e82016-04-01 16:48:57 +05304598 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304599}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304600
4601/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004602 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4603 * @wmi_handle: wmi handle
4604 * @evt_buf: wmi event buffer
4605 * @status: status buffer
4606 *
4607 * Return: QDF_STATUS_SUCCESS on success
4608 */
4609static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4610 void *evt_buf,
4611 uint32_t *status)
4612{
4613 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4614 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4615
4616 param_tlvs = evt_buf;
4617 fix_param = param_tlvs->fixed_param;
4618
4619 *status = fix_param->status;
4620 return QDF_STATUS_SUCCESS;
4621}
4622
4623/**
4624 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4625 * @wmi_handle: wmi handle
4626 * @evt_buf: wmi event buffer
4627 * @resp: response buffer
4628 *
4629 * Return: QDF_STATUS_SUCCESS on success
4630 */
4631static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4632 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4633{
4634 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4635 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4636
4637 param_tlvs = evt_buf;
4638 fix_param = param_tlvs->fixed_param;
4639 resp->vdev_id = fix_param->vdev_id;
4640 resp->timer_high = fix_param->tsf_timer_high;
4641 resp->timer_low = fix_param->tsf_timer_low;
4642
4643 return QDF_STATUS_SUCCESS;
4644}
4645
4646/**
4647 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4648 * @wmi_handle: wmi handle
4649 * @evt_buf: wmi event buffer
4650 * @resp: response buffer
4651 *
4652 * Return: QDF_STATUS_SUCCESS on success
4653 */
4654static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4655 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4656{
4657 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4658 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4659
4660 param_tlvs = evt_buf;
4661 fix_param = param_tlvs->fixed_param;
4662 resp->vdev_id = fix_param->vdev_id;
4663 resp->status = fix_param->status;
4664 return QDF_STATUS_SUCCESS;
4665}
4666
4667/**
4668 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4669 * @wmi_handle: wmi handle
4670 * @evt_buf: wmi event buffer
4671 * @resp: response buffer
4672 *
4673 * Since length of stats is variable, buffer for DCC stats will be allocated
4674 * in this function. The caller must free the buffer.
4675 *
4676 * Return: QDF_STATUS_SUCCESS on success
4677 */
4678static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4679 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4680{
4681 struct ocb_dcc_get_stats_response *response;
4682 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4683 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4684
4685 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4686 fix_param = param_tlvs->fixed_param;
4687
4688 /* Allocate and populate the response */
4689 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4690 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4691 WMI_LOGE("%s: too many channels:%d", __func__,
4692 fix_param->num_channels);
4693 QDF_ASSERT(0);
4694 *resp = NULL;
4695 return QDF_STATUS_E_INVAL;
4696 }
4697 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4698 sizeof(wmi_dcc_ndl_stats_per_channel));
4699 *resp = response;
4700 if (!response)
4701 return QDF_STATUS_E_NOMEM;
4702
4703 response->vdev_id = fix_param->vdev_id;
4704 response->num_channels = fix_param->num_channels;
4705 response->channel_stats_array_len =
4706 fix_param->num_channels *
4707 sizeof(wmi_dcc_ndl_stats_per_channel);
4708 response->channel_stats_array = ((uint8_t *)response) +
4709 sizeof(*response);
4710 qdf_mem_copy(response->channel_stats_array,
4711 param_tlvs->stats_per_channel_list,
4712 response->channel_stats_array_len);
4713
4714 return QDF_STATUS_SUCCESS;
4715}
4716#endif
4717
4718/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304719 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4720 * @wmi_handle: wmi handle
4721 * @mcc_adaptive_scheduler: enable/disable
4722 *
4723 * This function enable/disable mcc adaptive scheduler in fw.
4724 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004725 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304726 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304727static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004728 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4729 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304730{
Govind Singh67922e82016-04-01 16:48:57 +05304731 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304732 wmi_buf_t buf = 0;
4733 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4734 uint16_t len =
4735 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4736
4737 buf = wmi_buf_alloc(wmi_handle, len);
4738 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304739 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4740 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304741 }
4742 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4743 wmi_buf_data(buf);
4744
4745 WMITLV_SET_HDR(&cmd->tlv_header,
4746 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4747 WMITLV_GET_STRUCT_TLVLEN
4748 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4749 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304750 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304751
4752 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4753 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304754 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304755 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304756 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304757 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304758 }
Govind Singh67922e82016-04-01 16:48:57 +05304759
4760 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304761}
4762
4763/**
4764 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4765 * @wmi: wmi handle
4766 * @mcc_channel: mcc channel
4767 * @mcc_channel_time_latency: MCC channel time latency.
4768 *
4769 * Currently used to set time latency for an MCC vdev/adapter using operating
4770 * channel of it and channel number. The info is provided run time using
4771 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4772 *
4773 * Return: CDF status
4774 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304775static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304776 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4777{
Govind Singh67922e82016-04-01 16:48:57 +05304778 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304779 wmi_buf_t buf = 0;
4780 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4781 uint16_t len = 0;
4782 uint8_t *buf_ptr = NULL;
4783 wmi_resmgr_chan_latency chan_latency;
4784 /* Note: we only support MCC time latency for a single channel */
4785 uint32_t num_channels = 1;
4786 uint32_t chan1_freq = mcc_channel_freq;
4787 uint32_t latency_chan1 = mcc_channel_time_latency;
4788
4789
4790 /* If 0ms latency is provided, then FW will set to a default.
4791 * Otherwise, latency must be at least 30ms.
4792 */
4793 if ((latency_chan1 > 0) &&
4794 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304795 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304796 "Minimum is 30ms (or 0 to use default value by "
4797 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304798 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304799 }
4800
4801 /* Set WMI CMD for channel time latency here */
4802 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4803 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4804 num_channels * sizeof(wmi_resmgr_chan_latency);
4805 buf = wmi_buf_alloc(wmi_handle, len);
4806 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304807 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4808 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304809 }
4810 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4811 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4812 wmi_buf_data(buf);
4813 WMITLV_SET_HDR(&cmdTL->tlv_header,
4814 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4815 WMITLV_GET_STRUCT_TLVLEN
4816 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4817 cmdTL->num_chans = num_channels;
4818 /* Update channel time latency information for home channel(s) */
4819 buf_ptr += sizeof(*cmdTL);
4820 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4821 num_channels * sizeof(wmi_resmgr_chan_latency));
4822 buf_ptr += WMI_TLV_HDR_SIZE;
4823 chan_latency.chan_mhz = chan1_freq;
4824 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304825 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304826 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4827 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304828 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304829 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304830 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304831 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304832 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304833 }
Govind Singh67922e82016-04-01 16:48:57 +05304834
4835 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304836}
4837
4838/**
4839 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4840 * @wmi: wmi handle
4841 * @adapter_1_chan_number: adapter 1 channel number
4842 * @adapter_1_quota: adapter 1 quota
4843 * @adapter_2_chan_number: adapter 2 channel number
4844 *
4845 * Return: CDF status
4846 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304847static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304848 uint32_t adapter_1_chan_freq,
4849 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4850{
Govind Singh67922e82016-04-01 16:48:57 +05304851 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304852 wmi_buf_t buf = 0;
4853 uint16_t len = 0;
4854 uint8_t *buf_ptr = NULL;
4855 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4856 wmi_resmgr_chan_time_quota chan_quota;
4857 uint32_t quota_chan1 = adapter_1_quota;
4858 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4859 uint32_t quota_chan2 = 100 - quota_chan1;
4860 /* Note: setting time quota for MCC requires info for 2 channels */
4861 uint32_t num_channels = 2;
4862 uint32_t chan1_freq = adapter_1_chan_freq;
4863 uint32_t chan2_freq = adapter_2_chan_freq;
4864
Govind Singhb53420c2016-03-09 14:32:57 +05304865 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304866 "freq2:%dMHz, Quota2:%dms", __func__,
4867 chan1_freq, quota_chan1, chan2_freq,
4868 quota_chan2);
4869
4870 /*
4871 * Perform sanity check on time quota values provided.
4872 */
4873 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4874 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304875 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304876 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304877 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304878 }
4879 /* Set WMI CMD for channel time quota here */
4880 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4881 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4882 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4883 buf = wmi_buf_alloc(wmi_handle, len);
4884 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304885 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4886 QDF_ASSERT(0);
4887 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304888 }
4889 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4890 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4891 wmi_buf_data(buf);
4892 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4893 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4894 WMITLV_GET_STRUCT_TLVLEN
4895 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4896 cmdTQ->num_chans = num_channels;
4897
4898 /* Update channel time quota information for home channel(s) */
4899 buf_ptr += sizeof(*cmdTQ);
4900 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4901 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4902 buf_ptr += WMI_TLV_HDR_SIZE;
4903 chan_quota.chan_mhz = chan1_freq;
4904 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304905 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304906 /* Construct channel and quota record for the 2nd MCC mode. */
4907 buf_ptr += sizeof(chan_quota);
4908 chan_quota.chan_mhz = chan2_freq;
4909 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304910 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304911
4912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4913 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304914 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304915 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304917 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304918 }
Govind Singh67922e82016-04-01 16:48:57 +05304919
4920 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304921}
4922
4923/**
4924 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4925 * @wmi_handle: Pointer to wmi handle
4926 * @thermal_info: Thermal command information
4927 *
4928 * This function sends the thermal management command
4929 * to the firmware
4930 *
Govind Singhb53420c2016-03-09 14:32:57 +05304931 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304933static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304934 struct thermal_cmd_params *thermal_info)
4935{
4936 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4937 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304938 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304939 uint32_t len = 0;
4940
4941 len = sizeof(*cmd);
4942
4943 buf = wmi_buf_alloc(wmi_handle, len);
4944 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304945 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4946 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304947 }
4948
4949 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4950
4951 WMITLV_SET_HDR(&cmd->tlv_header,
4952 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4953 WMITLV_GET_STRUCT_TLVLEN
4954 (wmi_thermal_mgmt_cmd_fixed_param));
4955
4956 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4957 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4958 cmd->enable = thermal_info->thermal_enable;
4959
Govind Singhb53420c2016-03-09 14:32:57 +05304960 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304961 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4962
4963 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4964 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304965 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304966 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304967 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304968 }
4969
Govind Singh67922e82016-04-01 16:48:57 +05304970 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304971}
4972
4973
4974/**
4975 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304976 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304977 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4978 *
4979 * This function sends down the LRO configuration parameters to
4980 * the firmware to enable LRO, sets the TCP flags and sets the
4981 * seed values for the toeplitz hash generation
4982 *
Govind Singhb53420c2016-03-09 14:32:57 +05304983 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304984 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304985static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304986 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4987{
4988 wmi_lro_info_cmd_fixed_param *cmd;
4989 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304990 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304991
4992
4993 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4994 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304995 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4996 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304997 }
4998
4999 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
5000
5001 WMITLV_SET_HDR(&cmd->tlv_header,
5002 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
5003 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
5004
5005 cmd->lro_enable = wmi_lro_cmd->lro_enable;
5006 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
5007 wmi_lro_cmd->tcp_flag);
5008 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
5009 wmi_lro_cmd->tcp_flag_mask);
5010 cmd->toeplitz_hash_ipv4_0_3 =
5011 wmi_lro_cmd->toeplitz_hash_ipv4[0];
5012 cmd->toeplitz_hash_ipv4_4_7 =
5013 wmi_lro_cmd->toeplitz_hash_ipv4[1];
5014 cmd->toeplitz_hash_ipv4_8_11 =
5015 wmi_lro_cmd->toeplitz_hash_ipv4[2];
5016 cmd->toeplitz_hash_ipv4_12_15 =
5017 wmi_lro_cmd->toeplitz_hash_ipv4[3];
5018 cmd->toeplitz_hash_ipv4_16 =
5019 wmi_lro_cmd->toeplitz_hash_ipv4[4];
5020
5021 cmd->toeplitz_hash_ipv6_0_3 =
5022 wmi_lro_cmd->toeplitz_hash_ipv6[0];
5023 cmd->toeplitz_hash_ipv6_4_7 =
5024 wmi_lro_cmd->toeplitz_hash_ipv6[1];
5025 cmd->toeplitz_hash_ipv6_8_11 =
5026 wmi_lro_cmd->toeplitz_hash_ipv6[2];
5027 cmd->toeplitz_hash_ipv6_12_15 =
5028 wmi_lro_cmd->toeplitz_hash_ipv6[3];
5029 cmd->toeplitz_hash_ipv6_16_19 =
5030 wmi_lro_cmd->toeplitz_hash_ipv6[4];
5031 cmd->toeplitz_hash_ipv6_20_23 =
5032 wmi_lro_cmd->toeplitz_hash_ipv6[5];
5033 cmd->toeplitz_hash_ipv6_24_27 =
5034 wmi_lro_cmd->toeplitz_hash_ipv6[6];
5035 cmd->toeplitz_hash_ipv6_28_31 =
5036 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5037 cmd->toeplitz_hash_ipv6_32_35 =
5038 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5039 cmd->toeplitz_hash_ipv6_36_39 =
5040 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5041 cmd->toeplitz_hash_ipv6_40 =
5042 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5043
Govind Singhb53420c2016-03-09 14:32:57 +05305044 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305045 cmd->lro_enable, cmd->tcp_flag_u32);
5046
5047 status = wmi_unified_cmd_send(wmi_handle, buf,
5048 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305049 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305050 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305051 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305052 }
5053
Govind Singh67922e82016-04-01 16:48:57 +05305054 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305055}
5056
Govind Singh4eacd2b2016-03-07 14:24:22 +05305057/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305058 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5059 * @wmi_handle: Pointer to wmi handle
5060 * @rate_report_params: Pointer to peer rate report parameters
5061 *
5062 *
5063 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5064 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305065static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305066 struct wmi_peer_rate_report_params *rate_report_params)
5067{
5068 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5069 wmi_buf_t buf = NULL;
5070 QDF_STATUS status = 0;
5071 uint32_t len = 0;
5072 uint32_t i, j;
5073
5074 len = sizeof(*cmd);
5075
5076 buf = wmi_buf_alloc(wmi_handle, len);
5077 if (!buf) {
5078 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5079 return QDF_STATUS_E_FAILURE;
5080 }
5081
5082 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5083 wmi_buf_data(buf);
5084
5085 WMITLV_SET_HDR(
5086 &cmd->tlv_header,
5087 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5088 WMITLV_GET_STRUCT_TLVLEN(
5089 wmi_peer_set_rate_report_condition_fixed_param));
5090
5091 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5092 cmd->report_backoff_time = rate_report_params->backoff_time;
5093 cmd->report_timer_period = rate_report_params->timer_period;
5094 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5095 cmd->cond_per_phy[i].val_cond_flags =
5096 rate_report_params->report_per_phy[i].cond_flags;
5097 cmd->cond_per_phy[i].rate_delta.min_delta =
5098 rate_report_params->report_per_phy[i].delta.delta_min;
5099 cmd->cond_per_phy[i].rate_delta.percentage =
5100 rate_report_params->report_per_phy[i].delta.percent;
5101 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5102 cmd->cond_per_phy[i].rate_threshold[j] =
5103 rate_report_params->report_per_phy[i].
5104 report_rate_threshold[j];
5105 }
5106 }
5107
5108 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5109 cmd->enable_rate_report,
5110 cmd->report_backoff_time, cmd->report_timer_period);
5111
5112 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5113 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5114 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305115 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305116 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5117 __func__);
5118 }
5119 return status;
5120}
5121
5122/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305123 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5124 * @wmi_handle: wmi handle
5125 * @param: bcn ll cmd parameter
5126 *
Govind Singhb53420c2016-03-09 14:32:57 +05305127 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305128 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305129static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305130 wmi_bcn_send_from_host_cmd_fixed_param *param)
5131{
5132 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5133 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305134 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305135
5136 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5137 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305138 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5139 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305140 }
5141
5142 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5143 WMITLV_SET_HDR(&cmd->tlv_header,
5144 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5145 WMITLV_GET_STRUCT_TLVLEN
5146 (wmi_bcn_send_from_host_cmd_fixed_param));
5147 cmd->vdev_id = param->vdev_id;
5148 cmd->data_len = param->data_len;
5149 cmd->frame_ctrl = param->frame_ctrl;
5150 cmd->frag_ptr = param->frag_ptr;
5151 cmd->dtim_flag = param->dtim_flag;
5152
5153 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5154 WMI_PDEV_SEND_BCN_CMDID);
5155
Govind Singh67922e82016-04-01 16:48:57 +05305156 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305157 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305158 wmi_buf_free(wmi_buf);
5159 }
5160
5161 return ret;
5162}
5163
5164/**
5165 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5166 * @wmi_handle: wmi handle
5167 * @vdev_id: vdev id
5168 * @max_retries: max retries
5169 * @retry_interval: retry interval
5170 * This function sets sta query related parameters in fw.
5171 *
Govind Singhb53420c2016-03-09 14:32:57 +05305172 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305173 */
5174
Sathish Kumarfd347372017-02-13 12:29:09 +05305175static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305176 uint8_t vdev_id, uint32_t max_retries,
5177 uint32_t retry_interval)
5178{
5179 wmi_buf_t buf;
5180 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5181 int len;
5182
5183 len = sizeof(*cmd);
5184 buf = wmi_buf_alloc(wmi_handle, len);
5185 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305186 WMI_LOGE(FL("wmi_buf_alloc failed"));
5187 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 }
5189
5190 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5191 WMITLV_SET_HDR(&cmd->tlv_header,
5192 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5193 WMITLV_GET_STRUCT_TLVLEN
5194 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5195
5196
5197 cmd->vdev_id = vdev_id;
5198 cmd->sa_query_max_retry_count = max_retries;
5199 cmd->sa_query_retry_interval = retry_interval;
5200
Govind Singhb53420c2016-03-09 14:32:57 +05305201 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305202 vdev_id, retry_interval, max_retries);
5203
5204 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5205 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305206 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305207 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305208 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305209 }
5210
Govind Singhb53420c2016-03-09 14:32:57 +05305211 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305212 return 0;
5213}
5214
5215/**
5216 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5217 * @wmi_handle: wmi handle
5218 * @params: sta keep alive parameter
5219 *
5220 * This function sets keep alive related parameters in fw.
5221 *
5222 * Return: CDF status
5223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305224static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305225 struct sta_params *params)
5226{
5227 wmi_buf_t buf;
5228 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5229 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5230 uint8_t *buf_ptr;
5231 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305232 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233
Govind Singhb53420c2016-03-09 14:32:57 +05305234 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305235
Govind Singh4eacd2b2016-03-07 14:24:22 +05305236 len = sizeof(*cmd) + sizeof(*arp_rsp);
5237 buf = wmi_buf_alloc(wmi_handle, len);
5238 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305239 WMI_LOGE("wmi_buf_alloc failed");
5240 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305241 }
5242
5243 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5244 buf_ptr = (uint8_t *) cmd;
5245 WMITLV_SET_HDR(&cmd->tlv_header,
5246 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5247 WMITLV_GET_STRUCT_TLVLEN
5248 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5249 cmd->interval = params->timeperiod;
5250 cmd->enable = (params->timeperiod) ? 1 : 0;
5251 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305252 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 params->timeperiod, params->method);
5254 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5255 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5256 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5257 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5258
c_manjee2772b9c2017-01-23 15:14:13 +05305259 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5260 (params->method ==
5261 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305262 if ((NULL == params->hostv4addr) ||
5263 (NULL == params->destv4addr) ||
5264 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005265 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5266 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305268 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305269 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 }
c_manjee2772b9c2017-01-23 15:14:13 +05305271 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305272 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305273 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305274 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305275 WMI_IPV4_ADDR_LEN);
5276 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5277 } else {
5278 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5279 }
5280
Govind Singh67922e82016-04-01 16:48:57 +05305281 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5282 WMI_STA_KEEPALIVE_CMDID);
5283 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305284 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305285 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305286 }
5287
Govind Singhb53420c2016-03-09 14:32:57 +05305288 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305289 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305290}
5291
5292/**
5293 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5294 * @wmi_handle: wmi handle
5295 * @if_id: vdev id
5296 * @gtx_info: GTX config params
5297 *
5298 * This function set GTX related params in firmware.
5299 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305300 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305301 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305302static QDF_STATUS send_vdev_set_gtx_cfg_cmd_tlv(wmi_unified_t wmi_handle, uint32_t if_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305303 struct wmi_gtx_config *gtx_info)
5304{
5305 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5306 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305307 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305309
Govind Singh4eacd2b2016-03-07 14:24:22 +05305310 buf = wmi_buf_alloc(wmi_handle, len);
5311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305312 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305313 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305314 }
5315 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5316 WMITLV_SET_HDR(&cmd->tlv_header,
5317 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5318 WMITLV_GET_STRUCT_TLVLEN
5319 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5320 cmd->vdev_id = if_id;
5321
5322 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5323 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5324 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5325 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5326 cmd->gtxPERMargin = gtx_info->gtx_margin;
5327 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5328 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5329 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5330
Govind Singhb53420c2016-03-09 14:32:57 +05305331 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305332 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5333 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5334 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5335 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5336
Abhishek Singh716c46c2016-05-04 16:24:07 +05305337 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305338 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305339 if (QDF_IS_STATUS_ERROR(ret)) {
5340 WMI_LOGE("Failed to set GTX PARAMS");
5341 wmi_buf_free(buf);
5342 }
5343 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305344}
5345
5346/**
5347 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5348 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305349 * @vdev_id: vdev id.
5350 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305351 *
5352 * This function updates EDCA parameters to the target
5353 *
5354 * Return: CDF Status
5355 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305356static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005357 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305358 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305359{
5360 uint8_t *buf_ptr;
5361 wmi_buf_t buf;
5362 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305363 wmi_wmm_vparams *wmm_param;
5364 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365 int len = sizeof(*cmd);
5366 int ac;
5367
5368 buf = wmi_buf_alloc(wmi_handle, len);
5369
5370 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305371 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5372 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305373 }
5374
5375 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5376 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5377 WMITLV_SET_HDR(&cmd->tlv_header,
5378 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5379 WMITLV_GET_STRUCT_TLVLEN
5380 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5381 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005382 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305383
5384 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5385 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305386 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305387 WMITLV_SET_HDR(&wmm_param->tlv_header,
5388 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5389 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5390 wmm_param->cwmin = twmm_param->cwmin;
5391 wmm_param->cwmax = twmm_param->cwmax;
5392 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005393 if (mu_edca_param)
5394 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5395 else
5396 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305397 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305398 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305399 }
5400
5401 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5402 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5403 goto fail;
5404
Govind Singhb53420c2016-03-09 14:32:57 +05305405 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305406
5407fail:
5408 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305409 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5410 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305411}
5412
5413/**
5414 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5415 * @wmi_handle: wmi handle
5416 * @vdev_id: vdev id
5417 * @probe_rsp_info: probe response info
5418 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305419 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305420 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305421static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305422 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005423 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305424{
5425 wmi_prb_tmpl_cmd_fixed_param *cmd;
5426 wmi_bcn_prb_info *bcn_prb_info;
5427 wmi_buf_t wmi_buf;
5428 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5429 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305430 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305431
Govind Singhb53420c2016-03-09 14:32:57 +05305432 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305433
Krunal Soni89426862017-11-14 15:42:48 -08005434 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305435 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305436
5437 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5438 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5439 tmpl_len_aligned;
5440
5441 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305442 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305443 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305444 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305445 }
5446
5447 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5448 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305449 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305450 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305451 }
5452
5453 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5454
5455 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5456 WMITLV_SET_HDR(&cmd->tlv_header,
5457 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5458 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5459 cmd->vdev_id = vdev_id;
5460 cmd->buf_len = tmpl_len;
5461 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5462
5463 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5464 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5465 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5466 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5467 bcn_prb_info->caps = 0;
5468 bcn_prb_info->erp = 0;
5469 buf_ptr += sizeof(wmi_bcn_prb_info);
5470
5471 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5472 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005473 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305474
5475 ret = wmi_unified_cmd_send(wmi_handle,
5476 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305477 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305478 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305479 wmi_buf_free(wmi_buf);
5480 }
5481
5482 return ret;
5483}
5484
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305485#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305486#define WPI_IV_LEN 16
5487
5488/**
5489 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5490 *
5491 * @dest_tx: destination address of tsc key counter
5492 * @src_tx: source address of tsc key counter
5493 * @dest_rx: destination address of rsc key counter
5494 * @src_rx: source address of rsc key counter
5495 *
5496 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5497 *
5498 * Return: None
5499 *
5500 */
5501static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5502 uint8_t *dest_rx, uint8_t *src_rx)
5503{
5504 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5505 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5506}
5507#else
5508static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5509 uint8_t *dest_rx, uint8_t *src_rx)
5510{
5511 return;
5512}
5513#endif
5514
5515/**
5516 * send_setup_install_key_cmd_tlv() - set key parameters
5517 * @wmi_handle: wmi handle
5518 * @key_params: key parameters
5519 *
5520 * This function fills structure from information
5521 * passed in key_params.
5522 *
5523 * Return: QDF_STATUS_SUCCESS - success
5524 * QDF_STATUS_E_FAILURE - failure
5525 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5526 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305527static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305528 struct set_key_params *key_params)
5529{
5530 wmi_vdev_install_key_cmd_fixed_param *cmd;
5531 wmi_buf_t buf;
5532 uint8_t *buf_ptr;
5533 uint32_t len;
5534 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305535 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305536
5537 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5538 WMI_TLV_HDR_SIZE;
5539
5540 buf = wmi_buf_alloc(wmi_handle, len);
5541 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305542 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305543 return QDF_STATUS_E_NOMEM;
5544 }
5545
5546 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5547 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5548 WMITLV_SET_HDR(&cmd->tlv_header,
5549 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5550 WMITLV_GET_STRUCT_TLVLEN
5551 (wmi_vdev_install_key_cmd_fixed_param));
5552 cmd->vdev_id = key_params->vdev_id;
5553 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305554
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305555
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305556 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5557 cmd->key_flags |= key_params->key_flags;
5558 cmd->key_cipher = key_params->key_cipher;
5559 if ((key_params->key_txmic_len) &&
5560 (key_params->key_rxmic_len)) {
5561 cmd->key_txmic_len = key_params->key_txmic_len;
5562 cmd->key_rxmic_len = key_params->key_rxmic_len;
5563 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305564#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305565 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5566 key_params->tx_iv,
5567 cmd->wpi_key_rsc_counter,
5568 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305569#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305570 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5571 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5572 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305573 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305574 qdf_mem_copy((void *)key_data,
5575 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005576 if (key_params->key_rsc_counter)
5577 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5578 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305579 cmd->key_len = key_params->key_len;
5580
5581 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5582 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305583 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305584 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305585
Govind Singh67922e82016-04-01 16:48:57 +05305586 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305587}
5588
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305589/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005590 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5591 * @wmi_handle: wmi handle
5592 * @params: sar limit params
5593 *
5594 * Return: QDF_STATUS_SUCCESS for success or error code
5595 */
5596static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5597 struct sar_limit_cmd_params *sar_limit_params)
5598{
5599 wmi_buf_t buf;
5600 QDF_STATUS qdf_status;
5601 wmi_sar_limits_cmd_fixed_param *cmd;
5602 int i;
5603 uint8_t *buf_ptr;
5604 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5605 struct sar_limit_cmd_row *sar_rows_list;
5606 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5607
5608 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5609 buf = wmi_buf_alloc(wmi_handle, len);
5610 if (!buf) {
5611 WMI_LOGE("Failed to allocate memory");
5612 qdf_status = QDF_STATUS_E_NOMEM;
5613 goto end;
5614 }
5615
5616 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5617 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5618 WMITLV_SET_HDR(&cmd->tlv_header,
5619 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5620 WMITLV_GET_STRUCT_TLVLEN
5621 (wmi_sar_limits_cmd_fixed_param));
5622 cmd->sar_enable = sar_limit_params->sar_enable;
5623 cmd->commit_limits = sar_limit_params->commit_limits;
5624 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5625
5626 WMI_LOGD("no of sar rows = %d, len = %d",
5627 sar_limit_params->num_limit_rows, len);
5628 buf_ptr += sizeof(*cmd);
5629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5630 sizeof(wmi_sar_limit_cmd_row) *
5631 sar_limit_params->num_limit_rows);
5632 if (cmd->num_limit_rows == 0)
5633 goto send_sar_limits;
5634
5635 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5636 (buf_ptr + WMI_TLV_HDR_SIZE);
5637 sar_rows_list = sar_limit_params->sar_limit_row_list;
5638
5639 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5640 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5641 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5642 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5643 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5644 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5645 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5646 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5647 wmi_sar_rows_list->validity_bitmap =
5648 sar_rows_list->validity_bitmap;
5649 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5650 i, wmi_sar_rows_list->band_id,
5651 wmi_sar_rows_list->chain_id,
5652 wmi_sar_rows_list->mod_id,
5653 wmi_sar_rows_list->limit_value,
5654 wmi_sar_rows_list->validity_bitmap);
5655 sar_rows_list++;
5656 wmi_sar_rows_list++;
5657 }
5658send_sar_limits:
5659 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5660 WMI_SAR_LIMITS_CMDID);
5661
5662 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5663 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5664 wmi_buf_free(buf);
5665 }
5666
5667end:
5668 return qdf_status;
5669}
5670
Jeff Johnson4783f902017-12-14 15:50:16 -08005671static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5672{
5673 wmi_sar_get_limits_cmd_fixed_param *cmd;
5674 wmi_buf_t wmi_buf;
5675 uint32_t len;
5676 QDF_STATUS status;
5677
5678 WMI_LOGD(FL("Enter"));
5679
5680 len = sizeof(*cmd);
5681 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5682 if (!wmi_buf) {
5683 WMI_LOGP(FL("failed to allocate memory for msg"));
5684 return QDF_STATUS_E_NOMEM;
5685 }
5686
5687 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5688
5689 WMITLV_SET_HDR(&cmd->tlv_header,
5690 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5691 WMITLV_GET_STRUCT_TLVLEN
5692 (wmi_sar_get_limits_cmd_fixed_param));
5693
5694 cmd->reserved = 0;
5695
5696 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5697 WMI_SAR_GET_LIMITS_CMDID);
5698 if (QDF_IS_STATUS_ERROR(status)) {
5699 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5700 wmi_buf_free(wmi_buf);
5701 }
5702
5703 WMI_LOGD(FL("Exit"));
5704
5705 return status;
5706}
5707
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005708/**
5709 * wmi_sar2_result_string() - return string conversion of sar2 result
5710 * @result: sar2 result value
5711 *
5712 * This utility function helps log string conversion of sar2 result.
5713 *
5714 * Return: string conversion of sar 2 result, if match found;
5715 * "Unknown response" otherwise.
5716 */
5717static const char *wmi_sar2_result_string(uint32_t result)
5718{
5719 switch (result) {
5720 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5721 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5722 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5723 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5724 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5725 default:
5726 return "Unknown response";
5727 }
5728}
5729
5730/**
5731 * extract_sar2_result_event_tlv() - process sar response event from FW.
5732 * @handle: wma handle
5733 * @event: event buffer
5734 * @len: buffer length
5735 *
5736 * Return: 0 for success or error code
5737 */
5738static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5739 uint8_t *event,
5740 uint32_t len)
5741{
5742 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5743
5744 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5745 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5746
5747 if (!param_buf) {
5748 WMI_LOGI("Invalid sar2 result event buffer");
5749 return QDF_STATUS_E_INVAL;
5750 }
5751
5752 sar2_fixed_param = param_buf->fixed_param;
5753 if (!sar2_fixed_param) {
5754 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5755 return QDF_STATUS_E_INVAL;
5756 }
5757
5758 WMI_LOGI("SAR2 result: %s",
5759 wmi_sar2_result_string(sar2_fixed_param->result));
5760
5761 return QDF_STATUS_SUCCESS;
5762}
5763
Jeff Johnson4783f902017-12-14 15:50:16 -08005764static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5765 uint8_t *evt_buf,
5766 struct sar_limit_event *event)
5767{
5768 wmi_sar_get_limits_event_fixed_param *fixed_param;
5769 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5770 wmi_sar_get_limit_event_row *row_in;
5771 struct sar_limit_event_row *row_out;
5772 uint32_t row;
5773
5774 if (!evt_buf) {
5775 WMI_LOGE(FL("input event is NULL"));
5776 return QDF_STATUS_E_INVAL;
5777 }
5778 if (!event) {
5779 WMI_LOGE(FL("output event is NULL"));
5780 return QDF_STATUS_E_INVAL;
5781 }
5782
5783 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5784
5785 fixed_param = param_buf->fixed_param;
5786 if (!fixed_param) {
5787 WMI_LOGE(FL("Invalid fixed param"));
5788 return QDF_STATUS_E_INVAL;
5789 }
5790
5791 event->sar_enable = fixed_param->sar_enable;
5792 event->num_limit_rows = fixed_param->num_limit_rows;
5793
5794 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5795 QDF_ASSERT(0);
5796 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5797 event->num_limit_rows,
5798 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5799 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5800 }
5801
5802 row_in = param_buf->sar_get_limits;
5803 row_out = &event->sar_limit_row[0];
5804 for (row = 0; row < event->num_limit_rows; row++) {
5805 row_out->band_id = row_in->band_id;
5806 row_out->chain_id = row_in->chain_id;
5807 row_out->mod_id = row_in->mod_id;
5808 row_out->limit_value = row_in->limit_value;
5809 row_out++;
5810 row_in++;
5811 }
5812
5813 return QDF_STATUS_SUCCESS;
5814}
5815
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305816#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005817/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305818 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5819 * @wmi_handle: wmi handle
5820 * @params: encrypt/decrypt params
5821 *
5822 * Return: QDF_STATUS_SUCCESS for success or error code
5823 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005824static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305825QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305826 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305827{
5828 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5829 wmi_buf_t wmi_buf;
5830 uint8_t *buf_ptr;
5831 QDF_STATUS ret;
5832 uint32_t len;
5833
5834 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5835
5836 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305837 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305838 WMI_TLV_HDR_SIZE;
5839 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5840 if (!wmi_buf) {
5841 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5842 __func__);
5843 return QDF_STATUS_E_NOMEM;
5844 }
5845
5846 buf_ptr = wmi_buf_data(wmi_buf);
5847 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5848
5849 WMITLV_SET_HDR(&cmd->tlv_header,
5850 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5851 WMITLV_GET_STRUCT_TLVLEN(
5852 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5853
5854 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5855 cmd->key_flag = encrypt_decrypt_params->key_flag;
5856 cmd->key_idx = encrypt_decrypt_params->key_idx;
5857 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5858 cmd->key_len = encrypt_decrypt_params->key_len;
5859 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5860 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5861
5862 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5863 encrypt_decrypt_params->key_len);
5864
5865 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5866 MAX_MAC_HEADER_LEN);
5867
5868 cmd->data_len = encrypt_decrypt_params->data_len;
5869
5870 if (cmd->data_len) {
5871 buf_ptr += sizeof(*cmd);
5872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5873 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305874 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305875 buf_ptr += WMI_TLV_HDR_SIZE;
5876 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5877 encrypt_decrypt_params->data_len);
5878 }
5879
5880 /* This conversion is to facilitate data to FW in little endian */
5881 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5882 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5883 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5884 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5885 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5886 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5887
5888 ret = wmi_unified_cmd_send(wmi_handle,
5889 wmi_buf, len,
5890 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5891 if (QDF_IS_STATUS_ERROR(ret)) {
5892 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5893 wmi_buf_free(wmi_buf);
5894 }
5895
5896 return ret;
5897}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305898
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305899/**
5900 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5901 * params from event
5902 * @wmi_handle: wmi handle
5903 * @evt_buf: pointer to event buffer
5904 * @resp: Pointer to hold resp parameters
5905 *
5906 * Return: QDF_STATUS_SUCCESS for success or error code
5907 */
5908static
5909QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5910 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5911{
5912 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5913 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5914
5915 param_buf = evt_buf;
5916 if (!param_buf) {
5917 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5918 return QDF_STATUS_E_INVAL;
5919 }
5920
5921 data_event = param_buf->fixed_param;
5922
5923 resp->vdev_id = data_event->vdev_id;
5924 resp->status = data_event->status;
5925
Yeshwanth Sriram Guntukaa79e7f22018-06-22 18:25:45 +05305926 if ((data_event->data_length > param_buf->num_enc80211_frame) ||
5927 (data_event->data_length > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE -
5928 sizeof(*data_event))) {
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305929 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5930 data_event->data_length,
5931 param_buf->num_enc80211_frame);
5932 return QDF_STATUS_E_INVAL;
5933 }
5934
5935 resp->data_len = data_event->data_length;
5936
5937 if (resp->data_len)
5938 resp->data = (uint8_t *)param_buf->enc80211_frame;
5939
5940 return QDF_STATUS_SUCCESS;
5941}
5942#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305943
Govind Singh4eacd2b2016-03-07 14:24:22 +05305944/**
5945 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5946 * @wmi_handle: wmi handle
5947 * @vdev_id: vdev id
5948 * @p2p_ie: p2p IE
5949 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305950 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305951 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305952static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305953 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305954{
Govind Singh67922e82016-04-01 16:48:57 +05305955 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305956 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5957 wmi_buf_t wmi_buf;
5958 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5959 uint8_t *buf_ptr;
5960
5961 ie_len = (uint32_t) (p2p_ie[1] + 2);
5962
5963 /* More than one P2P IE may be included in a single frame.
5964 If multiple P2P IEs are present, the complete P2P attribute
5965 data consists of the concatenation of the P2P Attribute
5966 fields of the P2P IEs. The P2P Attributes field of each
5967 P2P IE may be any length up to the maximum (251 octets).
5968 In this case host sends one P2P IE to firmware so the length
5969 should not exceed more than 251 bytes
5970 */
5971 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305972 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305973 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305974 }
5975
Vivekc5823092018-03-22 23:27:21 +05305976 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305977
5978 wmi_buf_len =
5979 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5980 WMI_TLV_HDR_SIZE;
5981
5982 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5983 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305984 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305985 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305986 }
5987
5988 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5989
5990 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5991 WMITLV_SET_HDR(&cmd->tlv_header,
5992 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5993 WMITLV_GET_STRUCT_TLVLEN
5994 (wmi_p2p_go_set_beacon_ie_fixed_param));
5995 cmd->vdev_id = vdev_id;
5996 cmd->ie_buf_len = ie_len;
5997
5998 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5999 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
6000 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05306001 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306002
Govind Singhb53420c2016-03-09 14:32:57 +05306003 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306004
6005 ret = wmi_unified_cmd_send(wmi_handle,
6006 wmi_buf, wmi_buf_len,
6007 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05306008 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306009 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010 wmi_buf_free(wmi_buf);
6011 }
6012
Govind Singhb53420c2016-03-09 14:32:57 +05306013 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306014 return ret;
6015}
6016
6017/**
6018 * send_set_gateway_params_cmd_tlv() - set gateway parameters
6019 * @wmi_handle: wmi handle
6020 * @req: gateway parameter update request structure
6021 *
6022 * This function reads the incoming @req and fill in the destination
6023 * WMI structure and sends down the gateway configs down to the firmware
6024 *
Govind Singhb53420c2016-03-09 14:32:57 +05306025 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05306026 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306027static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306028 struct gateway_update_req_param *req)
6029{
6030 wmi_roam_subnet_change_config_fixed_param *cmd;
6031 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306032 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306033 int len = sizeof(*cmd);
6034
6035 buf = wmi_buf_alloc(wmi_handle, len);
6036 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306037 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6038 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306039 }
6040
6041 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6042 WMITLV_SET_HDR(&cmd->tlv_header,
6043 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6044 WMITLV_GET_STRUCT_TLVLEN(
6045 wmi_roam_subnet_change_config_fixed_param));
6046
6047 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306048 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6049 QDF_IPV4_ADDR_SIZE);
6050 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6051 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306052 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6053 &cmd->inet_gw_mac_addr);
6054 cmd->max_retries = req->max_retries;
6055 cmd->timeout = req->timeout;
6056 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6057 cmd->flag = 0;
6058 if (req->ipv4_addr_type)
6059 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6060
6061 if (req->ipv6_addr_type)
6062 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6063
6064 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6065 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306066 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306067 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306068 ret);
6069 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306070 }
6071
Govind Singh67922e82016-04-01 16:48:57 +05306072 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306073}
6074
6075/**
6076 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6077 * @wmi_handle: wmi handle
6078 * @req: rssi monitoring request structure
6079 *
6080 * This function reads the incoming @req and fill in the destination
6081 * WMI structure and send down the rssi monitoring configs down to the firmware
6082 *
6083 * Return: 0 on success; error number otherwise
6084 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306085static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306086 struct rssi_monitor_param *req)
6087{
6088 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6089 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306090 QDF_STATUS ret;
6091 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306092
6093 buf = wmi_buf_alloc(wmi_handle, len);
6094 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306095 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6096 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306097 }
6098
6099 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6100 WMITLV_SET_HDR(&cmd->tlv_header,
6101 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6102 WMITLV_GET_STRUCT_TLVLEN(
6103 wmi_rssi_breach_monitor_config_fixed_param));
6104
6105 cmd->vdev_id = req->session_id;
6106 cmd->request_id = req->request_id;
6107 cmd->lo_rssi_reenable_hysteresis = 0;
6108 cmd->hi_rssi_reenable_histeresis = 0;
6109 cmd->min_report_interval = 0;
6110 cmd->max_num_report = 1;
6111 if (req->control) {
6112 /* enable one threshold for each min/max */
6113 cmd->enabled_bitmap = 0x09;
6114 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6115 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6116 } else {
6117 cmd->enabled_bitmap = 0;
6118 cmd->low_rssi_breach_threshold[0] = 0;
6119 cmd->hi_rssi_breach_threshold[0] = 0;
6120 }
6121
6122 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6123 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306124 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306125 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306126 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306127 }
6128
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006129 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6130
Govind Singh67922e82016-04-01 16:48:57 +05306131 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132}
6133
6134/**
6135 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6136 * @wmi_handle: wmi handle
6137 * @psetoui: OUI parameters
6138 *
6139 * set scan probe OUI parameters in firmware
6140 *
6141 * Return: CDF status
6142 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306143static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306144 struct scan_mac_oui *psetoui)
6145{
6146 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6147 wmi_buf_t wmi_buf;
6148 uint32_t len;
6149 uint8_t *buf_ptr;
6150 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306151 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306152
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306153 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6154 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6155
Govind Singh4eacd2b2016-03-07 14:24:22 +05306156 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6157 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306158 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6159 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306160 }
6161 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6162 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6163 WMITLV_SET_HDR(&cmd->tlv_header,
6164 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6165 WMITLV_GET_STRUCT_TLVLEN
6166 (wmi_scan_prob_req_oui_cmd_fixed_param));
6167
6168 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306169 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306170 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6171 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306172 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306173 cmd->prob_req_oui);
6174
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306175 cmd->vdev_id = psetoui->vdev_id;
6176 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6177 if (psetoui->enb_probe_req_sno_randomization)
6178 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6179
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306180 if (ie_whitelist->white_list) {
6181 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6182 &cmd->num_vendor_oui,
6183 ie_whitelist);
6184 cmd->flags |=
6185 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6186 }
6187
6188 buf_ptr += sizeof(*cmd);
6189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6190 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6191 buf_ptr += WMI_TLV_HDR_SIZE;
6192
6193 if (cmd->num_vendor_oui != 0) {
6194 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6195 ie_whitelist->voui);
6196 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6197 }
6198
Govind Singh4eacd2b2016-03-07 14:24:22 +05306199 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6200 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306201 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306202 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306203 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306204 }
Govind Singhb53420c2016-03-09 14:32:57 +05306205 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306206}
6207
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306208#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306209/**
6210 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6211 * @wmi_handle: wmi handle
6212 * @roam_req: Roam scan offload params
6213 * @buf_ptr: command buffer to send
6214 * @fils_tlv_len: fils tlv length
6215 *
6216 * Return: Updated buffer pointer
6217 */
6218static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6219 struct roam_offload_scan_params *roam_req,
6220 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6221{
6222 wmi_roam_fils_offload_tlv_param *fils_tlv;
6223 wmi_erp_info *erp_info;
6224 struct roam_fils_params *roam_fils_params;
6225
6226 if (!roam_req->add_fils_tlv)
6227 return buf_ptr;
6228
6229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6230 sizeof(*fils_tlv));
6231 buf_ptr += WMI_TLV_HDR_SIZE;
6232
6233 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6234 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6235 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6236 WMITLV_GET_STRUCT_TLVLEN
6237 (wmi_roam_fils_offload_tlv_param));
6238
6239 roam_fils_params = &roam_req->roam_fils_params;
6240 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6241
6242 erp_info->username_length = roam_fils_params->username_length;
6243 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6244 erp_info->username_length);
6245
6246 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6247
6248 erp_info->rRk_length = roam_fils_params->rrk_length;
6249 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6250 erp_info->rRk_length);
6251
6252 erp_info->rIk_length = roam_fils_params->rik_length;
6253 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6254 erp_info->rIk_length);
6255
6256 erp_info->realm_len = roam_fils_params->realm_len;
6257 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6258 erp_info->realm_len);
6259
6260 buf_ptr += sizeof(*fils_tlv);
6261 return buf_ptr;
6262}
6263#else
6264static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6265 struct roam_offload_scan_params *roam_req,
6266 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6267{
6268 return buf_ptr;
6269}
6270#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306271/**
6272 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6273 * @wmi_handle: wmi handle
6274 * @scan_cmd_fp: start scan command ptr
6275 * @roam_req: roam request param
6276 *
6277 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6278 * of WMI_ROAM_SCAN_MODE.
6279 *
6280 * Return: QDF status
6281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306282static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306283 wmi_start_scan_cmd_fixed_param *
6284 scan_cmd_fp,
6285 struct roam_offload_scan_params *roam_req)
6286{
6287 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306288 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306289 int len;
6290 uint8_t *buf_ptr;
6291 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306292
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306293#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6294 int auth_mode = roam_req->auth_mode;
6295 wmi_roam_offload_tlv_param *roam_offload_params;
6296 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6297 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6298 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306299 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306300 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306301#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6302 /* Need to create a buf with roam_scan command at
6303 * front and piggyback with scan command */
6304 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6305#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6306 (2 * WMI_TLV_HDR_SIZE) +
6307#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6308 sizeof(wmi_start_scan_cmd_fixed_param);
6309#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006310 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306311 if (roam_req->is_roam_req_valid &&
6312 roam_req->roam_offload_enabled) {
6313 len += sizeof(wmi_roam_offload_tlv_param);
6314 len += WMI_TLV_HDR_SIZE;
6315 if ((auth_mode != WMI_AUTH_NONE) &&
6316 ((auth_mode != WMI_AUTH_OPEN) ||
6317 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306318 roam_req->mdid.mdie_present &&
6319 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306320 roam_req->is_ese_assoc)) {
6321 len += WMI_TLV_HDR_SIZE;
6322 if (roam_req->is_ese_assoc)
6323 len +=
6324 sizeof(wmi_roam_ese_offload_tlv_param);
6325 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6326 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6327 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306328 roam_req->mdid.mdie_present &&
6329 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306330 len +=
6331 sizeof(wmi_roam_11r_offload_tlv_param);
6332 else
6333 len +=
6334 sizeof(wmi_roam_11i_offload_tlv_param);
6335 } else {
6336 len += WMI_TLV_HDR_SIZE;
6337 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306338
6339 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6340 + roundup(roam_req->assoc_ie_length,
6341 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306342
6343 if (roam_req->add_fils_tlv) {
6344 fils_tlv_len = sizeof(
6345 wmi_roam_fils_offload_tlv_param);
6346 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6347 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306348 } else {
6349 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306350 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306351 __func__, roam_req->roam_offload_enabled);
6352 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306353 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306354 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306355 }
6356 if (roam_req->is_roam_req_valid &&
6357 roam_req->roam_offload_enabled) {
6358 roam_req->mode = roam_req->mode |
6359 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6360 }
6361#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6362
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306363 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6364 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6365 len = sizeof(wmi_roam_scan_mode_fixed_param);
6366
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306367 buf = wmi_buf_alloc(wmi_handle, len);
6368 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306369 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306370 return QDF_STATUS_E_NOMEM;
6371 }
6372
6373 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6374 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6375 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6376 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6377 WMITLV_GET_STRUCT_TLVLEN
6378 (wmi_roam_scan_mode_fixed_param));
6379
Abhinav Kumar334355f2018-04-06 17:18:52 +05306380 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6381 roam_req->roam_trigger_reason_bitmask;
6382 roam_scan_mode_fp->min_delay_btw_scans =
6383 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306384 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6385 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306386 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6387 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6388 roam_scan_mode_fp->flags |=
6389 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306390 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306391 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306392
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306393 /* Fill in scan parameters suitable for roaming scan */
6394 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306395
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306396 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6397 sizeof(wmi_start_scan_cmd_fixed_param));
6398 /* Ensure there is no additional IEs */
6399 scan_cmd_fp->ie_len = 0;
6400 WMITLV_SET_HDR(buf_ptr,
6401 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6402 WMITLV_GET_STRUCT_TLVLEN
6403 (wmi_start_scan_cmd_fixed_param));
6404#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6405 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6406 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6407 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6408 sizeof(wmi_roam_offload_tlv_param));
6409 buf_ptr += WMI_TLV_HDR_SIZE;
6410 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6411 WMITLV_SET_HDR(buf_ptr,
6412 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6413 WMITLV_GET_STRUCT_TLVLEN
6414 (wmi_roam_offload_tlv_param));
6415 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6416 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6417 roam_offload_params->select_5g_margin =
6418 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306419 roam_offload_params->handoff_delay_for_rx =
6420 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306421 roam_offload_params->reassoc_failure_timeout =
6422 roam_req->reassoc_failure_timeout;
6423
6424 /* Fill the capabilities */
6425 roam_offload_params->capability =
6426 roam_req->roam_offload_params.capability;
6427 roam_offload_params->ht_caps_info =
6428 roam_req->roam_offload_params.ht_caps_info;
6429 roam_offload_params->ampdu_param =
6430 roam_req->roam_offload_params.ampdu_param;
6431 roam_offload_params->ht_ext_cap =
6432 roam_req->roam_offload_params.ht_ext_cap;
6433 roam_offload_params->ht_txbf =
6434 roam_req->roam_offload_params.ht_txbf;
6435 roam_offload_params->asel_cap =
6436 roam_req->roam_offload_params.asel_cap;
6437 roam_offload_params->qos_caps =
6438 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006439 roam_offload_params->qos_enabled =
6440 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306441 roam_offload_params->wmm_caps =
6442 roam_req->roam_offload_params.wmm_caps;
6443 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6444 (uint8_t *)roam_req->roam_offload_params.mcsset,
6445 ROAM_OFFLOAD_NUM_MCS_SET);
6446
6447 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6448 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6449 * they are filled in the same order.Depending on the
6450 * authentication type, the other mode TLV's are nullified
6451 * and only headers are filled.*/
6452 if ((auth_mode != WMI_AUTH_NONE) &&
6453 ((auth_mode != WMI_AUTH_OPEN) ||
6454 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306455 && roam_req->mdid.mdie_present &&
6456 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306457 roam_req->is_ese_assoc)) {
6458 if (roam_req->is_ese_assoc) {
6459 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6460 WMITLV_GET_STRUCT_TLVLEN(0));
6461 buf_ptr += WMI_TLV_HDR_SIZE;
6462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6463 WMITLV_GET_STRUCT_TLVLEN(0));
6464 buf_ptr += WMI_TLV_HDR_SIZE;
6465 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6466 sizeof(wmi_roam_ese_offload_tlv_param));
6467 buf_ptr += WMI_TLV_HDR_SIZE;
6468 roam_offload_ese =
6469 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6470 qdf_mem_copy(roam_offload_ese->krk,
6471 roam_req->krk,
6472 sizeof(roam_req->krk));
6473 qdf_mem_copy(roam_offload_ese->btk,
6474 roam_req->btk,
6475 sizeof(roam_req->btk));
6476 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6477 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6478 WMITLV_GET_STRUCT_TLVLEN
6479 (wmi_roam_ese_offload_tlv_param));
6480 buf_ptr +=
6481 sizeof(wmi_roam_ese_offload_tlv_param);
6482 } else if (auth_mode == WMI_AUTH_FT_RSNA
6483 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6484 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306485 && roam_req->mdid.mdie_present &&
6486 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306487 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6488 0);
6489 buf_ptr += WMI_TLV_HDR_SIZE;
6490 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6491 sizeof(wmi_roam_11r_offload_tlv_param));
6492 buf_ptr += WMI_TLV_HDR_SIZE;
6493 roam_offload_11r =
6494 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6495 roam_offload_11r->r0kh_id_len =
6496 roam_req->rokh_id_length;
6497 qdf_mem_copy(roam_offload_11r->r0kh_id,
6498 roam_req->rokh_id,
6499 roam_offload_11r->r0kh_id_len);
6500 qdf_mem_copy(roam_offload_11r->psk_msk,
6501 roam_req->psk_pmk,
6502 sizeof(roam_req->psk_pmk));
6503 roam_offload_11r->psk_msk_len =
6504 roam_req->pmk_len;
6505 roam_offload_11r->mdie_present =
6506 roam_req->mdid.mdie_present;
6507 roam_offload_11r->mdid =
6508 roam_req->mdid.mobility_domain;
6509 if (auth_mode == WMI_AUTH_OPEN) {
6510 /* If FT-Open ensure pmk length
6511 and r0khid len are zero */
6512 roam_offload_11r->r0kh_id_len = 0;
6513 roam_offload_11r->psk_msk_len = 0;
6514 }
6515 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6516 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6517 WMITLV_GET_STRUCT_TLVLEN
6518 (wmi_roam_11r_offload_tlv_param));
6519 buf_ptr +=
6520 sizeof(wmi_roam_11r_offload_tlv_param);
6521 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6522 WMITLV_GET_STRUCT_TLVLEN(0));
6523 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006524 WMI_LOGD("psk_msk_len = %d",
6525 roam_offload_11r->psk_msk_len);
6526 if (roam_offload_11r->psk_msk_len)
6527 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6528 QDF_TRACE_LEVEL_DEBUG,
6529 roam_offload_11r->psk_msk,
6530 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306531 } else {
6532 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6533 sizeof(wmi_roam_11i_offload_tlv_param));
6534 buf_ptr += WMI_TLV_HDR_SIZE;
6535 roam_offload_11i =
6536 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006537
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006538 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006539 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306540 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6541 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006542 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306543 } else {
6544 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6545 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006546 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006547 }
6548 if (roam_req->roam_key_mgmt_offload_enabled &&
6549 roam_req->fw_pmksa_cache) {
6550 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6551 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006552 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006553 } else {
6554 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6555 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006556 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306557 }
6558
6559 qdf_mem_copy(roam_offload_11i->pmk,
6560 roam_req->psk_pmk,
6561 sizeof(roam_req->psk_pmk));
6562 roam_offload_11i->pmk_len = roam_req->pmk_len;
6563 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6564 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6565 WMITLV_GET_STRUCT_TLVLEN
6566 (wmi_roam_11i_offload_tlv_param));
6567 buf_ptr +=
6568 sizeof(wmi_roam_11i_offload_tlv_param);
6569 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6570 0);
6571 buf_ptr += WMI_TLV_HDR_SIZE;
6572 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6573 0);
6574 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006575 WMI_LOGD("pmk_len = %d",
6576 roam_offload_11i->pmk_len);
6577 if (roam_offload_11i->pmk_len)
6578 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6579 QDF_TRACE_LEVEL_DEBUG,
6580 roam_offload_11i->pmk,
6581 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306582 }
6583 } else {
6584 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6585 WMITLV_GET_STRUCT_TLVLEN(0));
6586 buf_ptr += WMI_TLV_HDR_SIZE;
6587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6588 WMITLV_GET_STRUCT_TLVLEN(0));
6589 buf_ptr += WMI_TLV_HDR_SIZE;
6590 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6591 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306592 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306593 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306594
6595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6596 sizeof(*assoc_ies));
6597 buf_ptr += WMI_TLV_HDR_SIZE;
6598
6599 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6600 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6601 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6602 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6603 assoc_ies->buf_len = roam_req->assoc_ie_length;
6604
6605 buf_ptr += sizeof(*assoc_ies);
6606
6607 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6608 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6609 buf_ptr += WMI_TLV_HDR_SIZE;
6610
6611 if (assoc_ies->buf_len != 0) {
6612 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6613 assoc_ies->buf_len);
6614 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306615 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6616 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6617 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306618 } else {
6619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6620 WMITLV_GET_STRUCT_TLVLEN(0));
6621 buf_ptr += WMI_TLV_HDR_SIZE;
6622 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6623 WMITLV_GET_STRUCT_TLVLEN(0));
6624 buf_ptr += WMI_TLV_HDR_SIZE;
6625 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6626 WMITLV_GET_STRUCT_TLVLEN(0));
6627 buf_ptr += WMI_TLV_HDR_SIZE;
6628 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6629 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306630 buf_ptr += WMI_TLV_HDR_SIZE;
6631 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6632 WMITLV_GET_STRUCT_TLVLEN(0));
6633 buf_ptr += WMI_TLV_HDR_SIZE;
6634 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6635 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306636 }
6637#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306638
6639send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306640 status = wmi_unified_cmd_send(wmi_handle, buf,
6641 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306642 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306643 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306644 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6645 status);
6646 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306647 }
6648
Govind Singh67922e82016-04-01 16:48:57 +05306649 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306650}
6651
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006652static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6653 struct wmi_mawc_roam_params *params)
6654{
6655 wmi_buf_t buf = NULL;
6656 QDF_STATUS status;
6657 int len;
6658 uint8_t *buf_ptr;
6659 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6660
6661 len = sizeof(*wmi_roam_mawc_params);
6662 buf = wmi_buf_alloc(wmi_handle, len);
6663 if (!buf) {
6664 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6665 return QDF_STATUS_E_NOMEM;
6666 }
6667
6668 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6669 wmi_roam_mawc_params =
6670 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6671 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6672 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6673 WMITLV_GET_STRUCT_TLVLEN
6674 (wmi_roam_configure_mawc_cmd_fixed_param));
6675 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6676 if (params->enable)
6677 wmi_roam_mawc_params->enable = 1;
6678 else
6679 wmi_roam_mawc_params->enable = 0;
6680 wmi_roam_mawc_params->traffic_load_threshold =
6681 params->traffic_load_threshold;
6682 wmi_roam_mawc_params->best_ap_rssi_threshold =
6683 params->best_ap_rssi_threshold;
6684 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6685 params->rssi_stationary_high_adjust;
6686 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6687 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006688 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6689 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6690 wmi_roam_mawc_params->traffic_load_threshold,
6691 wmi_roam_mawc_params->best_ap_rssi_threshold,
6692 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6693 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006694
6695 status = wmi_unified_cmd_send(wmi_handle, buf,
6696 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6697 if (QDF_IS_STATUS_ERROR(status)) {
6698 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6699 status);
6700 wmi_buf_free(buf);
6701 return status;
6702 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006703
6704 return QDF_STATUS_SUCCESS;
6705}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306706
6707/**
6708 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6709 * rssi threashold
6710 * @wmi_handle: wmi handle
6711 * @roam_req: Roaming request buffer
6712 *
6713 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6714 *
6715 * Return: QDF status
6716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306717static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306718 struct roam_offload_scan_rssi_params *roam_req)
6719{
6720 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306721 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306722 int len;
6723 uint8_t *buf_ptr;
6724 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6725 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6726 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306727 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006728 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306729
6730 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6731 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6732 len += sizeof(wmi_roam_scan_extended_threshold_param);
6733 len += WMI_TLV_HDR_SIZE;
6734 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306735 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6736 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006737 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6738 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306739 buf = wmi_buf_alloc(wmi_handle, len);
6740 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306741 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306742 return QDF_STATUS_E_NOMEM;
6743 }
6744
6745 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6746 rssi_threshold_fp =
6747 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6748 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6749 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6750 WMITLV_GET_STRUCT_TLVLEN
6751 (wmi_roam_scan_rssi_threshold_fixed_param));
6752 /* fill in threshold values */
6753 rssi_threshold_fp->vdev_id = roam_req->session_id;
6754 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6755 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6756 rssi_threshold_fp->hirssi_scan_max_count =
6757 roam_req->hi_rssi_scan_max_count;
6758 rssi_threshold_fp->hirssi_scan_delta =
6759 roam_req->hi_rssi_scan_rssi_delta;
6760 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006761 rssi_threshold_fp->rssi_thresh_offset_5g =
6762 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306763
6764 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6765 WMITLV_SET_HDR(buf_ptr,
6766 WMITLV_TAG_ARRAY_STRUC,
6767 sizeof(wmi_roam_scan_extended_threshold_param));
6768 buf_ptr += WMI_TLV_HDR_SIZE;
6769 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6770
6771 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6772 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6773 ext_thresholds->boost_threshold_5g =
6774 roam_req->boost_threshold_5g;
6775
6776 ext_thresholds->boost_algorithm_5g =
6777 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6778 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6779 ext_thresholds->penalty_algorithm_5g =
6780 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6781 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6782 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6783 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6784 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6785
6786 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6787 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6788 WMITLV_GET_STRUCT_TLVLEN
6789 (wmi_roam_scan_extended_threshold_param));
6790 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6791 WMITLV_SET_HDR(buf_ptr,
6792 WMITLV_TAG_ARRAY_STRUC,
6793 sizeof(wmi_roam_earlystop_rssi_thres_param));
6794 buf_ptr += WMI_TLV_HDR_SIZE;
6795 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6796 early_stop_thresholds->roam_earlystop_thres_min =
6797 roam_req->roam_earlystop_thres_min;
6798 early_stop_thresholds->roam_earlystop_thres_max =
6799 roam_req->roam_earlystop_thres_max;
6800 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6801 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6802 WMITLV_GET_STRUCT_TLVLEN
6803 (wmi_roam_earlystop_rssi_thres_param));
6804
Gupta, Kapil7e652922016-04-12 15:02:00 +05306805 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6807 sizeof(wmi_roam_dense_thres_param));
6808 buf_ptr += WMI_TLV_HDR_SIZE;
6809 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6810 dense_thresholds->roam_dense_rssi_thres_offset =
6811 roam_req->dense_rssi_thresh_offset;
6812 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6813 dense_thresholds->roam_dense_traffic_thres =
6814 roam_req->traffic_threshold;
6815 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6816 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6817 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6818 WMITLV_GET_STRUCT_TLVLEN
6819 (wmi_roam_dense_thres_param));
6820
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006821 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6822 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6823 sizeof(wmi_roam_bg_scan_roaming_param));
6824 buf_ptr += WMI_TLV_HDR_SIZE;
6825 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6826 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6827 roam_req->bg_scan_bad_rssi_thresh;
6828 bg_scan_params->roam_bg_scan_client_bitmap =
6829 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306830 bg_scan_params->bad_rssi_thresh_offset_2g =
6831 roam_req->roam_bad_rssi_thresh_offset_2g;
6832 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006833 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6834 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6835 WMITLV_GET_STRUCT_TLVLEN
6836 (wmi_roam_bg_scan_roaming_param));
6837
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306838 status = wmi_unified_cmd_send(wmi_handle, buf,
6839 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306840 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306841 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306842 status);
6843 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306844 }
6845
Govind Singh67922e82016-04-01 16:48:57 +05306846 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306847}
6848
6849/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306850 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6851 * configuration params
6852 * @wma_handle: wma handler
6853 * @dwelltime_params: pointer to dwelltime_params
6854 *
6855 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6856 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006857static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306858QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6859 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6860{
6861 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6862 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6863 wmi_buf_t buf;
6864 uint8_t *buf_ptr;
6865 int32_t err;
6866 int len;
6867
6868 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6869 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6870 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6871 buf = wmi_buf_alloc(wmi_handle, len);
6872 if (!buf) {
6873 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6874 __func__);
6875 return QDF_STATUS_E_NOMEM;
6876 }
6877 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6878 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6879 WMITLV_SET_HDR(&dwell_param->tlv_header,
6880 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6881 WMITLV_GET_STRUCT_TLVLEN
6882 (wmi_scan_adaptive_dwell_config_fixed_param));
6883
6884 dwell_param->enable = dwelltime_params->is_enabled;
6885 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6886 WMITLV_SET_HDR(buf_ptr,
6887 WMITLV_TAG_ARRAY_STRUC,
6888 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6889 buf_ptr += WMI_TLV_HDR_SIZE;
6890
6891 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6892 WMITLV_SET_HDR(&cmd->tlv_header,
6893 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6894 WMITLV_GET_STRUCT_TLVLEN(
6895 wmi_scan_adaptive_dwell_parameters_tlv));
6896
6897 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6898 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6899 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6900 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6901 err = wmi_unified_cmd_send(wmi_handle, buf,
6902 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6903 if (err) {
6904 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6905 wmi_buf_free(buf);
6906 return QDF_STATUS_E_FAILURE;
6907 }
6908
6909 return QDF_STATUS_SUCCESS;
6910}
6911
Nitesh Shah52323d02017-05-22 15:49:00 +05306912/**
6913 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6914 * configuration params
6915 * @wmi_handle: wmi handler
6916 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6917 *
6918 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6919 */
6920static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6921 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6922{
6923 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6924 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6925 wmi_buf_t buf;
6926 uint8_t *buf_ptr;
6927 QDF_STATUS err;
6928 uint32_t i;
6929 int len;
6930
6931 len = sizeof(*dbs_scan_param);
6932 len += WMI_TLV_HDR_SIZE;
6933 len += dbs_scan_params->num_clients * sizeof(*cmd);
6934
6935 buf = wmi_buf_alloc(wmi_handle, len);
6936 if (!buf) {
6937 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6938 return QDF_STATUS_E_NOMEM;
6939 }
6940
6941 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6942 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6943 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6944 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6945 WMITLV_GET_STRUCT_TLVLEN
6946 (wmi_scan_dbs_duty_cycle_fixed_param));
6947
6948 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6949 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6950 buf_ptr += sizeof(*dbs_scan_param);
6951 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6952 (sizeof(*cmd) * dbs_scan_params->num_clients));
6953 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6954
6955 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6956 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6957 WMITLV_SET_HDR(&cmd->tlv_header,
6958 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6959 WMITLV_GET_STRUCT_TLVLEN(
6960 wmi_scan_dbs_duty_cycle_tlv_param));
6961 cmd->module_id = dbs_scan_params->module_id[i];
6962 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6963 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6964 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6965 }
6966
6967 err = wmi_unified_cmd_send(wmi_handle, buf,
6968 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6969 if (QDF_IS_STATUS_ERROR(err)) {
6970 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6971 wmi_buf_free(buf);
6972 return QDF_STATUS_E_FAILURE;
6973 }
6974
6975 return QDF_STATUS_SUCCESS;
6976}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306977
6978/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306979 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6980 * @wmi_handle: wmi handle
6981 * @roam_req: Request which contains the filters
6982 *
6983 * There are filters such as whitelist, blacklist and preferred
6984 * list that need to be applied to the scan results to form the
6985 * probable candidates for roaming.
6986 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006987 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306988 * parameters to the firmware, otherwise failure.
6989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306990static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306991 struct roam_scan_filter_params *roam_req)
6992{
6993 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306994 QDF_STATUS status;
6995 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306996 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306997 uint8_t *buf_ptr;
6998 wmi_roam_filter_fixed_param *roam_filter;
6999 uint8_t *bssid_src_ptr = NULL;
7000 wmi_mac_addr *bssid_dst_ptr = NULL;
7001 wmi_ssid *ssid_ptr = NULL;
7002 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307003 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307004 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307005
7006 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307007
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307008 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05307009 if (roam_req->num_bssid_black_list)
7010 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
7011 len += WMI_TLV_HDR_SIZE;
7012 if (roam_req->num_ssid_white_list)
7013 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
7014 len += 2 * WMI_TLV_HDR_SIZE;
7015 if (roam_req->num_bssid_preferred_list) {
7016 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05307017 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307018 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307019 len += WMI_TLV_HDR_SIZE;
7020 if (roam_req->lca_disallow_config_present) {
7021 len += sizeof(*blist_param);
7022 blist_len = sizeof(*blist_param);
7023 }
7024
7025 len += WMI_TLV_HDR_SIZE;
7026 if (roam_req->num_rssi_rejection_ap)
7027 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307028
7029 buf = wmi_buf_alloc(wmi_handle, len);
7030 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307031 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307032 return QDF_STATUS_E_NOMEM;
7033 }
7034
7035 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7036 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
7037 WMITLV_SET_HDR(&roam_filter->tlv_header,
7038 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7039 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7040 /* fill in fixed values */
7041 roam_filter->vdev_id = roam_req->session_id;
7042 roam_filter->flags = 0;
7043 roam_filter->op_bitmap = roam_req->op_bitmap;
7044 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7045 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7046 roam_filter->num_bssid_preferred_list =
7047 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307048 roam_filter->num_rssi_rejection_ap =
7049 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307050 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7051
7052 WMITLV_SET_HDR((buf_ptr),
7053 WMITLV_TAG_ARRAY_FIXED_STRUC,
7054 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7055 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7056 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7057 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7058 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7059 bssid_src_ptr += ATH_MAC_LEN;
7060 bssid_dst_ptr++;
7061 }
7062 buf_ptr += WMI_TLV_HDR_SIZE +
7063 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7064 WMITLV_SET_HDR((buf_ptr),
7065 WMITLV_TAG_ARRAY_FIXED_STRUC,
7066 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7067 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7068 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7069 qdf_mem_copy(&ssid_ptr->ssid,
7070 &roam_req->ssid_allowed_list[i].mac_ssid,
7071 roam_req->ssid_allowed_list[i].length);
7072 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7073 ssid_ptr++;
7074 }
7075 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7076 sizeof(wmi_ssid));
7077 WMITLV_SET_HDR((buf_ptr),
7078 WMITLV_TAG_ARRAY_FIXED_STRUC,
7079 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7080 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7081 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7082 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7083 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7084 (wmi_mac_addr *)bssid_dst_ptr);
7085 bssid_src_ptr += ATH_MAC_LEN;
7086 bssid_dst_ptr++;
7087 }
7088 buf_ptr += WMI_TLV_HDR_SIZE +
7089 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7090 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7091 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7092 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7093 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7094 *bssid_preferred_factor_ptr =
7095 roam_req->bssid_favored_factor[i];
7096 bssid_preferred_factor_ptr++;
7097 }
7098 buf_ptr += WMI_TLV_HDR_SIZE +
7099 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7100
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307101 WMITLV_SET_HDR(buf_ptr,
7102 WMITLV_TAG_ARRAY_STRUC, blist_len);
7103 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307104 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307105 blist_param =
7106 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7107 WMITLV_SET_HDR(&blist_param->tlv_header,
7108 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7109 WMITLV_GET_STRUCT_TLVLEN(
7110 wmi_roam_lca_disallow_config_tlv_param));
7111
7112 blist_param->disallow_duration = roam_req->disallow_duration;
7113 blist_param->rssi_channel_penalization =
7114 roam_req->rssi_channel_penalization;
7115 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307116 blist_param->disallow_lca_enable_source_bitmap =
7117 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7118 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307119 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7120 }
7121
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307122 WMITLV_SET_HDR(buf_ptr,
7123 WMITLV_TAG_ARRAY_STRUC,
7124 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7125 buf_ptr += WMI_TLV_HDR_SIZE;
7126 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7127 rssi_rej =
7128 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7129 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7130 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7131 WMITLV_GET_STRUCT_TLVLEN(
7132 wmi_roam_rssi_rejection_oce_config_param));
7133 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7134 roam_req->rssi_rejection_ap[i].bssid.bytes,
7135 &rssi_rej->bssid);
7136 rssi_rej->remaining_disallow_duration =
7137 roam_req->rssi_rejection_ap[i].remaining_duration;
7138 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307139 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307140 buf_ptr +=
7141 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7142 }
7143
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307144 status = wmi_unified_cmd_send(wmi_handle, buf,
7145 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307146 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307147 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307148 status);
7149 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307150 }
Govind Singh67922e82016-04-01 16:48:57 +05307151
7152 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307153}
7154
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307155#if defined(WLAN_FEATURE_FILS_SK)
7156static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7157 struct hlp_params *params)
7158{
7159 uint32_t len;
7160 uint8_t *buf_ptr;
7161 wmi_buf_t buf = NULL;
7162 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7163
7164 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7165 len += WMI_TLV_HDR_SIZE;
7166 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7167
7168 buf = wmi_buf_alloc(wmi_handle, len);
7169 if (!buf) {
7170 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7171 return QDF_STATUS_E_NOMEM;
7172 }
7173
7174 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7175 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7176 WMITLV_SET_HDR(&hlp_params->tlv_header,
7177 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7178 WMITLV_GET_STRUCT_TLVLEN(
7179 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7180
7181 hlp_params->vdev_id = params->vdev_id;
7182 hlp_params->size = params->hlp_ie_len;
7183 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7184
7185 buf_ptr += sizeof(*hlp_params);
7186
7187 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7188 round_up(params->hlp_ie_len,
7189 sizeof(uint32_t)));
7190 buf_ptr += WMI_TLV_HDR_SIZE;
7191 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7192
7193 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7194 hlp_params->vdev_id, hlp_params->size);
7195 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7196 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7197 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7198 wmi_buf_free(buf);
7199 return QDF_STATUS_E_FAILURE;
7200 }
7201
7202 return QDF_STATUS_SUCCESS;
7203}
7204#endif
7205
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307206#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307207/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7208 * @wmi_handle: wmi handle
7209 * @ipa_offload: ipa offload control parameter
7210 *
7211 * Returns: 0 on success, error number otherwise
7212 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307213static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307214 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215{
7216 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7217 wmi_buf_t wmi_buf;
7218 uint32_t len;
7219 u_int8_t *buf_ptr;
7220
7221 len = sizeof(*cmd);
7222 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7223 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7225 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226 }
7227
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007228 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307229 ipa_offload->offload_type, ipa_offload->enable);
7230
7231 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7232
7233 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7234 WMITLV_SET_HDR(&cmd->tlv_header,
7235 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7236 WMITLV_GET_STRUCT_TLVLEN(
7237 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7238
7239 cmd->offload_type = ipa_offload->offload_type;
7240 cmd->vdev_id = ipa_offload->vdev_id;
7241 cmd->enable = ipa_offload->enable;
7242
7243 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7244 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307245 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307246 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307247 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248 }
7249
Govind Singhb53420c2016-03-09 14:32:57 +05307250 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307251}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307252#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307253
7254/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307255 * send_plm_stop_cmd_tlv() - plm stop request
7256 * @wmi_handle: wmi handle
7257 * @plm: plm request parameters
7258 *
7259 * This function request FW to stop PLM.
7260 *
7261 * Return: CDF status
7262 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307263static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307264 const struct plm_req_params *plm)
7265{
7266 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7267 int32_t len;
7268 wmi_buf_t buf;
7269 uint8_t *buf_ptr;
7270 int ret;
7271
7272 len = sizeof(*cmd);
7273 buf = wmi_buf_alloc(wmi_handle, len);
7274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307275 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7276 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307277 }
7278
7279 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7280
7281 buf_ptr = (uint8_t *) cmd;
7282
7283 WMITLV_SET_HDR(&cmd->tlv_header,
7284 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7285 WMITLV_GET_STRUCT_TLVLEN
7286 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7287
7288 cmd->vdev_id = plm->session_id;
7289
7290 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307291 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307292
7293 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7294 WMI_VDEV_PLMREQ_STOP_CMDID);
7295 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307296 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307297 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307298 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307299 }
7300
Govind Singhb53420c2016-03-09 14:32:57 +05307301 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307302}
7303
7304/**
7305 * send_plm_start_cmd_tlv() - plm start request
7306 * @wmi_handle: wmi handle
7307 * @plm: plm request parameters
7308 *
7309 * This function request FW to start PLM.
7310 *
7311 * Return: CDF status
7312 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307313static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307314 const struct plm_req_params *plm,
7315 uint32_t *gchannel_list)
7316{
7317 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7318 uint32_t *channel_list;
7319 int32_t len;
7320 wmi_buf_t buf;
7321 uint8_t *buf_ptr;
7322 uint8_t count;
7323 int ret;
7324
7325 /* TLV place holder for channel_list */
7326 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7327 len += sizeof(uint32_t) * plm->plm_num_ch;
7328
7329 buf = wmi_buf_alloc(wmi_handle, len);
7330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307331 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7332 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307333 }
7334 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7335
7336 buf_ptr = (uint8_t *) cmd;
7337
7338 WMITLV_SET_HDR(&cmd->tlv_header,
7339 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7340 WMITLV_GET_STRUCT_TLVLEN
7341 (wmi_vdev_plmreq_start_cmd_fixed_param));
7342
7343 cmd->vdev_id = plm->session_id;
7344
7345 cmd->meas_token = plm->meas_token;
7346 cmd->dialog_token = plm->diag_token;
7347 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307348 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307349 cmd->off_duration = plm->meas_duration;
7350 cmd->burst_cycle = plm->burst_len;
7351 cmd->tx_power = plm->desired_tx_pwr;
7352 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7353 cmd->num_chans = plm->plm_num_ch;
7354
7355 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7356
Govind Singhb53420c2016-03-09 14:32:57 +05307357 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7358 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7359 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7360 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7361 WMI_LOGD("off_duration: %d", cmd->off_duration);
7362 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7363 WMI_LOGD("tx_power: %d", cmd->tx_power);
7364 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307365
7366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7367 (cmd->num_chans * sizeof(uint32_t)));
7368
7369 buf_ptr += WMI_TLV_HDR_SIZE;
7370 if (cmd->num_chans) {
7371 channel_list = (uint32_t *) buf_ptr;
7372 for (count = 0; count < cmd->num_chans; count++) {
7373 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307374 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307375 channel_list[count] =
7376 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307377 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307378 }
7379 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7380 }
7381
7382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7383 WMI_VDEV_PLMREQ_START_CMDID);
7384 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307385 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307386 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307387 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307388 }
7389
Govind Singhb53420c2016-03-09 14:32:57 +05307390 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307391}
7392
7393/**
7394 * send_pno_stop_cmd_tlv() - PNO stop request
7395 * @wmi_handle: wmi handle
7396 * @vdev_id: vdev id
7397 *
7398 * This function request FW to stop ongoing PNO operation.
7399 *
7400 * Return: CDF status
7401 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307402static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307403{
7404 wmi_nlo_config_cmd_fixed_param *cmd;
7405 int32_t len = sizeof(*cmd);
7406 wmi_buf_t buf;
7407 uint8_t *buf_ptr;
7408 int ret;
7409
7410 /*
7411 * TLV place holder for array of structures nlo_configured_parameters
7412 * TLV place holder for array of uint32_t channel_list
7413 * TLV place holder for chnl prediction cfg
7414 */
7415 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7416 buf = wmi_buf_alloc(wmi_handle, len);
7417 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307418 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7419 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307420 }
7421
7422 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7423 buf_ptr = (uint8_t *) cmd;
7424
7425 WMITLV_SET_HDR(&cmd->tlv_header,
7426 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7427 WMITLV_GET_STRUCT_TLVLEN
7428 (wmi_nlo_config_cmd_fixed_param));
7429
7430 cmd->vdev_id = vdev_id;
7431 cmd->flags = WMI_NLO_CONFIG_STOP;
7432 buf_ptr += sizeof(*cmd);
7433
7434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7435 buf_ptr += WMI_TLV_HDR_SIZE;
7436
7437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7438 buf_ptr += WMI_TLV_HDR_SIZE;
7439
7440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7441 buf_ptr += WMI_TLV_HDR_SIZE;
7442
7443
7444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7445 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7446 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307447 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307448 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307449 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307450 }
7451
Govind Singhb53420c2016-03-09 14:32:57 +05307452 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307453}
7454
7455/**
Govind Singhccb0c272016-04-01 16:30:08 +05307456 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7457 * @buf_ptr: Buffer passed by upper layers
7458 * @pno: Buffer to be sent to the firmware
7459 *
7460 * Copy the PNO Channel prediction configuration parameters
7461 * passed by the upper layers to a WMI format TLV and send it
7462 * down to the firmware.
7463 *
7464 * Return: None
7465 */
7466static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7467 struct pno_scan_req_params *pno)
7468{
7469 nlo_channel_prediction_cfg *channel_prediction_cfg =
7470 (nlo_channel_prediction_cfg *) buf_ptr;
7471 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7472 WMITLV_TAG_ARRAY_BYTE,
7473 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307474#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307475 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7476 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7477 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7478 channel_prediction_cfg->full_scan_period_ms =
7479 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307480#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307481 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7482 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7483 channel_prediction_cfg->enable,
7484 channel_prediction_cfg->top_k_num,
7485 channel_prediction_cfg->stationary_threshold,
7486 channel_prediction_cfg->full_scan_period_ms);
7487}
7488
7489/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007490 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7491 * @wmi_handle: wmi handle
7492 * @params: configuration parameters
7493 *
7494 * Return: QDF_STATUS
7495 */
7496static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7497 struct nlo_mawc_params *params)
7498{
7499 wmi_buf_t buf = NULL;
7500 QDF_STATUS status;
7501 int len;
7502 uint8_t *buf_ptr;
7503 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7504
7505 len = sizeof(*wmi_nlo_mawc_params);
7506 buf = wmi_buf_alloc(wmi_handle, len);
7507 if (!buf) {
7508 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7509 return QDF_STATUS_E_NOMEM;
7510 }
7511
7512 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7513 wmi_nlo_mawc_params =
7514 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7515 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7516 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7517 WMITLV_GET_STRUCT_TLVLEN
7518 (wmi_nlo_configure_mawc_cmd_fixed_param));
7519 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7520 if (params->enable)
7521 wmi_nlo_mawc_params->enable = 1;
7522 else
7523 wmi_nlo_mawc_params->enable = 0;
7524 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7525 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7526 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007527 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7528 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7529 wmi_nlo_mawc_params->exp_backoff_ratio,
7530 wmi_nlo_mawc_params->init_scan_interval,
7531 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007532
7533 status = wmi_unified_cmd_send(wmi_handle, buf,
7534 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7535 if (QDF_IS_STATUS_ERROR(status)) {
7536 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7537 status);
7538 wmi_buf_free(buf);
7539 return QDF_STATUS_E_FAILURE;
7540 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007541
7542 return QDF_STATUS_SUCCESS;
7543}
7544
7545/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307546 * send_pno_start_cmd_tlv() - PNO start request
7547 * @wmi_handle: wmi handle
7548 * @pno: PNO request
7549 *
7550 * This function request FW to start PNO request.
7551 * Request: CDF status
7552 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307553static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307554 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307555{
7556 wmi_nlo_config_cmd_fixed_param *cmd;
7557 nlo_configured_parameters *nlo_list;
7558 uint32_t *channel_list;
7559 int32_t len;
7560 wmi_buf_t buf;
7561 uint8_t *buf_ptr;
7562 uint8_t i;
7563 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307564 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307565 connected_nlo_rssi_params *nlo_relative_rssi;
7566 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307567
7568 /*
7569 * TLV place holder for array nlo_configured_parameters(nlo_list)
7570 * TLV place holder for array of uint32_t channel_list
7571 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307572 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307573 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307574 */
7575 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307576 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307577 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307578
Abhishek Singh5987b632017-03-03 22:09:07 +05307579 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307580 WMI_NLO_MAX_CHAN);
7581 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307582 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307583 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307584 len += sizeof(enlo_candidate_score_params);
7585 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307586 len += sizeof(connected_nlo_rssi_params);
7587 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307588
7589 buf = wmi_buf_alloc(wmi_handle, len);
7590 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307591 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7592 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307593 }
7594
7595 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7596
7597 buf_ptr = (uint8_t *) cmd;
7598 WMITLV_SET_HDR(&cmd->tlv_header,
7599 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7600 WMITLV_GET_STRUCT_TLVLEN
7601 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307602 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307603 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7604
Govind Singh87542482016-06-08 19:40:11 +05307605#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307606 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307607 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307608#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307609 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307610 cmd->active_dwell_time = pno->active_dwell_time;
7611 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307612
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307613 if (pno->do_passive_scan)
7614 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307615 /* Copy scan interval */
7616 cmd->fast_scan_period = pno->fast_scan_period;
7617 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007618 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307619 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007620 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307621 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307622 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307623 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307624
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307625 /* mac randomization attributes */
7626 if (pno->scan_random.randomize) {
7627 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7628 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7629 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7630 pno->scan_random.mac_mask,
7631 &cmd->mac_addr,
7632 &cmd->mac_mask);
7633 }
7634
Govind Singh4eacd2b2016-03-07 14:24:22 +05307635 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7636
Abhishek Singh5987b632017-03-03 22:09:07 +05307637 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307638 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7640 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7641 buf_ptr += WMI_TLV_HDR_SIZE;
7642
7643 nlo_list = (nlo_configured_parameters *) buf_ptr;
7644 for (i = 0; i < cmd->no_of_ssids; i++) {
7645 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7646 WMITLV_TAG_ARRAY_BYTE,
7647 WMITLV_GET_STRUCT_TLVLEN
7648 (nlo_configured_parameters));
7649 /* Copy ssid and it's length */
7650 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307651 nlo_list[i].ssid.ssid.ssid_len =
7652 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307653 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307654 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307655 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307656 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307657 nlo_list[i].ssid.ssid.ssid_len,
7658 (char *)nlo_list[i].ssid.ssid.ssid,
7659 nlo_list[i].ssid.ssid.ssid_len);
7660
7661 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307662 if (pno->networks_list[i].rssi_thresh &&
7663 pno->networks_list[i].rssi_thresh >
7664 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307665 nlo_list[i].rssi_cond.valid = true;
7666 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307667 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307668 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307669 nlo_list[i].rssi_cond.rssi);
7670 }
7671 nlo_list[i].bcast_nw_type.valid = true;
7672 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307673 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007674 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307675 nlo_list[i].bcast_nw_type.bcast_nw_type);
7676 }
7677 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7678
7679 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307680 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307681 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307683 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7684 (cmd->num_of_channels * sizeof(uint32_t)));
7685 buf_ptr += WMI_TLV_HDR_SIZE;
7686
7687 channel_list = (uint32_t *) buf_ptr;
7688 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307689 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307690
7691 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307692 channel_list[i] =
7693 wlan_chan_to_freq(pno->
7694 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307695
Govind Singhb53420c2016-03-09 14:32:57 +05307696 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307697 }
7698 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7700 sizeof(nlo_channel_prediction_cfg));
7701 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307702 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307703 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307704 /** TODO: Discrete firmware doesn't have command/option to configure
7705 * App IE which comes from wpa_supplicant as of part PNO start request.
7706 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307707 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7708 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7709 buf_ptr += sizeof(enlo_candidate_score_params);
7710
7711 if (ie_whitelist->white_list) {
7712 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7713 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7714 &cmd->num_vendor_oui,
7715 ie_whitelist);
7716 }
7717
7718 /* ie white list */
7719 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7720 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7721 buf_ptr += WMI_TLV_HDR_SIZE;
7722 if (cmd->num_vendor_oui != 0) {
7723 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7724 ie_whitelist->voui);
7725 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7726 }
7727
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307728 if (pno->relative_rssi_set)
7729 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7730
7731 /*
7732 * Firmware calculation using connected PNO params:
7733 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7734 * deduction of rssi_pref for chosen band_pref and
7735 * addition of rssi_pref for remaining bands (other than chosen band).
7736 */
7737 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7738 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7739 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7740 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7741 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7742 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7743 buf_ptr += sizeof(*nlo_relative_rssi);
7744
7745 /*
7746 * As of now Kernel and Host supports one band and rssi preference.
7747 * Firmware supports array of band and rssi preferences
7748 */
7749 cmd->num_cnlo_band_pref = 1;
7750 WMITLV_SET_HDR(buf_ptr,
7751 WMITLV_TAG_ARRAY_STRUC,
7752 cmd->num_cnlo_band_pref *
7753 sizeof(connected_nlo_bss_band_rssi_pref));
7754 buf_ptr += WMI_TLV_HDR_SIZE;
7755
7756 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7757 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7758 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7759 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7760 WMITLV_GET_STRUCT_TLVLEN(
7761 connected_nlo_bss_band_rssi_pref));
7762 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7763 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7764 WMI_LOGI("band_pref %d, rssi_pref %d",
7765 nlo_band_rssi[i].band,
7766 nlo_band_rssi[i].rssi_pref);
7767 }
7768 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7769
Govind Singh4eacd2b2016-03-07 14:24:22 +05307770 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7771 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7772 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307773 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307774 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307775 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307776 }
7777
Govind Singhb53420c2016-03-09 14:32:57 +05307778 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307779}
7780
7781/* send_set_ric_req_cmd_tlv() - set ric request element
7782 * @wmi_handle: wmi handle
7783 * @msg: message
7784 * @is_add_ts: is addts required
7785 *
7786 * This function sets ric request element for 11r roaming.
7787 *
7788 * Return: CDF status
7789 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307790static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307791 void *msg, uint8_t is_add_ts)
7792{
7793 wmi_ric_request_fixed_param *cmd;
7794 wmi_ric_tspec *tspec_param;
7795 wmi_buf_t buf;
7796 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307797 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307798 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7799 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7800
7801 buf = wmi_buf_alloc(wmi_handle, len);
7802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307803 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7804 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307805 }
7806
7807 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7808
7809 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7810 WMITLV_SET_HDR(&cmd->tlv_header,
7811 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7812 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7813 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007814 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307815 else
7816 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7817 cmd->num_ric_request = 1;
7818 cmd->is_add_ric = is_add_ts;
7819
7820 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7822
7823 buf_ptr += WMI_TLV_HDR_SIZE;
7824 tspec_param = (wmi_ric_tspec *) buf_ptr;
7825 WMITLV_SET_HDR(&tspec_param->tlv_header,
7826 WMITLV_TAG_STRUC_wmi_ric_tspec,
7827 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7828
7829 if (is_add_ts)
7830 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307831#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307832 else
7833 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307834#endif
7835 if (ptspecIE) {
7836 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307837#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307838 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7839 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307840#else
Govind Singh87542482016-06-08 19:40:11 +05307841 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7842 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307843#endif /* ANI_LITTLE_BIT_ENDIAN */
7844
Govind Singh87542482016-06-08 19:40:11 +05307845 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7846 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7847 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7848 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7849 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7850 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7851 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7852 tspec_param->min_data_rate = ptspecIE->minDataRate;
7853 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7854 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7855 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7856 tspec_param->delay_bound = ptspecIE->delayBound;
7857 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7858 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7859 tspec_param->medium_time = 0;
7860 }
Govind Singhb53420c2016-03-09 14:32:57 +05307861 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307862
7863 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7864 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307865 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307866 __func__);
7867 if (is_add_ts)
7868 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307869 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307870 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307871 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307872 }
7873
Govind Singhb53420c2016-03-09 14:32:57 +05307874 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307875}
7876
Qiwei Cai1ccba222018-05-21 16:49:39 +08007877#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307878/**
7879 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7880 * @wmi_handle: wmi handle
7881 * @clear_req: ll stats clear request command params
7882 *
Govind Singhb53420c2016-03-09 14:32:57 +05307883 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307884 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307885static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307886 const struct ll_stats_clear_params *clear_req,
7887 uint8_t addr[IEEE80211_ADDR_LEN])
7888{
7889 wmi_clear_link_stats_cmd_fixed_param *cmd;
7890 int32_t len;
7891 wmi_buf_t buf;
7892 uint8_t *buf_ptr;
7893 int ret;
7894
7895 len = sizeof(*cmd);
7896 buf = wmi_buf_alloc(wmi_handle, len);
7897
7898 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307899 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7900 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307901 }
7902
7903 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307904 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307905 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7906
7907 WMITLV_SET_HDR(&cmd->tlv_header,
7908 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7909 WMITLV_GET_STRUCT_TLVLEN
7910 (wmi_clear_link_stats_cmd_fixed_param));
7911
7912 cmd->stop_stats_collection_req = clear_req->stop_req;
7913 cmd->vdev_id = clear_req->sta_id;
7914 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7915
7916 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7917 &cmd->peer_macaddr);
7918
Govind Singhb53420c2016-03-09 14:32:57 +05307919 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7920 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7921 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7922 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7923 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307924 cmd->peer_macaddr); */
7925
7926 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7927 WMI_CLEAR_LINK_STATS_CMDID);
7928 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307929 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307930 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307931 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307932 }
7933
Govind Singhb53420c2016-03-09 14:32:57 +05307934 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7935 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307936}
7937
7938/**
7939 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7940 * @wmi_handle: wmi handle
7941 * @setReq: ll stats set request command params
7942 *
Govind Singhb53420c2016-03-09 14:32:57 +05307943 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307944 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307945static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307946 const struct ll_stats_set_params *set_req)
7947{
7948 wmi_start_link_stats_cmd_fixed_param *cmd;
7949 int32_t len;
7950 wmi_buf_t buf;
7951 uint8_t *buf_ptr;
7952 int ret;
7953
7954 len = sizeof(*cmd);
7955 buf = wmi_buf_alloc(wmi_handle, len);
7956
7957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307958 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7959 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307960 }
7961
7962 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307963 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307964 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7965
7966 WMITLV_SET_HDR(&cmd->tlv_header,
7967 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7968 WMITLV_GET_STRUCT_TLVLEN
7969 (wmi_start_link_stats_cmd_fixed_param));
7970
7971 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7972 cmd->aggressive_statistics_gathering =
7973 set_req->aggressive_statistics_gathering;
7974
Govind Singhb53420c2016-03-09 14:32:57 +05307975 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7976 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7977 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307978
7979 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7980 WMI_START_LINK_STATS_CMDID);
7981 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307982 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307983 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307984 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307985 }
7986
Govind Singhb53420c2016-03-09 14:32:57 +05307987 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307988}
7989
7990/**
7991 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7992 * @wmi_handle:wmi handle
7993 * @get_req:ll stats get request command params
7994 * @addr: mac address
7995 *
Govind Singhb53420c2016-03-09 14:32:57 +05307996 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307997 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307998static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307999 const struct ll_stats_get_params *get_req,
8000 uint8_t addr[IEEE80211_ADDR_LEN])
8001{
8002 wmi_request_link_stats_cmd_fixed_param *cmd;
8003 int32_t len;
8004 wmi_buf_t buf;
8005 uint8_t *buf_ptr;
8006 int ret;
8007
8008 len = sizeof(*cmd);
8009 buf = wmi_buf_alloc(wmi_handle, len);
8010
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308011 if (!buf) {
8012 WMI_LOGE("%s: buf allocation failed", __func__);
8013 return QDF_STATUS_E_NOMEM;
8014 }
8015
Govind Singh4eacd2b2016-03-07 14:24:22 +05308016 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308017 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308018 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8019
8020 WMITLV_SET_HDR(&cmd->tlv_header,
8021 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8022 WMITLV_GET_STRUCT_TLVLEN
8023 (wmi_request_link_stats_cmd_fixed_param));
8024
8025 cmd->request_id = get_req->req_id;
8026 cmd->stats_type = get_req->param_id_mask;
8027 cmd->vdev_id = get_req->sta_id;
8028
8029 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8030 &cmd->peer_macaddr);
8031
Govind Singhb53420c2016-03-09 14:32:57 +05308032 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008033 WMI_LOGD("Request ID : %u", cmd->request_id);
8034 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308035 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8036 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308037
8038 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8039 WMI_REQUEST_LINK_STATS_CMDID);
8040 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308041 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308042 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308043 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308044 }
8045
Govind Singhb53420c2016-03-09 14:32:57 +05308046 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308047}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008048#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308049
Govind Singh20c5dac2016-03-07 15:33:31 +05308050/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308051 * send_congestion_cmd_tlv() - send request to fw to get CCA
8052 * @wmi_handle: wmi handle
8053 * @vdev_id: vdev id
8054 *
8055 * Return: CDF status
8056 */
8057static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308058 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308059{
8060 wmi_buf_t buf;
8061 wmi_request_stats_cmd_fixed_param *cmd;
8062 uint8_t len;
8063 uint8_t *buf_ptr;
8064
8065 len = sizeof(*cmd);
8066 buf = wmi_buf_alloc(wmi_handle, len);
8067 if (!buf) {
8068 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8069 return QDF_STATUS_E_FAILURE;
8070 }
8071
8072 buf_ptr = wmi_buf_data(buf);
8073 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8074 WMITLV_SET_HDR(&cmd->tlv_header,
8075 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8076 WMITLV_GET_STRUCT_TLVLEN
8077 (wmi_request_stats_cmd_fixed_param));
8078
8079 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8080 cmd->vdev_id = vdev_id;
8081 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8082 cmd->vdev_id, cmd->stats_id);
8083
8084 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8085 WMI_REQUEST_STATS_CMDID)) {
8086 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8087 __func__);
8088 wmi_buf_free(buf);
8089 return QDF_STATUS_E_FAILURE;
8090 }
8091
8092 return QDF_STATUS_SUCCESS;
8093}
8094
8095/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308096 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8097 * @wmi_handle: wmi handle
8098 * @rssi_req: get RSSI request
8099 *
8100 * Return: CDF status
8101 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308102static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308103{
8104 wmi_buf_t buf;
8105 wmi_request_stats_cmd_fixed_param *cmd;
8106 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8107
8108 buf = wmi_buf_alloc(wmi_handle, len);
8109 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308110 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8111 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308112 }
8113
8114 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8115 WMITLV_SET_HDR(&cmd->tlv_header,
8116 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8117 WMITLV_GET_STRUCT_TLVLEN
8118 (wmi_request_stats_cmd_fixed_param));
8119 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8120 if (wmi_unified_cmd_send
8121 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308122 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308123 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308124 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 }
8126
Govind Singhb53420c2016-03-09 14:32:57 +05308127 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308128}
8129
8130/**
8131 * send_snr_cmd_tlv() - get RSSI from fw
8132 * @wmi_handle: wmi handle
8133 * @vdev_id: vdev id
8134 *
8135 * Return: CDF status
8136 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308137static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308138{
8139 wmi_buf_t buf;
8140 wmi_request_stats_cmd_fixed_param *cmd;
8141 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8142
8143 buf = wmi_buf_alloc(wmi_handle, len);
8144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308145 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8146 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308147 }
8148
8149 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8150 cmd->vdev_id = vdev_id;
8151
8152 WMITLV_SET_HDR(&cmd->tlv_header,
8153 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8154 WMITLV_GET_STRUCT_TLVLEN
8155 (wmi_request_stats_cmd_fixed_param));
8156 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8157 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8158 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308159 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308160 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308161 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308162 }
8163
Govind Singhb53420c2016-03-09 14:32:57 +05308164 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308165}
8166
8167/**
8168 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8169 * @wmi_handle: wmi handle
8170 * @link_status: get link params
8171 *
8172 * Return: CDF status
8173 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308174static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308175 struct link_status_params *link_status)
8176{
8177 wmi_buf_t buf;
8178 wmi_request_stats_cmd_fixed_param *cmd;
8179 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8180
8181 buf = wmi_buf_alloc(wmi_handle, len);
8182 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308183 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8184 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308185 }
8186
8187 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8188 WMITLV_SET_HDR(&cmd->tlv_header,
8189 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8190 WMITLV_GET_STRUCT_TLVLEN
8191 (wmi_request_stats_cmd_fixed_param));
8192 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8193 cmd->vdev_id = link_status->session_id;
8194 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8195 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308196 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308197 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308198 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308199 }
8200
Govind Singhb53420c2016-03-09 14:32:57 +05308201 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308202}
8203
Govind Singh20c5dac2016-03-07 15:33:31 +05308204/**
8205 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8206 * @wmi_handle: wmi handle
8207 * @ta_dhcp_ind: DHCP indication parameter
8208 *
8209 * Return: CDF Status
8210 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308211static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308212 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8213{
Govind Singh67922e82016-04-01 16:48:57 +05308214 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308215 wmi_buf_t buf = NULL;
8216 uint8_t *buf_ptr;
8217 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8218 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8219
8220
8221 buf = wmi_buf_alloc(wmi_handle, len);
8222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308223 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8224 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308225 }
8226
8227 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8228 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8229 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8230 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8231 WMITLV_GET_STRUCT_TLVLEN
8232 (wmi_peer_set_param_cmd_fixed_param));
8233
8234 /* fill in values */
8235 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8236 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8237 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308238 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308239 &ta_dhcp_ind->peer_macaddr,
8240 sizeof(ta_dhcp_ind->peer_macaddr));
8241
8242 status = wmi_unified_cmd_send(wmi_handle, buf,
8243 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308244 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308245 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308246 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308247 wmi_buf_free(buf);
8248 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308249
Govind Singh67922e82016-04-01 16:48:57 +05308250 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308251}
8252
8253/**
8254 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8255 * @wmi_handle: wmi handle
8256 * @pLinkSpeed: link speed info
8257 *
8258 * Return: CDF status
8259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308260static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308261 wmi_mac_addr peer_macaddr)
8262{
8263 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8264 wmi_buf_t wmi_buf;
8265 uint32_t len;
8266 uint8_t *buf_ptr;
8267
8268 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8269 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8270 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308271 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8272 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 }
8274 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8275
8276 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8277 WMITLV_SET_HDR(&cmd->tlv_header,
8278 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8279 WMITLV_GET_STRUCT_TLVLEN
8280 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8281
8282 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308283 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308284 &peer_macaddr,
8285 sizeof(peer_macaddr));
8286
8287
8288 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8289 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308290 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308291 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308292 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308293 }
Govind Singhb53420c2016-03-09 14:32:57 +05308294 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308295}
8296
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308297#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308298/**
8299 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8300 * @wmi_handle: wmi handler
8301 * @egap_params: pointer to egap_params
8302 *
8303 * Return: 0 for success, otherwise appropriate error code
8304 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308305static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308306 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308307{
8308 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8309 wmi_buf_t buf;
8310 int32_t err;
8311
8312 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8313 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308314 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8315 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308316 }
8317 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8318 WMITLV_SET_HDR(&cmd->tlv_header,
8319 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8320 WMITLV_GET_STRUCT_TLVLEN(
8321 wmi_ap_ps_egap_param_cmd_fixed_param));
8322
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308323 cmd->enable = egap_params->host_enable_egap;
8324 cmd->inactivity_time = egap_params->egap_inactivity_time;
8325 cmd->wait_time = egap_params->egap_wait_time;
8326 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308327 err = wmi_unified_cmd_send(wmi_handle, buf,
8328 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8329 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308330 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308331 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308332 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 }
8334
Govind Singhb53420c2016-03-09 14:32:57 +05308335 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308336}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308337#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308338
8339/**
8340 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8341 * @wmi_handl: wmi handle
8342 * @cmd: Profiling command index
8343 * @value1: parameter1 value
8344 * @value2: parameter2 value
8345 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308346 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308347 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308348static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308349 uint32_t cmd, uint32_t value1, uint32_t value2)
8350{
8351 wmi_buf_t buf;
8352 int32_t len = 0;
8353 int ret;
8354 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8355 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8356 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8357 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8358
8359 switch (cmd) {
8360 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8361 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8362 buf = wmi_buf_alloc(wmi_handle, len);
8363 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308364 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308365 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308366 }
8367 prof_trig_cmd =
8368 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8369 wmi_buf_data(buf);
8370 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8371 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8372 WMITLV_GET_STRUCT_TLVLEN
8373 (wmi_wlan_profile_trigger_cmd_fixed_param));
8374 prof_trig_cmd->enable = value1;
8375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8376 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8377 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308378 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308379 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308380 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308381 return ret;
8382 }
8383 break;
8384
8385 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8386 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8387 buf = wmi_buf_alloc(wmi_handle, len);
8388 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308389 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308390 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308391 }
8392 profile_getdata_cmd =
8393 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8394 wmi_buf_data(buf);
8395 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8396 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8397 WMITLV_GET_STRUCT_TLVLEN
8398 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8399 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8400 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8401 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308402 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308403 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308404 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308405 return ret;
8406 }
8407 break;
8408
8409 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8410 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8411 buf = wmi_buf_alloc(wmi_handle, len);
8412 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308413 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308414 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308415 }
8416 hist_intvl_cmd =
8417 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8418 wmi_buf_data(buf);
8419 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8420 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8421 WMITLV_GET_STRUCT_TLVLEN
8422 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8423 hist_intvl_cmd->profile_id = value1;
8424 hist_intvl_cmd->value = value2;
8425 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8426 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8427 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308428 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308429 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308430 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 return ret;
8432 }
8433 break;
8434
8435 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8436 len =
8437 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8438 buf = wmi_buf_alloc(wmi_handle, len);
8439 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308440 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308441 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308442 }
8443 profile_enable_cmd =
8444 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8445 wmi_buf_data(buf);
8446 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8447 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8448 WMITLV_GET_STRUCT_TLVLEN
8449 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8450 profile_enable_cmd->profile_id = value1;
8451 profile_enable_cmd->enable = value2;
8452 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8453 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8454 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308455 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308456 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308457 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308458 return ret;
8459 }
8460 break;
8461
8462 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308463 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308464 break;
8465 }
8466
8467 return 0;
8468}
8469
Paul Zhang92ab8d32017-12-08 16:08:00 +08008470static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8471 struct wlm_latency_level_param *params)
8472{
8473 wmi_wlm_config_cmd_fixed_param *cmd;
8474 wmi_buf_t buf;
8475 uint32_t len = sizeof(*cmd);
8476 static uint32_t ll[4] = {100, 60, 40, 20};
8477
8478 buf = wmi_buf_alloc(wmi_handle, len);
8479 if (!buf) {
8480 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8481 return QDF_STATUS_E_NOMEM;
8482 }
8483 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8484 WMITLV_SET_HDR(&cmd->tlv_header,
8485 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8486 WMITLV_GET_STRUCT_TLVLEN
8487 (wmi_wlm_config_cmd_fixed_param));
8488 cmd->vdev_id = params->vdev_id;
8489 cmd->latency_level = params->wlm_latency_level;
8490 cmd->ul_latency = ll[params->wlm_latency_level];
8491 cmd->dl_latency = ll[params->wlm_latency_level];
8492 cmd->flags = params->wlm_latency_flags;
8493 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8494 WMI_WLM_CONFIG_CMDID)) {
8495 WMI_LOGE("%s: Failed to send setting latency config command",
8496 __func__);
8497 wmi_buf_free(buf);
8498 return QDF_STATUS_E_FAILURE;
8499 }
8500
8501 return 0;
8502}
Govind Singh20c5dac2016-03-07 15:33:31 +05308503/**
8504 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8505 * @wmi_handle: wmi handle
8506 * @vdev_id: vdev id
8507 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308508 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308509 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308510static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308511{
8512 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8513 wmi_buf_t buf;
8514 int32_t len = sizeof(*cmd);
8515
Govind Singhb53420c2016-03-09 14:32:57 +05308516 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308517 buf = wmi_buf_alloc(wmi_handle, len);
8518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308519 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308520 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308521 }
8522 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8523 wmi_buf_data(buf);
8524 WMITLV_SET_HDR(&cmd->tlv_header,
8525 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8526 WMITLV_GET_STRUCT_TLVLEN
8527 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8528 cmd->vdev_id = vdev_id;
8529 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8530 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8531 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308532 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308533 __func__);
8534 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308535 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308536 }
8537
8538 return 0;
8539}
8540
8541/**
8542 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8543 * @wmi_handle: wmi handle
8544 * @vdev_id: vdev id
8545 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308546 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308547 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308548static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308549 uint8_t vdev_id)
8550{
8551 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8552 wmi_buf_t buf;
8553 int32_t len = sizeof(*cmd);
8554
Govind Singhb53420c2016-03-09 14:32:57 +05308555 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308556 buf = wmi_buf_alloc(wmi_handle, len);
8557 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308558 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308559 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 }
8561 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8562 WMITLV_SET_HDR(&cmd->tlv_header,
8563 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8564 WMITLV_GET_STRUCT_TLVLEN
8565 (wmi_csa_offload_enable_cmd_fixed_param));
8566 cmd->vdev_id = vdev_id;
8567 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8568 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8569 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308570 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308571 __func__);
8572 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308573 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308574 }
8575
8576 return 0;
8577}
8578
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008579#ifdef WLAN_FEATURE_CIF_CFR
8580/**
8581 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8582 * @wmi_handle: wmi handle
8583 * @data_len: len of dma cfg req
8584 * @data: dma cfg req
8585 *
8586 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8587 */
8588static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8589 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8590{
8591 wmi_buf_t buf;
8592 uint8_t *cmd;
8593 QDF_STATUS ret;
8594
8595 WMITLV_SET_HDR(cfg,
8596 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8597 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8598
8599 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8600 if (!buf) {
8601 WMI_LOGE(FL("wmi_buf_alloc failed"));
8602 return QDF_STATUS_E_FAILURE;
8603 }
8604
8605 cmd = (uint8_t *) wmi_buf_data(buf);
8606 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8607 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8608 sizeof(*cfg));
8609 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8610 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8611 if (QDF_IS_STATUS_ERROR(ret)) {
8612 WMI_LOGE(FL(":wmi cmd send failed"));
8613 wmi_buf_free(buf);
8614 }
8615
8616 return ret;
8617}
8618#endif
8619
Govind Singh20c5dac2016-03-07 15:33:31 +05308620/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308621 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8622 * @wmi_handle: wmi handle
8623 * @data_len: len of dma cfg req
8624 * @data: dma cfg req
8625 *
8626 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8627 */
8628static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8629 struct direct_buf_rx_cfg_req *cfg)
8630{
8631 wmi_buf_t buf;
8632 wmi_dma_ring_cfg_req_fixed_param *cmd;
8633 QDF_STATUS ret;
8634 int32_t len = sizeof(*cmd);
8635
8636 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8637 if (!buf) {
8638 WMI_LOGE(FL("wmi_buf_alloc failed"));
8639 return QDF_STATUS_E_FAILURE;
8640 }
8641
8642 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8643
8644 WMITLV_SET_HDR(&cmd->tlv_header,
8645 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8646 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8647
8648 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8649 cfg->pdev_id);
8650 cmd->mod_id = cfg->mod_id;
8651 cmd->base_paddr_lo = cfg->base_paddr_lo;
8652 cmd->base_paddr_hi = cfg->base_paddr_hi;
8653 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8654 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8655 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8656 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8657 cmd->num_elems = cfg->num_elems;
8658 cmd->buf_size = cfg->buf_size;
8659 cmd->num_resp_per_event = cfg->num_resp_per_event;
8660 cmd->event_timeout_ms = cfg->event_timeout_ms;
8661
8662 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8663 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8664 "head idx paddr hi %x tail idx paddr lo %x"
8665 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8666 "event timeout %d\n", __func__, cmd->pdev_id,
8667 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8668 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8669 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8670 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8671 cmd->event_timeout_ms);
8672 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8673 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8674 if (QDF_IS_STATUS_ERROR(ret)) {
8675 WMI_LOGE(FL(":wmi cmd send failed"));
8676 wmi_buf_free(buf);
8677 }
8678
8679 return ret;
8680}
8681
8682/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008683 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8684 * @wmi_handle: wmi handle
8685 * @start_11d_scan: 11d scan start request parameters
8686 *
8687 * This function request FW to start 11d scan.
8688 *
8689 * Return: QDF status
8690 */
8691static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8692 struct reg_start_11d_scan_req *start_11d_scan)
8693{
8694 wmi_11d_scan_start_cmd_fixed_param *cmd;
8695 int32_t len;
8696 wmi_buf_t buf;
8697 int ret;
8698
8699 len = sizeof(*cmd);
8700 buf = wmi_buf_alloc(wmi_handle, len);
8701 if (!buf) {
8702 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8703 return QDF_STATUS_E_NOMEM;
8704 }
8705
8706 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8707
8708 WMITLV_SET_HDR(&cmd->tlv_header,
8709 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8710 WMITLV_GET_STRUCT_TLVLEN
8711 (wmi_11d_scan_start_cmd_fixed_param));
8712
8713 cmd->vdev_id = start_11d_scan->vdev_id;
8714 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8715 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8716
8717 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8718
8719 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8720 WMI_11D_SCAN_START_CMDID);
8721 if (ret) {
8722 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8723 wmi_buf_free(buf);
8724 return QDF_STATUS_E_FAILURE;
8725 }
8726
8727 return QDF_STATUS_SUCCESS;
8728}
8729
8730/**
8731 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8732 * @wmi_handle: wmi handle
8733 * @start_11d_scan: 11d scan stop request parameters
8734 *
8735 * This function request FW to stop 11d scan.
8736 *
8737 * Return: QDF status
8738 */
8739static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8740 struct reg_stop_11d_scan_req *stop_11d_scan)
8741{
8742 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8743 int32_t len;
8744 wmi_buf_t buf;
8745 int ret;
8746
8747 len = sizeof(*cmd);
8748 buf = wmi_buf_alloc(wmi_handle, len);
8749 if (!buf) {
8750 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8751 return QDF_STATUS_E_NOMEM;
8752 }
8753
8754 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8755
8756 WMITLV_SET_HDR(&cmd->tlv_header,
8757 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8758 WMITLV_GET_STRUCT_TLVLEN
8759 (wmi_11d_scan_stop_cmd_fixed_param));
8760
8761 cmd->vdev_id = stop_11d_scan->vdev_id;
8762
8763 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8764
8765 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8766 WMI_11D_SCAN_STOP_CMDID);
8767 if (ret) {
8768 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8769 wmi_buf_free(buf);
8770 return QDF_STATUS_E_FAILURE;
8771 }
8772
8773 return QDF_STATUS_SUCCESS;
8774}
8775
8776/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308777 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8778 * @wmi_handle: wmi handle
8779 * @startOemDataReq: start request params
8780 *
8781 * Return: CDF status
8782 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308783static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008784 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308785 uint8_t *data)
8786{
8787 wmi_buf_t buf;
8788 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308789 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308790
8791 buf = wmi_buf_alloc(wmi_handle,
8792 (data_len + WMI_TLV_HDR_SIZE));
8793 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308794 WMI_LOGE(FL("wmi_buf_alloc failed"));
8795 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308796 }
8797
8798 cmd = (uint8_t *) wmi_buf_data(buf);
8799
8800 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8801 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308802 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308803 data_len);
8804
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008805 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308806 data_len);
8807
8808 ret = wmi_unified_cmd_send(wmi_handle, buf,
8809 (data_len +
8810 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8811
Govind Singh67922e82016-04-01 16:48:57 +05308812 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308813 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308814 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 }
8816
Govind Singh67922e82016-04-01 16:48:57 +05308817 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308818}
8819
8820/**
8821 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8822 * @wmi_handle: wmi handle
8823 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8824 *
8825 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8826 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8827 * to firmware based on phyerr filtering
8828 * offload status.
8829 *
8830 * Return: 1 success, 0 failure
8831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308832static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308833send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8834 bool dfs_phyerr_filter_offload)
8835{
8836 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8837 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8838 wmi_buf_t buf;
8839 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308840 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308841
8842
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008843 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308844 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308845 __func__);
8846 len = sizeof(*disable_phyerr_offload_cmd);
8847 buf = wmi_buf_alloc(wmi_handle, len);
8848 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308849 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308850 return 0;
8851 }
8852 disable_phyerr_offload_cmd =
8853 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8854 wmi_buf_data(buf);
8855
8856 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8857 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8858 WMITLV_GET_STRUCT_TLVLEN
8859 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8860
8861 /*
8862 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8863 * to the firmware to disable the phyerror
8864 * filtering offload.
8865 */
8866 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8867 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308868 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308869 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 __func__, ret);
8871 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308872 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308873 }
Govind Singhb53420c2016-03-09 14:32:57 +05308874 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308875 __func__);
8876 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 __func__);
8879
8880 len = sizeof(*enable_phyerr_offload_cmd);
8881 buf = wmi_buf_alloc(wmi_handle, len);
8882 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308883 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8884 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308885 }
8886
8887 enable_phyerr_offload_cmd =
8888 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8889 wmi_buf_data(buf);
8890
8891 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8892 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8893 WMITLV_GET_STRUCT_TLVLEN
8894 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8895
8896 /*
8897 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8898 * to the firmware to enable the phyerror
8899 * filtering offload.
8900 */
8901 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8902 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8903
Govind Singh67922e82016-04-01 16:48:57 +05308904 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308905 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308906 __func__, ret);
8907 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308908 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308909 }
Govind Singhb53420c2016-03-09 14:32:57 +05308910 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308911 __func__);
8912 }
8913
Govind Singhb53420c2016-03-09 14:32:57 +05308914 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308915}
8916
Naveen Rawata5817e72017-10-26 18:50:19 -07008917/**
8918 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8919 * will wake up host after specified time is elapsed
8920 * @wmi_handle: wmi handle
8921 * @vdev_id: vdev id
8922 * @cookie: value to identify reason why host set up wake call.
8923 * @time: time in ms
8924 *
8925 * Return: QDF status
8926 */
8927static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8928 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8929{
8930 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8931 wmi_buf_t buf;
8932 uint8_t *buf_ptr;
8933 int32_t len;
8934 int ret;
8935
8936 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8937 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8938 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8939 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8940 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308941 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8942 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008943
8944 buf = wmi_buf_alloc(wmi_handle, len);
8945 if (!buf) {
8946 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8947 return QDF_STATUS_E_NOMEM;
8948 }
8949
8950 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8951 buf_ptr = (uint8_t *) cmd;
8952
8953 WMITLV_SET_HDR(&cmd->tlv_header,
8954 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8955 WMITLV_GET_STRUCT_TLVLEN
8956 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8957 cmd->vdev_id = vdev_id;
8958 cmd->pattern_id = cookie,
8959 cmd->pattern_type = WOW_TIMER_PATTERN;
8960 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8961
8962 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8963 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8964 buf_ptr += WMI_TLV_HDR_SIZE;
8965
8966 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8968 buf_ptr += WMI_TLV_HDR_SIZE;
8969
8970 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8971 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8972 buf_ptr += WMI_TLV_HDR_SIZE;
8973
8974 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8975 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8976 buf_ptr += WMI_TLV_HDR_SIZE;
8977
8978 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008980 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308981 *((uint32_t *) buf_ptr) = time;
8982 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008983
8984 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308985 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008986 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308987 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008988
8989 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8990 __func__, time, vdev_id);
8991
8992 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8993 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8994 if (ret) {
8995 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
8996 __func__);
8997 wmi_buf_free(buf);
8998 return QDF_STATUS_E_FAILURE;
8999 }
9000
9001 return QDF_STATUS_SUCCESS;
9002}
9003
Govind Singh20c5dac2016-03-07 15:33:31 +05309004#if !defined(REMOVE_PKT_LOG)
9005/**
9006 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9007 * @wmi_handle: wmi handle
9008 * @pktlog_event: pktlog event
9009 * @cmd_id: pktlog cmd id
9010 *
9011 * Return: CDF status
9012 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309013static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309014 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309015 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309016{
9017 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9018 WMI_CMD_ID CMD_ID;
9019 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9020 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9021 int len = 0;
9022 wmi_buf_t buf;
9023
9024 PKTLOG_EVENT = pktlog_event;
9025 CMD_ID = cmd_id;
9026
9027 switch (CMD_ID) {
9028 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9029 len = sizeof(*cmd);
9030 buf = wmi_buf_alloc(wmi_handle, len);
9031 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309032 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9033 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309034 }
9035 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9036 wmi_buf_data(buf);
9037 WMITLV_SET_HDR(&cmd->tlv_header,
9038 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9039 WMITLV_GET_STRUCT_TLVLEN
9040 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9041 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309042 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9043 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309044 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9045 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309046 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9047 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309048 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309049 goto wmi_send_failed;
9050 }
9051 break;
9052 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9053 len = sizeof(*disable_cmd);
9054 buf = wmi_buf_alloc(wmi_handle, len);
9055 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309056 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9057 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309058 }
9059 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9060 wmi_buf_data(buf);
9061 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9062 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9063 WMITLV_GET_STRUCT_TLVLEN
9064 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309065 disable_cmd->pdev_id =
9066 wmi_handle->ops->convert_pdev_id_host_to_target(
9067 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309068 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9069 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309070 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 goto wmi_send_failed;
9072 }
9073 break;
9074 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309075 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 break;
9077 }
9078
Govind Singhb53420c2016-03-09 14:32:57 +05309079 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309080
9081wmi_send_failed:
9082 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309083 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309084}
9085#endif /* REMOVE_PKT_LOG */
9086
9087/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309088 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9089 * @wmi_handle: wmi handle
9090 * @ptrn_id: pattern id
9091 * @vdev_id: vdev id
9092 *
9093 * Return: CDF status
9094 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309095static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9096 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309097{
9098 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9099 wmi_buf_t buf;
9100 int32_t len;
9101 int ret;
9102
9103 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9104
9105
9106 buf = wmi_buf_alloc(wmi_handle, len);
9107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309108 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9109 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309110 }
9111
9112 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9113
9114 WMITLV_SET_HDR(&cmd->tlv_header,
9115 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9116 WMITLV_GET_STRUCT_TLVLEN(
9117 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9118 cmd->vdev_id = vdev_id;
9119 cmd->pattern_id = ptrn_id;
9120 cmd->pattern_type = WOW_BITMAP_PATTERN;
9121
Govind Singhb53420c2016-03-09 14:32:57 +05309122 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 cmd->pattern_id, vdev_id);
9124
9125 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9126 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9127 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309128 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309129 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309130 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309131 }
9132
Govind Singhb53420c2016-03-09 14:32:57 +05309133 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309134}
9135
9136/**
9137 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9138 * @wmi_handle: wmi handle
9139 *
9140 * Sends host wakeup indication to FW. On receiving this indication,
9141 * FW will come out of WOW.
9142 *
9143 * Return: CDF status
9144 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309145static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309146{
9147 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9148 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309149 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309150 int32_t len;
9151 int ret;
9152
9153 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9154
9155 buf = wmi_buf_alloc(wmi_handle, len);
9156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309157 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9158 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309159 }
9160
9161 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9162 wmi_buf_data(buf);
9163 WMITLV_SET_HDR(&cmd->tlv_header,
9164 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9165 WMITLV_GET_STRUCT_TLVLEN
9166 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9167
9168
9169 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9170 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9171 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309172 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309173 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309174 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 }
9176
Govind Singhb53420c2016-03-09 14:32:57 +05309177 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309178}
9179
9180/**
9181 * send_del_ts_cmd_tlv() - send DELTS request to fw
9182 * @wmi_handle: wmi handle
9183 * @msg: delts params
9184 *
9185 * Return: CDF status
9186 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309187static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 uint8_t ac)
9189{
9190 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9191 wmi_buf_t buf;
9192 int32_t len = sizeof(*cmd);
9193
9194 buf = wmi_buf_alloc(wmi_handle, len);
9195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309196 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9197 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309198 }
9199 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9200 WMITLV_SET_HDR(&cmd->tlv_header,
9201 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9202 WMITLV_GET_STRUCT_TLVLEN
9203 (wmi_vdev_wmm_delts_cmd_fixed_param));
9204 cmd->vdev_id = vdev_id;
9205 cmd->ac = ac;
9206
Govind Singhb53420c2016-03-09 14:32:57 +05309207 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309208 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9209 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9210 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309211 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309212 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309213 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309214 }
9215
Govind Singhb53420c2016-03-09 14:32:57 +05309216 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309217}
9218
9219/**
9220 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9221 * @wmi_handle: handle to wmi
9222 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9223 *
Govind Singhb53420c2016-03-09 14:32:57 +05309224 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309225 * ADD_TS requestes to firmware in loop for all the ACs with
9226 * active flow.
9227 *
9228 * Return: CDF status
9229 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309230static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9232{
9233 int i = 0;
9234 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9235 wmi_buf_t buf;
9236 int32_t len = sizeof(*cmd);
9237
9238 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9239 /* if flow in this AC is active */
9240 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9241 /*
9242 * as per implementation of wma_add_ts_req() we
9243 * are not waiting any response from firmware so
9244 * apart from sending ADDTS to firmware just send
9245 * success to upper layers
9246 */
Govind Singhb53420c2016-03-09 14:32:57 +05309247 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309248
9249 buf = wmi_buf_alloc(wmi_handle, len);
9250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309251 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9252 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 }
9254 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9255 wmi_buf_data(buf);
9256 WMITLV_SET_HDR(&cmd->tlv_header,
9257 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9258 WMITLV_GET_STRUCT_TLVLEN
9259 (wmi_vdev_wmm_addts_cmd_fixed_param));
Rajasekaran Kalidoss81f8de22018-08-04 00:17:18 +05309260 cmd->vdev_id = aggr_qos_rsp_msg->vdev_id;
Govind Singh20c5dac2016-03-07 15:33:31 +05309261 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309262 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309263 traffic.userPrio);
9264 cmd->medium_time_us =
9265 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9266 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309267 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309268 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9269 cmd->medium_time_us, cmd->downgrade_type);
9270 if (wmi_unified_cmd_send
9271 (wmi_handle, buf, len,
9272 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309273 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309274 __func__);
9275 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309276 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309277 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309278 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 }
9280 }
9281 }
9282
Govind Singhb53420c2016-03-09 14:32:57 +05309283 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309284}
9285
9286/**
9287 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9288 * @wmi_handle: wmi handle
9289 * @msg: ADDTS params
9290 *
9291 * Return: CDF status
9292 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309293static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309294 struct add_ts_param *msg)
9295{
9296 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9297 wmi_buf_t buf;
9298 int32_t len = sizeof(*cmd);
9299
Govind Singhb53420c2016-03-09 14:32:57 +05309300 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309301
9302 buf = wmi_buf_alloc(wmi_handle, len);
9303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309304 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9305 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309306 }
9307 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9308 WMITLV_SET_HDR(&cmd->tlv_header,
9309 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9310 WMITLV_GET_STRUCT_TLVLEN
9311 (wmi_vdev_wmm_addts_cmd_fixed_param));
9312 cmd->vdev_id = msg->sme_session_id;
9313 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9314 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9315 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309316 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309317 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9318 cmd->downgrade_type, __func__, __LINE__);
9319 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9320 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309321 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9322 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309323 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309324 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309325 }
9326
Govind Singhb53420c2016-03-09 14:32:57 +05309327 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309328}
9329
9330/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309331 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9332 * @wmi_handle: wmi handle
9333 * @pAddPeriodicTxPtrnParams: tx ptrn params
9334 *
9335 * Retrun: CDF status
9336 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309337static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309338 struct periodic_tx_pattern *
9339 pAddPeriodicTxPtrnParams,
9340 uint8_t vdev_id)
9341{
9342 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9343 wmi_buf_t wmi_buf;
9344 uint32_t len;
9345 uint8_t *buf_ptr;
9346 uint32_t ptrn_len, ptrn_len_aligned;
9347 int j;
9348
9349 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9350 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9351 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9352 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9353
9354 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9355 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309356 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9357 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309358 }
9359
9360 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9361
9362 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9363 WMITLV_SET_HDR(&cmd->tlv_header,
9364 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9365 WMITLV_GET_STRUCT_TLVLEN
9366 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9367
9368 /* Pass the pattern id to delete for the corresponding vdev id */
9369 cmd->vdev_id = vdev_id;
9370 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9371 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9372 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9373
9374 /* Pattern info */
9375 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9377 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309378 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309379 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309380 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309381
Govind Singhb53420c2016-03-09 14:32:57 +05309382 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309383 __func__, cmd->pattern_id, cmd->vdev_id);
9384
9385 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9386 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309387 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309388 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309389 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309390 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 }
Govind Singhb53420c2016-03-09 14:32:57 +05309392 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309393}
9394
9395/**
9396 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9397 * @wmi_handle: wmi handle
9398 * @vdev_id: vdev id
9399 * @pattern_id: pattern id
9400 *
9401 * Retrun: CDF status
9402 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309403static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309404 uint8_t vdev_id,
9405 uint8_t pattern_id)
9406{
9407 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9408 wmi_buf_t wmi_buf;
9409 uint32_t len =
9410 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9411
9412 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9413 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309414 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9415 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309416 }
9417
9418 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9419 wmi_buf_data(wmi_buf);
9420 WMITLV_SET_HDR(&cmd->tlv_header,
9421 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9422 WMITLV_GET_STRUCT_TLVLEN
9423 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9424
9425 /* Pass the pattern id to delete for the corresponding vdev id */
9426 cmd->vdev_id = vdev_id;
9427 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309428 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309429 __func__, cmd->pattern_id, cmd->vdev_id);
9430
9431 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9432 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309433 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309434 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309435 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309436 }
Govind Singhb53420c2016-03-09 14:32:57 +05309437 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309438}
9439
9440/**
9441 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9442 * @wmi_handle: wmi handle
9443 * @preq: stats ext params
9444 *
9445 * Return: CDF status
9446 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309447static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309448 struct stats_ext_params *preq)
9449{
Govind Singh67922e82016-04-01 16:48:57 +05309450 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309451 wmi_req_stats_ext_cmd_fixed_param *cmd;
9452 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309453 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 uint8_t *buf_ptr;
9455
9456 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9457
9458 buf = wmi_buf_alloc(wmi_handle, len);
9459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309460 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309461 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309462 }
9463
9464 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9465 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9466
9467 WMITLV_SET_HDR(&cmd->tlv_header,
9468 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9469 WMITLV_GET_STRUCT_TLVLEN
9470 (wmi_req_stats_ext_cmd_fixed_param));
9471 cmd->vdev_id = preq->vdev_id;
9472 cmd->data_len = preq->request_data_len;
9473
Govind Singhb53420c2016-03-09 14:32:57 +05309474 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 __func__, preq->request_data_len, preq->vdev_id);
9476
9477 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9478 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9479
9480 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309481 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309482
9483 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9484 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309485 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309486 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309487 ret);
9488 wmi_buf_free(buf);
9489 }
9490
9491 return ret;
9492}
9493
9494/**
9495 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9496 * @wmi_handle: wmi handle
9497 * @params: ext wow params
9498 *
9499 * Return:0 for success or error code
9500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309501static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309502 struct ext_wow_params *params)
9503{
9504 wmi_extwow_enable_cmd_fixed_param *cmd;
9505 wmi_buf_t buf;
9506 int32_t len;
9507 int ret;
9508
9509 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9510 buf = wmi_buf_alloc(wmi_handle, len);
9511 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309512 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9513 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309514 }
9515
9516 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9517
9518 WMITLV_SET_HDR(&cmd->tlv_header,
9519 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9520 WMITLV_GET_STRUCT_TLVLEN
9521 (wmi_extwow_enable_cmd_fixed_param));
9522
9523 cmd->vdev_id = params->vdev_id;
9524 cmd->type = params->type;
9525 cmd->wakeup_pin_num = params->wakeup_pin_num;
9526
Govind Singhb53420c2016-03-09 14:32:57 +05309527 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309528 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9529
9530 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9531 WMI_EXTWOW_ENABLE_CMDID);
9532 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309533 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309534 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309535 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309536 }
9537
Govind Singhb53420c2016-03-09 14:32:57 +05309538 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309539
9540}
9541
9542/**
9543 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9544 * @wmi_handle: wmi handle
9545 * @app_type1_params: app type1 params
9546 *
9547 * Return: CDF status
9548 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309549static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309550 struct app_type1_params *app_type1_params)
9551{
9552 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9553 wmi_buf_t buf;
9554 int32_t len;
9555 int ret;
9556
9557 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9558 buf = wmi_buf_alloc(wmi_handle, len);
9559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309560 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9561 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309562 }
9563
9564 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9565 wmi_buf_data(buf);
9566
9567 WMITLV_SET_HDR(&cmd->tlv_header,
9568 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9569 WMITLV_GET_STRUCT_TLVLEN
9570 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9571
9572 cmd->vdev_id = app_type1_params->vdev_id;
9573 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9574 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309575 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309576 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309577 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309578 cmd->passwd_len = app_type1_params->pass_length;
9579
Govind Singhb53420c2016-03-09 14:32:57 +05309580 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309581 "identification_id %.8s id_length %u "
9582 "password %.16s pass_length %u",
9583 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9584 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9585
9586 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9587 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9588 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309589 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309590 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309591 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309592 }
9593
Govind Singhb53420c2016-03-09 14:32:57 +05309594 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309595}
9596
9597/**
9598 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9599 * @wmi_handle: wmi handle
9600 * @appType2Params: app type2 params
9601 *
9602 * Return: CDF status
9603 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309604static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309605 struct app_type2_params *appType2Params)
9606{
9607 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9608 wmi_buf_t buf;
9609 int32_t len;
9610 int ret;
9611
9612 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9613 buf = wmi_buf_alloc(wmi_handle, len);
9614 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309615 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9616 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309617 }
9618
9619 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9620 wmi_buf_data(buf);
9621
9622 WMITLV_SET_HDR(&cmd->tlv_header,
9623 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9624 WMITLV_GET_STRUCT_TLVLEN
9625 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9626
9627 cmd->vdev_id = appType2Params->vdev_id;
9628
Govind Singhb53420c2016-03-09 14:32:57 +05309629 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309630 cmd->rc4_key_len = appType2Params->rc4_key_len;
9631
9632 cmd->ip_id = appType2Params->ip_id;
9633 cmd->ip_device_ip = appType2Params->ip_device_ip;
9634 cmd->ip_server_ip = appType2Params->ip_server_ip;
9635
9636 cmd->tcp_src_port = appType2Params->tcp_src_port;
9637 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9638 cmd->tcp_seq = appType2Params->tcp_seq;
9639 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9640
9641 cmd->keepalive_init = appType2Params->keepalive_init;
9642 cmd->keepalive_min = appType2Params->keepalive_min;
9643 cmd->keepalive_max = appType2Params->keepalive_max;
9644 cmd->keepalive_inc = appType2Params->keepalive_inc;
9645
9646 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9647 &cmd->gateway_mac);
9648 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9649 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9650
Govind Singhb53420c2016-03-09 14:32:57 +05309651 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309652 "rc4_key %.16s rc4_key_len %u "
9653 "ip_id %x ip_device_ip %x ip_server_ip %x "
9654 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9655 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9656 "keepalive_max %u keepalive_inc %u "
9657 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9658 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9659 cmd->rc4_key, cmd->rc4_key_len,
9660 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9661 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9662 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9663 cmd->keepalive_max, cmd->keepalive_inc,
9664 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9665
9666 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9667 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9668 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309669 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309670 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309671 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309672 }
9673
Govind Singhb53420c2016-03-09 14:32:57 +05309674 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309675
9676}
9677
9678/**
9679 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9680 * @wmi_handle: wmi handle
9681 * @timer_val: auto shutdown timer value
9682 *
9683 * Return: CDF status
9684 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309685static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309686 uint32_t timer_val)
9687{
Govind Singh67922e82016-04-01 16:48:57 +05309688 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309689 wmi_buf_t buf = NULL;
9690 uint8_t *buf_ptr;
9691 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9692 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9693
Govind Singhb53420c2016-03-09 14:32:57 +05309694 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309695 __func__, timer_val);
9696
9697 buf = wmi_buf_alloc(wmi_handle, len);
9698 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309699 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9700 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309701 }
9702
9703 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9704 wmi_auto_sh_cmd =
9705 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9706 wmi_auto_sh_cmd->timer_value = timer_val;
9707
9708 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9709 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9710 WMITLV_GET_STRUCT_TLVLEN
9711 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9712
9713 status = wmi_unified_cmd_send(wmi_handle, buf,
9714 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309715 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309716 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309717 __func__, status);
9718 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309719 }
9720
Govind Singh67922e82016-04-01 16:48:57 +05309721 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309722}
9723
9724/**
9725 * send_nan_req_cmd_tlv() - to send nan request to target
9726 * @wmi_handle: wmi handle
9727 * @nan_req: request data which will be non-null
9728 *
9729 * Return: CDF status
9730 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309731static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309732 struct nan_req_params *nan_req)
9733{
Govind Singh67922e82016-04-01 16:48:57 +05309734 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309735 wmi_nan_cmd_param *cmd;
9736 wmi_buf_t buf;
9737 uint16_t len = sizeof(*cmd);
9738 uint16_t nan_data_len, nan_data_len_aligned;
9739 uint8_t *buf_ptr;
9740
9741 /*
9742 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9743 * +------------+----------+-----------------------+--------------+
9744 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9745 * +------------+----------+-----------------------+--------------+
9746 */
9747 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309748 WMI_LOGE("%s:nan req is not valid", __func__);
9749 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309750 }
9751 nan_data_len = nan_req->request_data_len;
9752 nan_data_len_aligned = roundup(nan_req->request_data_len,
9753 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009754 if (nan_data_len_aligned < nan_req->request_data_len) {
9755 WMI_LOGE("%s: integer overflow while rounding up data_len",
9756 __func__);
9757 return QDF_STATUS_E_FAILURE;
9758 }
9759
9760 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9761 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9762 __func__);
9763 return QDF_STATUS_E_FAILURE;
9764 }
9765
Govind Singh20c5dac2016-03-07 15:33:31 +05309766 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9767 buf = wmi_buf_alloc(wmi_handle, len);
9768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309769 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9770 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309771 }
9772 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9773 cmd = (wmi_nan_cmd_param *) buf_ptr;
9774 WMITLV_SET_HDR(&cmd->tlv_header,
9775 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9776 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9777 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309778 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309779 __func__, nan_req->request_data_len);
9780 buf_ptr += sizeof(wmi_nan_cmd_param);
9781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9782 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309783 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309784
9785 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9786 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309787 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309788 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309789 __func__, ret);
9790 wmi_buf_free(buf);
9791 }
9792
9793 return ret;
9794}
9795
9796/**
9797 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9798 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009799 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309800 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309801 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309802 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009803static QDF_STATUS
9804send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9805 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309806{
9807 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9808 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309809 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309810
9811 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309813 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309814 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309815 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309816 }
9817
9818 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309819
9820 WMITLV_SET_HDR(&cmd->tlv_header,
9821 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9822 WMITLV_GET_STRUCT_TLVLEN
9823 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009824 cmd->vdev_id = params->vdev_id;
9825 cmd->enable = params->dhcp_offload_enabled;
9826 cmd->num_client = params->dhcp_client_num;
9827 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309828 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309829 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309830 sizeof(*cmd),
9831 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309832 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309833 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309834 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309835 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309836 }
Govind Singhb53420c2016-03-09 14:32:57 +05309837 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009838 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309839
9840 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309841}
9842
9843/**
9844 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9845 * @wmi_handle: wmi handle
9846 * @flashing: flashing request
9847 *
9848 * Return: CDF status
9849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309850static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309851 struct flashing_req_params *flashing)
9852{
9853 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309854 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309855 wmi_buf_t buf;
9856 uint8_t *buf_ptr;
9857 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9858
9859 buf = wmi_buf_alloc(wmi_handle, len);
9860 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309861 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309862 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309863 }
9864 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9865 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9866 WMITLV_SET_HDR(&cmd->tlv_header,
9867 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9868 WMITLV_GET_STRUCT_TLVLEN
9869 (wmi_set_led_flashing_cmd_fixed_param));
9870 cmd->pattern_id = flashing->pattern_id;
9871 cmd->led_x0 = flashing->led_x0;
9872 cmd->led_x1 = flashing->led_x1;
9873
9874 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9875 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309876 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309877 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309878 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309879 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309880 }
Govind Singh67922e82016-04-01 16:48:57 +05309881
9882 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309883}
9884
9885/**
9886 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9887 * @wmi_handle: wmi handle
9888 * @ch_avoid_update_req: channel avoid update params
9889 *
9890 * Return: CDF status
9891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309892static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309893{
Govind Singh67922e82016-04-01 16:48:57 +05309894 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309895 wmi_buf_t buf = NULL;
9896 uint8_t *buf_ptr;
9897 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9898 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9899
9900
9901 buf = wmi_buf_alloc(wmi_handle, len);
9902 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309903 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9904 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309905 }
9906
9907 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9908 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9909 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9910 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9911 WMITLV_GET_STRUCT_TLVLEN
9912 (wmi_chan_avoid_update_cmd_param));
9913
9914 status = wmi_unified_cmd_send(wmi_handle, buf,
9915 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309916 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309917 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309918 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9919 " returned Error %d", status);
9920 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309921 }
9922
Govind Singh67922e82016-04-01 16:48:57 +05309923 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309924}
9925
9926/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309927 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9928 * @wmi_handle: wmi handle
9929 * @param: pointer to pdev regdomain params
9930 *
9931 * Return: 0 for success or error code
9932 */
9933static QDF_STATUS
9934send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9935 struct pdev_set_regdomain_params *param)
9936{
9937 wmi_buf_t buf;
9938 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9939 int32_t len = sizeof(*cmd);
9940
9941
9942 buf = wmi_buf_alloc(wmi_handle, len);
9943 if (!buf) {
9944 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9945 return QDF_STATUS_E_NOMEM;
9946 }
9947 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9948 WMITLV_SET_HDR(&cmd->tlv_header,
9949 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9950 WMITLV_GET_STRUCT_TLVLEN
9951 (wmi_pdev_set_regdomain_cmd_fixed_param));
9952
9953 cmd->reg_domain = param->currentRDinuse;
9954 cmd->reg_domain_2G = param->currentRD2G;
9955 cmd->reg_domain_5G = param->currentRD5G;
9956 cmd->conformance_test_limit_2G = param->ctl_2G;
9957 cmd->conformance_test_limit_5G = param->ctl_5G;
9958 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309959 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9960 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309961
9962 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9963 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9964 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9965 __func__);
9966 wmi_buf_free(buf);
9967 return QDF_STATUS_E_FAILURE;
9968 }
9969
9970 return QDF_STATUS_SUCCESS;
9971}
9972
9973/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309974 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9975 * @wmi_handle: wmi handle
9976 * @reg_dmn: reg domain
9977 * @regdmn2G: 2G reg domain
9978 * @regdmn5G: 5G reg domain
9979 * @ctl2G: 2G test limit
9980 * @ctl5G: 5G test limit
9981 *
9982 * Return: none
9983 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309984static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309985 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309986 uint16_t regdmn5G, uint8_t ctl2G,
9987 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309988{
9989 wmi_buf_t buf;
9990 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9991 int32_t len = sizeof(*cmd);
9992
9993
9994 buf = wmi_buf_alloc(wmi_handle, len);
9995 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309996 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9997 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309998 }
9999 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10000 WMITLV_SET_HDR(&cmd->tlv_header,
10001 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10002 WMITLV_GET_STRUCT_TLVLEN
10003 (wmi_pdev_set_regdomain_cmd_fixed_param));
10004 cmd->reg_domain = reg_dmn;
10005 cmd->reg_domain_2G = regdmn2G;
10006 cmd->reg_domain_5G = regdmn5G;
10007 cmd->conformance_test_limit_2G = ctl2G;
10008 cmd->conformance_test_limit_5G = ctl5G;
10009
10010 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10011 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010012 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010013 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010014 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010015 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010016 }
10017
Govind Singhb53420c2016-03-09 14:32:57 +053010018 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010019}
10020
10021
10022/**
10023 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10024 * @wmi_handle: wmi handle
10025 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10026 *
10027 * This function sets tdls off channel mode
10028 *
10029 * Return: 0 on success; Negative errno otherwise
10030 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010031static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010032 struct tdls_channel_switch_params *chan_switch_params)
10033{
10034 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10035 wmi_buf_t wmi_buf;
10036 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10037
10038 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10039 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010040 WMI_LOGE(FL("wmi_buf_alloc failed"));
10041 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010042 }
10043 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10044 wmi_buf_data(wmi_buf);
10045 WMITLV_SET_HDR(&cmd->tlv_header,
10046 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10047 WMITLV_GET_STRUCT_TLVLEN(
10048 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10049
10050 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10051 &cmd->peer_macaddr);
10052 cmd->vdev_id = chan_switch_params->vdev_id;
10053 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10054 cmd->is_peer_responder = chan_switch_params->is_responder;
10055 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10056 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10057 cmd->offchan_oper_class = chan_switch_params->oper_class;
10058
Govind Singhb53420c2016-03-09 14:32:57 +053010059 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010060 cmd->peer_macaddr.mac_addr31to0,
10061 cmd->peer_macaddr.mac_addr47to32);
10062
Govind Singhb53420c2016-03-09 14:32:57 +053010063 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010064 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10065 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10066 ),
10067 cmd->vdev_id,
10068 cmd->offchan_mode,
10069 cmd->offchan_num,
10070 cmd->offchan_bw_bitmap,
10071 cmd->is_peer_responder,
10072 cmd->offchan_oper_class);
10073
10074 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10075 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010076 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010077 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010078 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010079 }
10080
10081
Govind Singhb53420c2016-03-09 14:32:57 +053010082 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010083}
10084
10085/**
10086 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10087 * @wmi_handle: wmi handle
10088 * @pwmaTdlsparams: TDLS params
10089 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010090 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010091 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010092static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010093 void *tdls_param, uint8_t tdls_state)
10094{
10095 wmi_tdls_set_state_cmd_fixed_param *cmd;
10096 wmi_buf_t wmi_buf;
10097
10098 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10099 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10100
10101 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10102 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010103 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10104 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010105 }
10106 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10107 WMITLV_SET_HDR(&cmd->tlv_header,
10108 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10109 WMITLV_GET_STRUCT_TLVLEN
10110 (wmi_tdls_set_state_cmd_fixed_param));
10111 cmd->vdev_id = wmi_tdls->vdev_id;
10112 cmd->state = tdls_state;
10113 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10114 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10115 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10116 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10117 cmd->rssi_delta = wmi_tdls->rssi_delta;
10118 cmd->tdls_options = wmi_tdls->tdls_options;
10119 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10120 cmd->tdls_peer_traffic_response_timeout_ms =
10121 wmi_tdls->peer_traffic_response_timeout;
10122 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10123 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10124 cmd->tdls_puapsd_rx_frame_threshold =
10125 wmi_tdls->puapsd_rx_frame_threshold;
10126 cmd->teardown_notification_ms =
10127 wmi_tdls->teardown_notification_ms;
10128 cmd->tdls_peer_kickout_threshold =
10129 wmi_tdls->tdls_peer_kickout_threshold;
10130
Govind Singhb53420c2016-03-09 14:32:57 +053010131 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010132 "notification_interval_ms: %d, "
10133 "tx_discovery_threshold: %d, "
10134 "tx_teardown_threshold: %d, "
10135 "rssi_teardown_threshold: %d, "
10136 "rssi_delta: %d, "
10137 "tdls_options: 0x%x, "
10138 "tdls_peer_traffic_ind_window: %d, "
10139 "tdls_peer_traffic_response_timeout: %d, "
10140 "tdls_puapsd_mask: 0x%x, "
10141 "tdls_puapsd_inactivity_time: %d, "
10142 "tdls_puapsd_rx_frame_threshold: %d, "
10143 "teardown_notification_ms: %d, "
10144 "tdls_peer_kickout_threshold: %d",
10145 __func__, tdls_state, cmd->state,
10146 cmd->notification_interval_ms,
10147 cmd->tx_discovery_threshold,
10148 cmd->tx_teardown_threshold,
10149 cmd->rssi_teardown_threshold,
10150 cmd->rssi_delta,
10151 cmd->tdls_options,
10152 cmd->tdls_peer_traffic_ind_window,
10153 cmd->tdls_peer_traffic_response_timeout_ms,
10154 cmd->tdls_puapsd_mask,
10155 cmd->tdls_puapsd_inactivity_time_ms,
10156 cmd->tdls_puapsd_rx_frame_threshold,
10157 cmd->teardown_notification_ms,
10158 cmd->tdls_peer_kickout_threshold);
10159
10160 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10161 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010162 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010163 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010164 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010165 }
Govind Singhb53420c2016-03-09 14:32:57 +053010166 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010167
Govind Singhb53420c2016-03-09 14:32:57 +053010168 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010169}
10170
10171/**
10172 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10173 * @wmi_handle: wmi handle
10174 * @peerStateParams: TDLS peer state params
10175 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010176 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010177 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010178static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010179 struct tdls_peer_state_params *peerStateParams,
10180 uint32_t *ch_mhz)
10181{
10182 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10183 wmi_tdls_peer_capabilities *peer_cap;
10184 wmi_channel *chan_info;
10185 wmi_buf_t wmi_buf;
10186 uint8_t *buf_ptr;
10187 uint32_t i;
10188 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10189 sizeof(wmi_tdls_peer_capabilities);
10190
10191
10192 len += WMI_TLV_HDR_SIZE +
10193 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10194
10195 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10196 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010197 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10198 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010199 }
10200
10201 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10202 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10203 WMITLV_SET_HDR(&cmd->tlv_header,
10204 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10205 WMITLV_GET_STRUCT_TLVLEN
10206 (wmi_tdls_peer_update_cmd_fixed_param));
10207
10208 cmd->vdev_id = peerStateParams->vdevId;
10209 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10210 &cmd->peer_macaddr);
10211
10212
10213 cmd->peer_state = peerStateParams->peerState;
10214
Govind Singhb53420c2016-03-09 14:32:57 +053010215 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010216 "peer_macaddr.mac_addr31to0: 0x%x, "
10217 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10218 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10219 cmd->peer_macaddr.mac_addr31to0,
10220 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10221
10222 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10223 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10224 WMITLV_SET_HDR(&peer_cap->tlv_header,
10225 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10226 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10227
10228 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10229 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10230 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10231 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10232 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10233 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10234 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10235 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10236
10237 /* Ack and More Data Ack are sent as 0, so no need to set
10238 * but fill SP
10239 */
10240 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10241 peerStateParams->peerCap.peerMaxSp);
10242
10243 peer_cap->buff_sta_support =
10244 peerStateParams->peerCap.peerBuffStaSupport;
10245 peer_cap->off_chan_support =
10246 peerStateParams->peerCap.peerOffChanSupport;
10247 peer_cap->peer_curr_operclass =
10248 peerStateParams->peerCap.peerCurrOperClass;
10249 /* self curr operclass is not being used and so pass op class for
10250 * preferred off chan in it.
10251 */
10252 peer_cap->self_curr_operclass =
10253 peerStateParams->peerCap.opClassForPrefOffChan;
10254 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10255 peer_cap->peer_operclass_len =
10256 peerStateParams->peerCap.peerOperClassLen;
10257
Govind Singhb53420c2016-03-09 14:32:57 +053010258 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010259 __func__, peer_cap->peer_operclass_len);
10260 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10261 peer_cap->peer_operclass[i] =
10262 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010263 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010264 __func__, i, peer_cap->peer_operclass[i]);
10265 }
10266
10267 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10268 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10269 peer_cap->pref_offchan_bw =
10270 peerStateParams->peerCap.prefOffChanBandwidth;
10271
Govind Singhb53420c2016-03-09 14:32:57 +053010272 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010273 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10274 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10275 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10276 " %d, pref_offchan_bw: %d",
10277 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10278 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10279 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10280 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10281 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10282
10283 /* next fill variable size array of peer chan info */
10284 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10285 WMITLV_SET_HDR(buf_ptr,
10286 WMITLV_TAG_ARRAY_STRUC,
10287 sizeof(wmi_channel) *
10288 peerStateParams->peerCap.peerChanLen);
10289 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10290
10291 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10292 WMITLV_SET_HDR(&chan_info->tlv_header,
10293 WMITLV_TAG_STRUC_wmi_channel,
10294 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10295 chan_info->mhz = ch_mhz[i];
10296 chan_info->band_center_freq1 = chan_info->mhz;
10297 chan_info->band_center_freq2 = 0;
10298
Govind Singhb53420c2016-03-09 14:32:57 +053010299 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010300
10301 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10302 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010303 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010304 peerStateParams->peerCap.peerChan[i].chanId,
10305 peerStateParams->peerCap.peerChan[i].dfsSet);
10306 }
10307
10308 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10309 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10310 else
10311 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10312
10313 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10314 peerStateParams->peerCap.
10315 peerChan[i].pwr);
10316
10317 WMI_SET_CHANNEL_REG_POWER(chan_info,
10318 peerStateParams->peerCap.peerChan[i].
10319 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010320 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010321 peerStateParams->peerCap.peerChan[i].pwr);
10322
10323 chan_info++;
10324 }
10325
10326 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10327 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010328 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010329 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010330 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010331 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010332 }
10333
10334
Govind Singhb53420c2016-03-09 14:32:57 +053010335 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010336}
10337
10338/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010339 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10340 * @wmi_handle: Pointer to WMi handle
10341 * @ie_data: Pointer for ie data
10342 *
10343 * This function sends IE information to firmware
10344 *
Govind Singhb53420c2016-03-09 14:32:57 +053010345 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010346 *
10347 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010348static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010349 struct vdev_ie_info_param *ie_info)
10350{
10351 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10352 wmi_buf_t buf;
10353 uint8_t *buf_ptr;
10354 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010355 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010356
10357
10358 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10359 /* Allocate memory for the WMI command */
10360 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10361
10362 buf = wmi_buf_alloc(wmi_handle, len);
10363 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010364 WMI_LOGE(FL("wmi_buf_alloc failed"));
10365 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010366 }
10367
10368 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010369 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010370
10371 /* Populate the WMI command */
10372 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10373
10374 WMITLV_SET_HDR(&cmd->tlv_header,
10375 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10376 WMITLV_GET_STRUCT_TLVLEN(
10377 wmi_vdev_set_ie_cmd_fixed_param));
10378 cmd->vdev_id = ie_info->vdev_id;
10379 cmd->ie_id = ie_info->ie_id;
10380 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010381 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010382
Govind Singhb53420c2016-03-09 14:32:57 +053010383 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010384 ie_info->length, ie_info->vdev_id);
10385
10386 buf_ptr += sizeof(*cmd);
10387 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10388 buf_ptr += WMI_TLV_HDR_SIZE;
10389
Govind Singhb53420c2016-03-09 14:32:57 +053010390 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010391
10392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10393 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010394 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010395 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010396 wmi_buf_free(buf);
10397 }
10398
10399 return ret;
10400}
10401
Sathish Kumar497bef42017-03-01 14:02:36 +053010402/**
10403 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10404 *
10405 * @param wmi_handle : handle to WMI.
10406 * @param param : pointer to antenna param
10407 *
10408 * This function sends smart antenna enable command to FW
10409 *
10410 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10411 */
10412static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10413 struct smart_ant_enable_params *param)
10414{
10415 /* Send WMI COMMAND to Enable */
10416 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10417 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10418 wmi_buf_t buf;
10419 uint8_t *buf_ptr;
10420 int len = 0;
10421 QDF_STATUS ret;
10422 int loop = 0;
10423
10424 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10425 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10426 buf = wmi_buf_alloc(wmi_handle, len);
10427
10428 if (!buf) {
10429 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10430 return QDF_STATUS_E_NOMEM;
10431 }
10432
10433 buf_ptr = wmi_buf_data(buf);
10434 qdf_mem_zero(buf_ptr, len);
10435 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10436
10437 WMITLV_SET_HDR(&cmd->tlv_header,
10438 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10439 WMITLV_GET_STRUCT_TLVLEN(
10440 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10441
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010442 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10443 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010444 cmd->enable = param->enable;
10445 cmd->mode = param->mode;
10446 cmd->rx_antenna = param->rx_antenna;
10447 cmd->tx_default_antenna = param->rx_antenna;
10448
10449 /* TLV indicating array of structures to follow */
10450 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10452 WMI_HAL_MAX_SANTENNA *
10453 sizeof(wmi_pdev_smart_ant_gpio_handle));
10454
10455 buf_ptr += WMI_TLV_HDR_SIZE;
10456 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10457
10458 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10459 WMITLV_SET_HDR(&gpio_param->tlv_header,
10460 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10461 WMITLV_GET_STRUCT_TLVLEN(
10462 wmi_pdev_smart_ant_gpio_handle));
10463 if (param->mode == SMART_ANT_MODE_SERIAL) {
10464 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10465 gpio_param->gpio_pin = param->gpio_pin[loop];
10466 gpio_param->gpio_func = param->gpio_func[loop];
10467 } else {
10468 gpio_param->gpio_pin = 0;
10469 gpio_param->gpio_func = 0;
10470 }
10471 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10472 gpio_param->gpio_pin = param->gpio_pin[loop];
10473 gpio_param->gpio_func = param->gpio_func[loop];
10474 }
10475 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010476 gpio_param->pdev_id =
10477 wmi_handle->ops->convert_pdev_id_host_to_target(
10478 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010479 gpio_param++;
10480 }
10481
10482 ret = wmi_unified_cmd_send(wmi_handle,
10483 buf,
10484 len,
10485 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10486
10487 if (ret != 0) {
10488 WMI_LOGE(" %s :WMI Failed\n", __func__);
10489 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10490 cmd->enable,
10491 cmd->mode,
10492 cmd->rx_antenna,
10493 param->gpio_pin[0], param->gpio_pin[1],
10494 param->gpio_pin[2], param->gpio_pin[3],
10495 param->gpio_func[0], param->gpio_func[1],
10496 param->gpio_func[2], param->gpio_func[3],
10497 ret);
10498 wmi_buf_free(buf);
10499 }
10500
10501 return ret;
10502}
10503
10504/**
10505 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10506 *
10507 * @param wmi_handle : handle to WMI.
10508 * @param param : pointer to rx antenna param
10509 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10510 */
10511static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10512 struct smart_ant_rx_ant_params *param)
10513{
10514 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10515 wmi_buf_t buf;
10516 uint8_t *buf_ptr;
10517 uint32_t len;
10518 QDF_STATUS ret;
10519
10520 len = sizeof(*cmd);
10521 buf = wmi_buf_alloc(wmi_handle, len);
10522 WMI_LOGD("%s:\n", __func__);
10523 if (!buf) {
10524 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10525 return QDF_STATUS_E_NOMEM;
10526 }
10527
10528 buf_ptr = wmi_buf_data(buf);
10529 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10530 WMITLV_SET_HDR(&cmd->tlv_header,
10531 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10532 WMITLV_GET_STRUCT_TLVLEN(
10533 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10534 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010535 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10536 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010537
10538 ret = wmi_unified_cmd_send(wmi_handle,
10539 buf,
10540 len,
10541 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10542
10543 if (ret != 0) {
10544 WMI_LOGE(" %s :WMI Failed\n", __func__);
10545 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10546 __func__,
10547 cmd->rx_antenna,
10548 ret);
10549 wmi_buf_free(buf);
10550 }
10551
10552 return ret;
10553}
10554
10555/**
10556 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10557 * @wmi_handle: wmi handle
10558 * @param: pointer to hold ctl table param
10559 *
10560 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10561 */
10562static QDF_STATUS
10563send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10564 struct ctl_table_params *param)
10565{
10566 uint16_t len, ctl_tlv_len;
10567 uint8_t *buf_ptr;
10568 wmi_buf_t buf;
10569 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10570 uint32_t *ctl_array;
10571
10572 if (!param->ctl_array)
10573 return QDF_STATUS_E_FAILURE;
10574
Sathish Kumar497bef42017-03-01 14:02:36 +053010575 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010576 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010577 len = sizeof(*cmd) + ctl_tlv_len;
10578
10579 buf = wmi_buf_alloc(wmi_handle, len);
10580 if (!buf) {
10581 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10582 return QDF_STATUS_E_FAILURE;
10583 }
10584
10585 buf_ptr = wmi_buf_data(buf);
10586 qdf_mem_zero(buf_ptr, len);
10587
10588 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10589
10590 WMITLV_SET_HDR(&cmd->tlv_header,
10591 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10592 WMITLV_GET_STRUCT_TLVLEN(
10593 wmi_pdev_set_ctl_table_cmd_fixed_param));
10594 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010595 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10596 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010597
10598 buf_ptr += sizeof(*cmd);
10599 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10600 (cmd->ctl_len));
10601 buf_ptr += WMI_TLV_HDR_SIZE;
10602 ctl_array = (uint32_t *)buf_ptr;
10603
10604 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10605 sizeof(param->ctl_band));
10606 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10607 param->ctl_cmd_len -
10608 sizeof(param->ctl_band));
10609
10610 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10611 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10612 WMI_LOGE("%s:Failed to send command\n", __func__);
10613 wmi_buf_free(buf);
10614 return QDF_STATUS_E_FAILURE;
10615 }
10616
10617 return QDF_STATUS_SUCCESS;
10618}
10619
10620/**
10621 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10622 * @wmi_handle: wmi handle
10623 * @param: pointer to hold mimogain table param
10624 *
10625 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10626 */
10627static QDF_STATUS
10628send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10629 struct mimogain_table_params *param)
10630{
10631 uint16_t len, table_tlv_len;
10632 wmi_buf_t buf;
10633 uint8_t *buf_ptr;
10634 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10635 uint32_t *gain_table;
10636
10637 if (!param->array_gain)
10638 return QDF_STATUS_E_FAILURE;
10639
10640 /* len must be multiple of a single array gain table */
10641 if (param->tbl_len %
10642 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10643 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10644 WMI_LOGE("Array gain table len not correct\n");
10645 return QDF_STATUS_E_FAILURE;
10646 }
10647
10648 table_tlv_len = WMI_TLV_HDR_SIZE +
10649 roundup(param->tbl_len, sizeof(uint32_t));
10650 len = sizeof(*cmd) + table_tlv_len;
10651
10652 buf = wmi_buf_alloc(wmi_handle, len);
10653 if (!buf) {
10654 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10655 return QDF_STATUS_E_FAILURE;
10656 }
10657
10658 buf_ptr = wmi_buf_data(buf);
10659 qdf_mem_zero(buf_ptr, len);
10660
10661 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10662
10663 WMITLV_SET_HDR(&cmd->tlv_header,
10664 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10665 WMITLV_GET_STRUCT_TLVLEN(
10666 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10667
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010668 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10669 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010670 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10671 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10672 param->multichain_gain_bypass);
10673
10674 buf_ptr += sizeof(*cmd);
10675 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10676 (param->tbl_len));
10677 buf_ptr += WMI_TLV_HDR_SIZE;
10678 gain_table = (uint32_t *)buf_ptr;
10679
10680 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10681 param->array_gain,
10682 param->tbl_len);
10683
10684 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10685 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10686 return QDF_STATUS_E_FAILURE;
10687 }
10688
10689 return QDF_STATUS_SUCCESS;
10690}
10691
10692/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010693 * enum packet_power_tlv_flags: target defined
10694 * packet power rate flags for TLV
10695 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10696 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10697 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10698 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10699 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10700 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10701 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10702 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10703 * @WMI_TLV_FLAG_STBC: STBC is set
10704 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10705 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10706 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10707 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10708 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10709 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10710 * @WMI_TLV_FLAG_LDPC: LDPC is set
10711 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10712 * @WMI_TLV_FLAG_SU: SU Data
10713 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10714 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10715 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10716 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10717 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10718 *
10719 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10720 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10721 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10722 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10723 */
10724enum packet_power_tlv_flags {
10725 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10726 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10727 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10728 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10729 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10730 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10731 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10732 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10733 WMI_TLV_FLAG_STBC = 0x00000100,
10734 WMI_TLV_FLAG_40MHZ = 0x00000200,
10735 WMI_TLV_FLAG_80MHZ = 0x00000300,
10736 WMI_TLV_FLAG_160MHZ = 0x00000400,
10737 WMI_TLV_FLAG_TXBF = 0x00000800,
10738 WMI_TLV_FLAG_RTSENA = 0x00001000,
10739 WMI_TLV_FLAG_CTSENA = 0x00002000,
10740 WMI_TLV_FLAG_LDPC = 0x00004000,
10741 WMI_TLV_FLAG_SGI = 0x00008000,
10742 WMI_TLV_FLAG_SU = 0x00100000,
10743 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10744 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10745 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10746 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10747 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10748
10749 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10750 WMI_TLV_FLAG_BW_MASK = 0x3,
10751 WMI_TLV_FLAG_BW_SHIFT = 9,
10752 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10753 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10754};
10755
10756/**
10757 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10758 * to FW understandable format
10759 * @param: pointer to hold packet power info param
10760 *
10761 * @return FW understandable 32 bit rate flags
10762 */
10763static uint32_t
10764convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10765{
10766 uint32_t rateflags = 0;
10767
10768 if (param->chainmask)
10769 rateflags |=
10770 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10771 if (param->chan_width)
10772 rateflags |=
10773 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10774 << WMI_TLV_FLAG_BW_SHIFT);
10775 if (param->su_mu_ofdma)
10776 rateflags |=
10777 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10778 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10779 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10780 rateflags |= WMI_TLV_FLAG_STBC;
10781 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10782 rateflags |= WMI_TLV_FLAG_LDPC;
10783 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10784 rateflags |= WMI_TLV_FLAG_TXBF;
10785 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10786 rateflags |= WMI_TLV_FLAG_RTSENA;
10787 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10788 rateflags |= WMI_TLV_FLAG_CTSENA;
10789 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10790 rateflags |= WMI_TLV_FLAG_SGI;
10791
10792 return rateflags;
10793}
10794
10795/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010796 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10797 * info to fw
10798 * @wmi_handle: wmi handle
10799 * @param: pointer to hold packet power info param
10800 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010801 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010802 */
10803static QDF_STATUS
10804send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10805 struct packet_power_info_params *param)
10806{
10807 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10808 wmi_buf_t wmibuf;
10809 uint8_t *buf_ptr;
10810 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10811
10812 wmibuf = wmi_buf_alloc(wmi_handle, len);
10813 if (wmibuf == NULL)
10814 return QDF_STATUS_E_NOMEM;
10815
10816 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10817
10818 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10819 WMITLV_SET_HDR(&cmd->tlv_header,
10820 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10821 WMITLV_GET_STRUCT_TLVLEN(
10822 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010823 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10824 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010825 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010826 cmd->nss = param->nss;
10827 cmd->preamble = param->preamble;
10828 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010829
10830 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10831 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10832 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10833 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10834
Sathish Kumar497bef42017-03-01 14:02:36 +053010835 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10836 WMI_PDEV_GET_TPC_CMDID)) {
10837 WMI_LOGE(FL("Failed to get tpc command\n"));
10838 wmi_buf_free(wmibuf);
10839 return QDF_STATUS_E_FAILURE;
10840 }
10841
10842 return QDF_STATUS_SUCCESS;
10843}
10844
10845/**
10846 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10847 * @wmi_handle: wmi handle
10848 * @param: pointer to hold config ratemask params
10849 *
10850 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10851 */
10852static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10853 struct config_ratemask_params *param)
10854{
10855 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10856 wmi_buf_t buf;
10857 int32_t len = sizeof(*cmd);
10858
10859 buf = wmi_buf_alloc(wmi_handle, len);
10860 if (!buf) {
10861 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10862 return QDF_STATUS_E_FAILURE;
10863 }
10864 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10865 WMITLV_SET_HDR(&cmd->tlv_header,
10866 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10867 WMITLV_GET_STRUCT_TLVLEN(
10868 wmi_vdev_config_ratemask_cmd_fixed_param));
10869 cmd->vdev_id = param->vdev_id;
10870 cmd->type = param->type;
10871 cmd->mask_lower32 = param->lower32;
10872 cmd->mask_higher32 = param->higher32;
Rhythm Patwab5ca01d2018-06-19 10:43:00 -070010873 cmd->mask_lower32_2 = param->lower32_2;
10874 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X"
10875 "mask_l32 = 0x%X mask_h32 = 0x%X mask_l32_2 = 0x%X\n",
10876 param->vdev_id, param->type, param->lower32,
10877 param->higher32, param->lower32_2);
Sathish Kumar497bef42017-03-01 14:02:36 +053010878
10879 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10880 WMI_VDEV_RATEMASK_CMDID)) {
10881 WMI_LOGE("Seting vdev ratemask failed\n");
10882 wmi_buf_free(buf);
10883 return QDF_STATUS_E_FAILURE;
10884 }
10885
10886 return QDF_STATUS_SUCCESS;
10887}
10888
10889/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010890 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10891 * @param: param sent from the host side
10892 * @cmd: param to be sent to the fw side
10893 */
10894static inline void copy_custom_aggr_bitmap(
10895 struct set_custom_aggr_size_params *param,
10896 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10897{
10898 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10899 param->ac);
10900 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10901 param->aggr_type);
10902 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10903 param->tx_aggr_size_disable);
10904 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10905 param->rx_aggr_size_disable);
10906 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10907 param->tx_ac_enable);
10908}
10909
10910/**
10911 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10912 * @wmi_handle: wmi handle
10913 * @param: pointer to hold custom aggr size params
10914 *
10915 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10916 */
10917static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10918 wmi_unified_t wmi_handle,
10919 struct set_custom_aggr_size_params *param)
10920{
10921 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10922 wmi_buf_t buf;
10923 int32_t len = sizeof(*cmd);
10924
10925 buf = wmi_buf_alloc(wmi_handle, len);
10926 if (!buf) {
10927 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10928 return QDF_STATUS_E_FAILURE;
10929 }
10930 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10931 wmi_buf_data(buf);
10932 WMITLV_SET_HDR(&cmd->tlv_header,
10933 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10934 WMITLV_GET_STRUCT_TLVLEN(
10935 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10936 cmd->vdev_id = param->vdev_id;
10937 cmd->tx_aggr_size = param->tx_aggr_size;
10938 cmd->rx_aggr_size = param->rx_aggr_size;
10939 copy_custom_aggr_bitmap(param, cmd);
10940
10941 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10942 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10943 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10944 "tx_ac_enable=0x%X\n",
10945 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10946 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10947 param->rx_aggr_size_disable, param->tx_ac_enable);
10948
10949 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10950 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10951 WMI_LOGE("Seting custom aggregation size failed\n");
10952 wmi_buf_free(buf);
10953 return QDF_STATUS_E_FAILURE;
10954 }
10955
10956 return QDF_STATUS_SUCCESS;
10957}
10958
10959/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010960 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10961 * @param wmi_handle : handle to WMI.
10962 * @param param : pointer to tx antenna param
10963 *
10964 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10965 */
10966
10967static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10968 struct set_qdepth_thresh_params *param)
10969{
10970 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10971 wmi_msduq_qdepth_thresh_update *cmd_update;
10972 wmi_buf_t buf;
10973 int32_t len = 0;
10974 int i;
10975 uint8_t *buf_ptr;
10976 QDF_STATUS ret;
10977
10978 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10979 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10980 return QDF_STATUS_E_INVAL;
10981 }
10982
10983 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10984 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10985 param->num_of_msduq_updates);
10986 buf = wmi_buf_alloc(wmi_handle, len);
10987
10988 if (!buf) {
10989 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10990 return QDF_STATUS_E_NOMEM;
10991 }
10992
10993 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10994 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
10995 buf_ptr;
10996
10997 WMITLV_SET_HDR(&cmd->tlv_header,
10998 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
10999 , WMITLV_GET_STRUCT_TLVLEN(
11000 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11001
11002 cmd->pdev_id =
11003 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11004 cmd->vdev_id = param->vdev_id;
11005 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11006 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11007
11008 buf_ptr += sizeof(
11009 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11010 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11011 param->num_of_msduq_updates *
11012 sizeof(wmi_msduq_qdepth_thresh_update));
11013 buf_ptr += WMI_TLV_HDR_SIZE;
11014 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11015
11016 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11017 WMITLV_SET_HDR(&cmd_update->tlv_header,
11018 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11019 WMITLV_GET_STRUCT_TLVLEN(
11020 wmi_msduq_qdepth_thresh_update));
11021 cmd_update->tid_num = param->update_params[i].tid_num;
11022 cmd_update->msduq_update_mask =
11023 param->update_params[i].msduq_update_mask;
11024 cmd_update->qdepth_thresh_value =
11025 param->update_params[i].qdepth_thresh_value;
11026 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11027 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11028 " update mask=0x%X thresh val=0x%X\n",
11029 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11030 cmd->peer_mac_address.mac_addr31to0,
11031 cmd->peer_mac_address.mac_addr47to32,
11032 cmd_update->msduq_update_mask,
11033 cmd_update->qdepth_thresh_value);
11034 cmd_update++;
11035 }
11036
11037 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11038 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11039
11040 if (ret != 0) {
11041 WMI_LOGE(" %s :WMI Failed\n", __func__);
11042 wmi_buf_free(buf);
11043 }
11044
11045 return ret;
11046}
11047
11048/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011049 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11050 * @wmi_handle: wmi handle
11051 * @param: pointer to hold vap dscp tid map param
11052 *
11053 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11054 */
11055static QDF_STATUS
11056send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11057 struct vap_dscp_tid_map_params *param)
11058{
11059 wmi_buf_t buf;
11060 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11061 int32_t len = sizeof(*cmd);
11062
11063 buf = wmi_buf_alloc(wmi_handle, len);
11064 if (!buf) {
11065 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11066 return QDF_STATUS_E_FAILURE;
11067 }
11068
11069 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11070 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011071 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011072
11073 cmd->vdev_id = param->vdev_id;
11074 cmd->enable_override = 0;
11075
11076 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11077 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11078 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11079 WMI_LOGE("Failed to set dscp cmd\n");
11080 wmi_buf_free(buf);
11081 return QDF_STATUS_E_FAILURE;
11082 }
11083
11084 return QDF_STATUS_SUCCESS;
11085}
11086
11087/**
11088 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11089 * @wmi_handle: wmi handle
11090 * @macaddr: vdev mac address
11091 * @param: pointer to hold neigbour rx param
11092 *
11093 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11094 */
11095static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11096 uint8_t macaddr[IEEE80211_ADDR_LEN],
11097 struct set_neighbour_rx_params *param)
11098{
11099 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11100 wmi_buf_t buf;
11101 int32_t len = sizeof(*cmd);
11102
11103 buf = wmi_buf_alloc(wmi_handle, len);
11104 if (!buf) {
11105 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11106 return QDF_STATUS_E_FAILURE;
11107 }
11108 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11109 WMITLV_SET_HDR(&cmd->tlv_header,
11110 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11111 WMITLV_GET_STRUCT_TLVLEN(
11112 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11113 cmd->vdev_id = param->vdev_id;
11114 cmd->bssid_idx = param->idx;
11115 cmd->action = param->action;
11116 cmd->type = param->type;
11117 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11118 cmd->flag = 0;
11119
11120 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11121 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11122 WMI_LOGE("Failed to set neighbour rx param\n");
11123 wmi_buf_free(buf);
11124 return QDF_STATUS_E_FAILURE;
11125 }
11126
11127 return QDF_STATUS_SUCCESS;
11128}
11129
11130/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011131 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011132 * @param wmi_handle : handle to WMI.
11133 * @param macaddr : vdev mac address
11134 * @param param : pointer to tx antenna param
11135 *
11136 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11137 */
11138static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11139 uint8_t macaddr[IEEE80211_ADDR_LEN],
11140 struct smart_ant_tx_ant_params *param)
11141{
11142 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11143 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11144 wmi_buf_t buf;
11145 int32_t len = 0;
11146 int i;
11147 uint8_t *buf_ptr;
11148 QDF_STATUS ret;
11149
11150 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11151 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11152 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11153 buf = wmi_buf_alloc(wmi_handle, len);
11154
11155 if (!buf) {
11156 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11157 return QDF_STATUS_E_NOMEM;
11158 }
11159
11160 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11161 qdf_mem_zero(buf_ptr, len);
11162 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11163
11164 WMITLV_SET_HDR(&cmd->tlv_header,
11165 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11166 WMITLV_GET_STRUCT_TLVLEN(
11167 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11168
11169 cmd->vdev_id = param->vdev_id;
11170 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11171
11172 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11174 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11175 buf_ptr += WMI_TLV_HDR_SIZE;
11176 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11177
11178 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11179 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11180 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11181 WMITLV_GET_STRUCT_TLVLEN(
11182 wmi_peer_smart_ant_set_tx_antenna_series));
11183 ant_tx_series->antenna_series = param->antenna_array[i];
11184 ant_tx_series++;
11185 }
11186
11187 ret = wmi_unified_cmd_send(wmi_handle,
11188 buf,
11189 len,
11190 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11191
11192 if (ret != 0) {
11193 WMI_LOGE(" %s :WMI Failed\n", __func__);
11194 wmi_buf_free(buf);
11195 }
11196
11197 return ret;
11198}
11199
Sathish Kumar02c3b542017-02-22 17:24:45 +053011200/**
11201 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11202 * @wmi_handle: wmi handle
11203 * @param: pointer to hold ant switch tbl param
11204 *
11205 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11206 */
11207static QDF_STATUS
11208send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11209 struct ant_switch_tbl_params *param)
11210{
11211 uint8_t len;
11212 wmi_buf_t buf;
11213 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11214 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11215 uint8_t *buf_ptr;
11216
11217 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11218 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11219 buf = wmi_buf_alloc(wmi_handle, len);
11220
11221 if (!buf) {
11222 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11223 return QDF_STATUS_E_NOMEM;
11224 }
11225
11226 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11227 qdf_mem_zero(buf_ptr, len);
11228 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11229
11230 WMITLV_SET_HDR(&cmd->tlv_header,
11231 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11232 WMITLV_GET_STRUCT_TLVLEN(
11233 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11234
11235 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11236 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011237 cmd->mac_id =
11238 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011239
11240 /* TLV indicating array of structures to follow */
11241 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11242 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11243 sizeof(wmi_pdev_set_ant_ctrl_chain));
11244 buf_ptr += WMI_TLV_HDR_SIZE;
11245 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11246
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011247 ctrl_chain->pdev_id =
11248 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011249 ctrl_chain->antCtrlChain = param->antCtrlChain;
11250
11251 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11252 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11253 wmi_buf_free(buf);
11254 return QDF_STATUS_E_FAILURE;
11255 }
11256
11257 return QDF_STATUS_SUCCESS;
11258}
11259
11260/**
11261 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11262 * training information function
11263 * @param wmi_handle : handle to WMI.
11264 * @macaddr : vdev mac address
11265 * @param param : pointer to tx antenna param
11266 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11267 */
11268static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11269 wmi_unified_t wmi_handle,
11270 uint8_t macaddr[IEEE80211_ADDR_LEN],
11271 struct smart_ant_training_info_params *param)
11272{
11273 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11274 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11275 wmi_buf_t buf;
11276 uint8_t *buf_ptr;
11277 int32_t len = 0;
11278 QDF_STATUS ret;
11279 int loop;
11280
11281 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11282 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11283 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11284 buf = wmi_buf_alloc(wmi_handle, len);
11285
11286 if (!buf) {
11287 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11288 return QDF_STATUS_E_NOMEM;
11289 }
11290
11291 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11292 qdf_mem_zero(buf_ptr, len);
11293 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11294
11295 WMITLV_SET_HDR(&cmd->tlv_header,
11296 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11297 WMITLV_GET_STRUCT_TLVLEN(
11298 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11299
11300 cmd->vdev_id = param->vdev_id;
11301 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11302 cmd->num_pkts = param->numpkts;
11303
11304 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11305 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11306 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11307 WMI_SMART_ANT_MAX_RATE_SERIES);
11308
11309 buf_ptr += WMI_TLV_HDR_SIZE;
11310 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11311
11312 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11313 WMITLV_SET_HDR(&train_param->tlv_header,
11314 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11315 WMITLV_GET_STRUCT_TLVLEN(
11316 wmi_peer_smart_ant_set_train_antenna_param));
11317 train_param->train_rate_series = param->rate_array[loop];
11318 train_param->train_antenna_series = param->antenna_array[loop];
11319 train_param->rc_flags = 0;
11320 WMI_LOGI(FL("Series number:%d\n"), loop);
11321 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11322 train_param->train_rate_series,
11323 train_param->train_antenna_series);
11324 train_param++;
11325 }
11326
11327 ret = wmi_unified_cmd_send(wmi_handle,
11328 buf,
11329 len,
11330 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11331
11332 if (ret != 0) {
11333 WMI_LOGE(" %s :WMI Failed\n", __func__);
11334 wmi_buf_free(buf);
11335 return QDF_STATUS_E_FAILURE;
11336 }
11337
11338 return ret;
11339}
11340
11341/**
11342 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11343 * configuration function
11344 * @param wmi_handle : handle to WMI.
11345 * @macaddr : vdev mad address
11346 * @param param : pointer to tx antenna param
11347 *
11348 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11349 */
11350static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11351 wmi_unified_t wmi_handle,
11352 uint8_t macaddr[IEEE80211_ADDR_LEN],
11353 struct smart_ant_node_config_params *param)
11354{
11355 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11356 wmi_buf_t buf;
11357 uint8_t *buf_ptr;
11358 int32_t len = 0, args_tlv_len;
11359 int ret;
11360 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011361 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011362
Vivekc5823092018-03-22 23:27:21 +053011363 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011364 len = sizeof(*cmd) + args_tlv_len;
11365
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011366 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011367 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11368 __func__, param->args_count);
11369 return QDF_STATUS_E_FAILURE;
11370 }
11371
11372 buf = wmi_buf_alloc(wmi_handle, len);
11373 if (!buf) {
11374 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11375 return QDF_STATUS_E_NOMEM;
11376 }
11377
11378 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11379 wmi_buf_data(buf);
11380 buf_ptr = (uint8_t *)cmd;
11381 WMITLV_SET_HDR(&cmd->tlv_header,
11382 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11383 WMITLV_GET_STRUCT_TLVLEN(
11384 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11385 cmd->vdev_id = param->vdev_id;
11386 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11387 cmd->cmd_id = param->cmd_id;
11388 cmd->args_count = param->args_count;
11389 buf_ptr += sizeof(
11390 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11391 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011392 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011393 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011394 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011395
11396 for (i = 0; i < param->args_count; i++) {
11397 node_config_args[i] = param->args_arr[i];
11398 WMI_LOGI("%d", param->args_arr[i]);
11399 }
11400
11401 ret = wmi_unified_cmd_send(wmi_handle,
11402 buf,
11403 len,
11404 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11405
11406 if (ret != 0) {
11407 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11408 __func__, param->cmd_id, macaddr[0],
11409 macaddr[1], macaddr[2], macaddr[3],
11410 macaddr[4], macaddr[5], ret);
11411 wmi_buf_free(buf);
11412 }
11413
11414 return ret;
11415}
11416
Jeffin Mammen095050b2018-07-24 14:20:08 +053011417#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053011418/**
11419 * send_set_atf_cmd_tlv() - send set atf command to fw
11420 * @wmi_handle: wmi handle
11421 * @param: pointer to set atf param
11422 *
11423 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11424 */
11425static QDF_STATUS
11426send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11427 struct set_atf_params *param)
11428{
11429 wmi_atf_peer_info *peer_info;
11430 wmi_peer_atf_request_fixed_param *cmd;
11431 wmi_buf_t buf;
11432 uint8_t *buf_ptr;
11433 int i;
11434 int32_t len = 0;
11435 QDF_STATUS retval;
11436
11437 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11438 len += param->num_peers * sizeof(wmi_atf_peer_info);
11439 buf = wmi_buf_alloc(wmi_handle, len);
11440 if (!buf) {
11441 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11442 return QDF_STATUS_E_FAILURE;
11443 }
11444 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11445 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11446 WMITLV_SET_HDR(&cmd->tlv_header,
11447 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11448 WMITLV_GET_STRUCT_TLVLEN(
11449 wmi_peer_atf_request_fixed_param));
11450 cmd->num_peers = param->num_peers;
11451
11452 buf_ptr += sizeof(*cmd);
11453 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11454 sizeof(wmi_atf_peer_info) *
11455 cmd->num_peers);
11456 buf_ptr += WMI_TLV_HDR_SIZE;
11457 peer_info = (wmi_atf_peer_info *)buf_ptr;
11458
11459 for (i = 0; i < cmd->num_peers; i++) {
11460 WMITLV_SET_HDR(&peer_info->tlv_header,
11461 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11462 WMITLV_GET_STRUCT_TLVLEN(
11463 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011464 qdf_mem_copy(&(peer_info->peer_macaddr),
11465 &(param->peer_info[i].peer_macaddr),
11466 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011467 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011468 peer_info->vdev_id = param->peer_info[i].vdev_id;
11469 peer_info->pdev_id =
11470 wmi_handle->ops->convert_pdev_id_host_to_target(
11471 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011472 /*
11473 * TLV definition for peer atf request fixed param combines
11474 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11475 * stats and atf extension stats as two different
11476 * implementations.
11477 * Need to discuss with FW on this.
11478 *
11479 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11480 * peer_info->atf_units_reserved =
11481 * param->peer_ext_info[i].atf_index_reserved;
11482 */
11483 peer_info++;
11484 }
11485
11486 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11487 WMI_PEER_ATF_REQUEST_CMDID);
11488
11489 if (retval != QDF_STATUS_SUCCESS) {
11490 WMI_LOGE("%s : WMI Failed\n", __func__);
11491 wmi_buf_free(buf);
11492 }
11493
11494 return retval;
11495}
Jeffin Mammen095050b2018-07-24 14:20:08 +053011496#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053011497
11498/**
11499 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11500 * @wmi_handle: wmi handle
11501 * @param: pointer to hold fwtest param
11502 *
11503 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11504 */
11505static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11506 struct set_fwtest_params *param)
11507{
11508 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11509 wmi_buf_t buf;
11510 int32_t len = sizeof(*cmd);
11511
11512 buf = wmi_buf_alloc(wmi_handle, len);
11513
11514 if (!buf) {
11515 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11516 return QDF_STATUS_E_FAILURE;
11517 }
11518
11519 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11520 WMITLV_SET_HDR(&cmd->tlv_header,
11521 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11522 WMITLV_GET_STRUCT_TLVLEN(
11523 wmi_fwtest_set_param_cmd_fixed_param));
11524 cmd->param_id = param->arg;
11525 cmd->param_value = param->value;
11526
11527 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11528 WMI_LOGE("Setting FW test param failed\n");
11529 wmi_buf_free(buf);
11530 return QDF_STATUS_E_FAILURE;
11531 }
11532
11533 return QDF_STATUS_SUCCESS;
11534}
11535
11536/**
11537 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11538 * @wmi_handle: wmi handle
11539 * @param: pointer to qboost params
11540 * @macaddr: vdev mac address
11541 *
11542 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11543 */
11544static QDF_STATUS
11545send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11546 uint8_t macaddr[IEEE80211_ADDR_LEN],
11547 struct set_qboost_params *param)
11548{
11549 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11550 wmi_buf_t buf;
11551 int32_t len;
11552 QDF_STATUS ret;
11553
11554 len = sizeof(*cmd);
11555
11556 buf = wmi_buf_alloc(wmi_handle, len);
11557 if (!buf) {
11558 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11559 return QDF_STATUS_E_FAILURE;
11560 }
11561
11562 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11563 WMITLV_SET_HDR(&cmd->tlv_header,
11564 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11565 WMITLV_GET_STRUCT_TLVLEN(
11566 WMI_QBOOST_CFG_CMD_fixed_param));
11567 cmd->vdev_id = param->vdev_id;
11568 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11569 cmd->qb_enable = param->value;
11570
11571 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11572 WMI_QBOOST_CFG_CMDID);
11573
11574 if (ret != 0) {
11575 WMI_LOGE("Setting qboost cmd failed\n");
11576 wmi_buf_free(buf);
11577 }
11578
11579 return ret;
11580}
11581
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011582/**
11583 * send_gpio_config_cmd_tlv() - send gpio config to fw
11584 * @wmi_handle: wmi handle
11585 * @param: pointer to hold gpio config param
11586 *
11587 * Return: 0 for success or error code
11588 */
11589static QDF_STATUS
11590send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11591 struct gpio_config_params *param)
11592{
11593 wmi_gpio_config_cmd_fixed_param *cmd;
11594 wmi_buf_t buf;
11595 int32_t len;
11596 QDF_STATUS ret;
11597
11598 len = sizeof(*cmd);
11599
11600 /* Sanity Checks */
11601 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11602 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11603 return QDF_STATUS_E_FAILURE;
11604 }
11605
11606 buf = wmi_buf_alloc(wmi_handle, len);
11607 if (!buf) {
11608 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11609 return QDF_STATUS_E_FAILURE;
11610 }
11611
11612 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11613 WMITLV_SET_HDR(&cmd->tlv_header,
11614 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11615 WMITLV_GET_STRUCT_TLVLEN(
11616 wmi_gpio_config_cmd_fixed_param));
11617 cmd->gpio_num = param->gpio_num;
11618 cmd->input = param->input;
11619 cmd->pull_type = param->pull_type;
11620 cmd->intr_mode = param->intr_mode;
11621
11622 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11623 WMI_GPIO_CONFIG_CMDID);
11624
11625 if (ret != 0) {
11626 WMI_LOGE("Sending GPIO config cmd failed\n");
11627 wmi_buf_free(buf);
11628 }
11629
11630 return ret;
11631}
11632
11633/**
11634 * send_gpio_output_cmd_tlv() - send gpio output to fw
11635 * @wmi_handle: wmi handle
11636 * @param: pointer to hold gpio output param
11637 *
11638 * Return: 0 for success or error code
11639 */
11640static QDF_STATUS
11641send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11642 struct gpio_output_params *param)
11643{
11644 wmi_gpio_output_cmd_fixed_param *cmd;
11645 wmi_buf_t buf;
11646 int32_t len;
11647 QDF_STATUS ret;
11648
11649 len = sizeof(*cmd);
11650
11651 buf = wmi_buf_alloc(wmi_handle, len);
11652 if (!buf) {
11653 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11654 return QDF_STATUS_E_FAILURE;
11655 }
11656
11657 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11658 WMITLV_SET_HDR(&cmd->tlv_header,
11659 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11660 WMITLV_GET_STRUCT_TLVLEN(
11661 wmi_gpio_output_cmd_fixed_param));
11662 cmd->gpio_num = param->gpio_num;
11663 cmd->set = param->set;
11664
11665 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11666 WMI_GPIO_OUTPUT_CMDID);
11667
11668 if (ret != 0) {
11669 WMI_LOGE("Sending GPIO output cmd failed\n");
11670 wmi_buf_free(buf);
11671 }
11672
11673 return ret;
11674
11675}
11676
11677/**
11678 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11679 *
11680 * @param wmi_handle : handle to WMI.
11681 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11682 */
11683static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11684{
11685 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11686 wmi_buf_t buf;
11687 QDF_STATUS ret;
11688 int32_t len;
11689
11690 len = sizeof(*cmd);
11691
11692 buf = wmi_buf_alloc(wmi_handle, len);
11693 if (!buf) {
11694 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11695 return QDF_STATUS_E_FAILURE;
11696 }
11697
11698 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11699 WMITLV_SET_HDR(&cmd->tlv_header,
11700 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11701 WMITLV_GET_STRUCT_TLVLEN(
11702 wmi_pdev_dfs_disable_cmd_fixed_param));
11703 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011704 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11705 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011706
11707 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11708 WMI_PDEV_DFS_DISABLE_CMDID);
11709
11710 if (ret != 0) {
11711 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11712 wmi_buf_free(buf);
11713 }
11714
11715 return ret;
11716}
11717
11718/**
11719 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11720 *
11721 * @param wmi_handle : handle to WMI.
11722 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11723 */
11724static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11725{
11726 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11727 wmi_buf_t buf;
11728 QDF_STATUS ret;
11729 int32_t len;
11730
11731 len = sizeof(*cmd);
11732
11733 buf = wmi_buf_alloc(wmi_handle, len);
11734 if (!buf) {
11735 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11736 return QDF_STATUS_E_FAILURE;
11737 }
11738
11739 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11740 WMITLV_SET_HDR(&cmd->tlv_header,
11741 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11742 WMITLV_GET_STRUCT_TLVLEN(
11743 wmi_pdev_dfs_enable_cmd_fixed_param));
11744 /* Reserved for future use */
11745 cmd->reserved0 = 0;
11746
11747 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11748 WMI_PDEV_DFS_ENABLE_CMDID);
11749
11750 if (ret != 0) {
11751 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11752 wmi_buf_free(buf);
11753 }
11754
11755 return ret;
11756}
11757
11758/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011759 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11760 * to fw
11761 * @wmi_handle: wmi handle
11762 * @param: pointer to hold periodic chan stats param
11763 *
11764 * Return: 0 for success or error code
11765 */
11766static QDF_STATUS
11767send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11768 struct periodic_chan_stats_params *param)
11769{
11770 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11771 wmi_buf_t buf;
11772 QDF_STATUS ret;
11773 int32_t len;
11774
11775 len = sizeof(*cmd);
11776
11777 buf = wmi_buf_alloc(wmi_handle, len);
11778 if (!buf) {
11779 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11780 return QDF_STATUS_E_FAILURE;
11781 }
11782
11783 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11784 wmi_buf_data(buf);
11785 WMITLV_SET_HDR(&cmd->tlv_header,
11786 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11787 WMITLV_GET_STRUCT_TLVLEN(
11788 wmi_set_periodic_channel_stats_config_fixed_param));
11789 cmd->enable = param->enable;
11790 cmd->stats_period = param->stats_period;
11791 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11792 param->pdev_id);
11793
11794 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11795 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11796
11797 if (ret != 0) {
11798 WMI_LOGE("Sending periodic chan stats config failed");
11799 wmi_buf_free(buf);
11800 }
11801
11802 return ret;
11803}
11804
11805/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011806 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11807 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011808 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011809 *
11810 * Return: 0 for success or error code
11811 */
11812static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011813send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011814{
11815 wmi_buf_t buf;
11816 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011817 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11818 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011819
nobeljf74583b2018-01-25 16:35:36 -080011820 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011821 if (buf == NULL)
11822 return QDF_STATUS_E_NOMEM;
11823
nobeljf74583b2018-01-25 16:35:36 -080011824 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11825 WMITLV_SET_HDR(&cmd->tlv_header,
11826 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11827 WMITLV_GET_STRUCT_TLVLEN
11828 (wmi_pdev_get_nfcal_power_fixed_param));
11829 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11830
11831 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011832 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11833 if (ret != 0) {
11834 WMI_LOGE("Sending get nfcal power cmd failed\n");
11835 wmi_buf_free(buf);
11836 }
11837
11838 return ret;
11839}
11840
11841/**
11842 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11843 * @wmi_handle: wmi handle
11844 * @param: pointer to ht ie param
11845 *
11846 * Return: 0 for success or error code
11847 */
11848static QDF_STATUS
11849send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11850 struct ht_ie_params *param)
11851{
11852 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11853 wmi_buf_t buf;
11854 QDF_STATUS ret;
11855 int32_t len;
11856 uint8_t *buf_ptr;
11857
11858 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11859 roundup(param->ie_len, sizeof(uint32_t));
11860
11861 buf = wmi_buf_alloc(wmi_handle, len);
11862 if (!buf) {
11863 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11864 return QDF_STATUS_E_FAILURE;
11865 }
11866
11867 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11868 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11869 WMITLV_SET_HDR(&cmd->tlv_header,
11870 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11871 WMITLV_GET_STRUCT_TLVLEN(
11872 wmi_pdev_set_ht_ie_cmd_fixed_param));
11873 cmd->reserved0 = 0;
11874 cmd->ie_len = param->ie_len;
11875 cmd->tx_streams = param->tx_streams;
11876 cmd->rx_streams = param->rx_streams;
11877
11878 buf_ptr += sizeof(*cmd);
11879 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11880 buf_ptr += WMI_TLV_HDR_SIZE;
11881 if (param->ie_len)
11882 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11883 cmd->ie_len);
11884
11885 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11886 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11887
11888 if (ret != 0) {
11889 WMI_LOGE("Sending set ht ie cmd failed\n");
11890 wmi_buf_free(buf);
11891 }
11892
11893 return ret;
11894}
11895
11896/**
11897 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11898 * @wmi_handle: wmi handle
11899 * @param: pointer to vht ie param
11900 *
11901 * Return: 0 for success or error code
11902 */
11903static QDF_STATUS
11904send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11905 struct vht_ie_params *param)
11906{
11907 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11908 wmi_buf_t buf;
11909 QDF_STATUS ret;
11910 int32_t len;
11911 uint8_t *buf_ptr;
11912
11913 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11914 roundup(param->ie_len, sizeof(uint32_t));
11915
11916 buf = wmi_buf_alloc(wmi_handle, len);
11917 if (!buf) {
11918 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11919 return QDF_STATUS_E_FAILURE;
11920 }
11921
11922 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11923 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11924 WMITLV_SET_HDR(&cmd->tlv_header,
11925 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11926 WMITLV_GET_STRUCT_TLVLEN(
11927 wmi_pdev_set_vht_ie_cmd_fixed_param));
11928 cmd->reserved0 = 0;
11929 cmd->ie_len = param->ie_len;
11930 cmd->tx_streams = param->tx_streams;
11931 cmd->rx_streams = param->rx_streams;
11932
11933 buf_ptr += sizeof(*cmd);
11934 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11935 buf_ptr += WMI_TLV_HDR_SIZE;
11936 if (param->ie_len)
11937 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11938 cmd->ie_len);
11939
11940 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11941 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11942
11943 if (ret != 0) {
11944 WMI_LOGE("Sending set vht ie cmd failed\n");
11945 wmi_buf_free(buf);
11946 }
11947
11948 return ret;
11949}
11950
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011951/**
11952 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11953 * @wmi_handle: wmi handle
11954 * @param: pointer to quiet mode params
11955 *
11956 * Return: 0 for success or error code
11957 */
11958static QDF_STATUS
11959send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11960 struct set_quiet_mode_params *param)
11961{
11962 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11963 wmi_buf_t buf;
11964 QDF_STATUS ret;
11965 int32_t len;
11966
11967 len = sizeof(*quiet_cmd);
11968 buf = wmi_buf_alloc(wmi_handle, len);
11969 if (!buf) {
11970 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11971 return QDF_STATUS_E_FAILURE;
11972 }
11973
11974 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11975 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11976 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11977 WMITLV_GET_STRUCT_TLVLEN(
11978 wmi_pdev_set_quiet_cmd_fixed_param));
11979 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11980 quiet_cmd->enabled = param->enabled;
11981 quiet_cmd->period = (param->period)*(param->intval);
11982 quiet_cmd->duration = param->duration;
11983 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011984 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11985 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011986
11987 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11988 WMI_PDEV_SET_QUIET_MODE_CMDID);
11989
11990 if (ret != 0) {
11991 WMI_LOGE("Sending set quiet cmd failed\n");
11992 wmi_buf_free(buf);
11993 }
11994
11995 return ret;
11996}
11997
11998/**
11999 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12000 * @wmi_handle: wmi handle
12001 * @param: pointer to set bwf param
12002 *
12003 * Return: 0 for success or error code
12004 */
12005static QDF_STATUS
12006send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12007 struct set_bwf_params *param)
12008{
12009 wmi_bwf_peer_info *peer_info;
12010 wmi_peer_bwf_request_fixed_param *cmd;
12011 wmi_buf_t buf;
12012 QDF_STATUS retval;
12013 int32_t len;
12014 uint8_t *buf_ptr;
12015 int i;
12016
12017 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12018 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12019 buf = wmi_buf_alloc(wmi_handle, len);
12020 if (!buf) {
12021 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12022 return QDF_STATUS_E_FAILURE;
12023 }
12024 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12025 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12026 WMITLV_SET_HDR(&cmd->tlv_header,
12027 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12028 WMITLV_GET_STRUCT_TLVLEN(
12029 wmi_peer_bwf_request_fixed_param));
12030 cmd->num_peers = param->num_peers;
12031
12032 buf_ptr += sizeof(*cmd);
12033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12034 sizeof(wmi_bwf_peer_info) *
12035 cmd->num_peers);
12036 buf_ptr += WMI_TLV_HDR_SIZE;
12037 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12038
12039 for (i = 0; i < cmd->num_peers; i++) {
12040 WMITLV_SET_HDR(&peer_info->tlv_header,
12041 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12042 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12043 peer_info->bwf_guaranteed_bandwidth =
12044 param->peer_info[i].throughput;
12045 peer_info->bwf_max_airtime =
12046 param->peer_info[i].max_airtime;
12047 peer_info->bwf_peer_priority =
12048 param->peer_info[i].priority;
12049 qdf_mem_copy(&peer_info->peer_macaddr,
12050 &param->peer_info[i].peer_macaddr,
12051 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012052 peer_info->vdev_id =
12053 param->peer_info[i].vdev_id;
12054 peer_info->pdev_id =
12055 wmi_handle->ops->convert_pdev_id_host_to_target(
12056 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012057 peer_info++;
12058 }
12059
12060 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12061 WMI_PEER_BWF_REQUEST_CMDID);
12062
12063 if (retval != QDF_STATUS_SUCCESS) {
12064 WMI_LOGE("%s : WMI Failed\n", __func__);
12065 wmi_buf_free(buf);
12066 }
12067
12068 return retval;
12069}
12070
12071/**
12072 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12073 * @wmi_handle: wmi handle
12074 * @param: pointer to hold mcast update param
12075 *
12076 * Return: 0 for success or error code
12077 */
12078static QDF_STATUS
12079send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12080 struct mcast_group_update_params *param)
12081{
12082 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12083 wmi_buf_t buf;
12084 QDF_STATUS ret;
12085 int32_t len;
12086 int offset = 0;
12087 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12088
12089 len = sizeof(*cmd);
12090 buf = wmi_buf_alloc(wmi_handle, len);
12091 if (!buf) {
12092 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12093 return QDF_STATUS_E_FAILURE;
12094 }
12095 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12096 WMITLV_SET_HDR(&cmd->tlv_header,
12097 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12098 WMITLV_GET_STRUCT_TLVLEN(
12099 wmi_peer_mcast_group_cmd_fixed_param));
12100 /* confirm the buffer is 4-byte aligned */
12101 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12102 qdf_mem_zero(cmd, sizeof(*cmd));
12103
12104 cmd->vdev_id = param->vap_id;
12105 /* construct the message assuming our endianness matches the target */
12106 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12107 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12108 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12109 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12110 if (param->is_action_delete)
12111 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12112
12113 if (param->is_mcast_addr_len)
12114 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12115
12116 if (param->is_filter_mode_snoop)
12117 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12118
12119 /* unicast address spec only applies for non-wildcard cases */
12120 if (!param->wildcard && param->ucast_mac_addr) {
12121 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12122 &cmd->ucast_mac_addr);
12123 }
Amar Singhal5593c902017-10-03 13:00:29 -070012124
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012125 if (param->mcast_ip_addr) {
12126 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12127 sizeof(cmd->mcast_ip_addr));
12128 offset = sizeof(cmd->mcast_ip_addr) -
12129 param->mcast_ip_addr_bytes;
12130 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12131 param->mcast_ip_addr,
12132 param->mcast_ip_addr_bytes);
12133 }
12134 if (!param->mask)
12135 param->mask = &dummymask[0];
12136
12137 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12138 param->mask,
12139 param->mcast_ip_addr_bytes);
12140
12141 if (param->srcs && param->nsrcs) {
12142 cmd->num_filter_addr = param->nsrcs;
12143 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12144 sizeof(cmd->filter_addr));
12145
12146 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12147 param->nsrcs * param->mcast_ip_addr_bytes);
12148 }
12149
12150 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12151 WMI_PEER_MCAST_GROUP_CMDID);
12152
12153 if (ret != QDF_STATUS_SUCCESS) {
12154 WMI_LOGE("%s : WMI Failed\n", __func__);
12155 wmi_buf_free(buf);
12156 }
12157
12158 return ret;
12159}
12160
12161/**
12162 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12163 * command to fw
12164 * @wmi_handle: wmi handle
12165 * @param: pointer to hold spectral config parameter
12166 *
12167 * Return: 0 for success or error code
12168 */
12169static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12170 struct vdev_spectral_configure_params *param)
12171{
12172 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12173 wmi_buf_t buf;
12174 QDF_STATUS ret;
12175 int32_t len;
12176
12177 len = sizeof(*cmd);
12178 buf = wmi_buf_alloc(wmi_handle, len);
12179 if (!buf) {
12180 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12181 return QDF_STATUS_E_FAILURE;
12182 }
12183
12184 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12185 WMITLV_SET_HDR(&cmd->tlv_header,
12186 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12187 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012188 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012189
12190 cmd->vdev_id = param->vdev_id;
12191 cmd->spectral_scan_count = param->count;
12192 cmd->spectral_scan_period = param->period;
12193 cmd->spectral_scan_priority = param->spectral_pri;
12194 cmd->spectral_scan_fft_size = param->fft_size;
12195 cmd->spectral_scan_gc_ena = param->gc_enable;
12196 cmd->spectral_scan_restart_ena = param->restart_enable;
12197 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12198 cmd->spectral_scan_init_delay = param->init_delay;
12199 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12200 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12201 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12202 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12203 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12204 cmd->spectral_scan_pwr_format = param->pwr_format;
12205 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12206 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012207 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012208 cmd->spectral_scan_chn_mask = param->chn_mask;
12209
12210 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12211 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12212
12213 if (ret != 0) {
12214 WMI_LOGE("Sending set quiet cmd failed\n");
12215 wmi_buf_free(buf);
12216 }
12217
12218 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12219 __func__);
12220
12221 WMI_LOGI("vdev_id = %u\n"
12222 "spectral_scan_count = %u\n"
12223 "spectral_scan_period = %u\n"
12224 "spectral_scan_priority = %u\n"
12225 "spectral_scan_fft_size = %u\n"
12226 "spectral_scan_gc_ena = %u\n"
12227 "spectral_scan_restart_ena = %u\n"
12228 "spectral_scan_noise_floor_ref = %u\n"
12229 "spectral_scan_init_delay = %u\n"
12230 "spectral_scan_nb_tone_thr = %u\n"
12231 "spectral_scan_str_bin_thr = %u\n"
12232 "spectral_scan_wb_rpt_mode = %u\n"
12233 "spectral_scan_rssi_rpt_mode = %u\n"
12234 "spectral_scan_rssi_thr = %u\n"
12235 "spectral_scan_pwr_format = %u\n"
12236 "spectral_scan_rpt_mode = %u\n"
12237 "spectral_scan_bin_scale = %u\n"
12238 "spectral_scan_dBm_adj = %u\n"
12239 "spectral_scan_chn_mask = %u\n",
12240 param->vdev_id,
12241 param->count,
12242 param->period,
12243 param->spectral_pri,
12244 param->fft_size,
12245 param->gc_enable,
12246 param->restart_enable,
12247 param->noise_floor_ref,
12248 param->init_delay,
12249 param->nb_tone_thr,
12250 param->str_bin_thr,
12251 param->wb_rpt_mode,
12252 param->rssi_rpt_mode,
12253 param->rssi_thr,
12254 param->pwr_format,
12255 param->rpt_mode,
12256 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012257 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012258 param->chn_mask);
12259 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12260
12261 return ret;
12262}
12263
12264/**
12265 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12266 * command to fw
12267 * @wmi_handle: wmi handle
12268 * @param: pointer to hold spectral enable parameter
12269 *
12270 * Return: 0 for success or error code
12271 */
12272static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12273 struct vdev_spectral_enable_params *param)
12274{
12275 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12276 wmi_buf_t buf;
12277 QDF_STATUS ret;
12278 int32_t len;
12279
12280 len = sizeof(*cmd);
12281 buf = wmi_buf_alloc(wmi_handle, len);
12282 if (!buf) {
12283 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12284 return QDF_STATUS_E_FAILURE;
12285 }
12286
12287 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12288 WMITLV_SET_HDR(&cmd->tlv_header,
12289 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12290 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012291 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012292
12293 cmd->vdev_id = param->vdev_id;
12294
12295 if (param->active_valid) {
12296 cmd->trigger_cmd = param->active ? 1 : 2;
12297 /* 1: Trigger, 2: Clear Trigger */
12298 } else {
12299 cmd->trigger_cmd = 0; /* 0: Ignore */
12300 }
12301
12302 if (param->enabled_valid) {
12303 cmd->enable_cmd = param->enabled ? 1 : 2;
12304 /* 1: Enable 2: Disable */
12305 } else {
12306 cmd->enable_cmd = 0; /* 0: Ignore */
12307 }
12308
12309 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12310 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12311
12312 if (ret != 0) {
12313 WMI_LOGE("Sending scan enable CMD failed\n");
12314 wmi_buf_free(buf);
12315 }
12316
12317 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12318
12319 WMI_LOGI("vdev_id = %u\n"
12320 "trigger_cmd = %u\n"
12321 "enable_cmd = %u\n",
12322 cmd->vdev_id,
12323 cmd->trigger_cmd,
12324 cmd->enable_cmd);
12325
12326 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12327
12328 return ret;
12329}
12330
12331/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012332 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12333 * @param wmi_handle : handle to WMI.
12334 * @param param : pointer to hold thermal mitigation param
12335 *
12336 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12337 */
12338static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12339 wmi_unified_t wmi_handle,
12340 struct thermal_mitigation_params *param)
12341{
12342 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12343 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12344 wmi_buf_t buf = NULL;
12345 uint8_t *buf_ptr = NULL;
12346 int error;
12347 int32_t len;
12348 int i;
12349
12350 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12351 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12352
12353 buf = wmi_buf_alloc(wmi_handle, len);
12354 if (!buf) {
12355 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12356 return QDF_STATUS_E_NOMEM;
12357 }
12358 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12359
12360 /* init fixed params */
12361 WMITLV_SET_HDR(tt_conf,
12362 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12363 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12364
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012365 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12366 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012367 tt_conf->enable = param->enable;
12368 tt_conf->dc = param->dc;
12369 tt_conf->dc_per_event = param->dc_per_event;
12370 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12371
12372 buf_ptr = (uint8_t *) ++tt_conf;
12373 /* init TLV params */
12374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12375 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12376
12377 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12378 for (i = 0; i < THERMAL_LEVELS; i++) {
12379 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12380 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12381 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12382 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12383 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12384 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12385 lvl_conf->prio = param->levelconf[i].priority;
12386 lvl_conf++;
12387 }
12388
12389 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12390 WMI_THERM_THROT_SET_CONF_CMDID);
12391 if (QDF_IS_STATUS_ERROR(error)) {
12392 wmi_buf_free(buf);
12393 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12394 }
12395
12396 return error;
12397}
12398
12399/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012400 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12401 * @wmi_handle: wmi handle
12402 * @param: pointer to pdev_qvit_params
12403 *
12404 * Return: 0 for success or error code
12405 */
12406static QDF_STATUS
12407send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12408 struct pdev_qvit_params *param)
12409{
12410 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012411 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012412 uint8_t *cmd;
12413 static uint8_t msgref = 1;
12414 uint8_t segnumber = 0, seginfo, numsegments;
12415 uint16_t chunk_len, total_bytes;
12416 uint8_t *bufpos;
12417 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12418
12419 bufpos = param->utf_payload;
12420 total_bytes = param->len;
12421 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12422 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12423 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12424
12425 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12426 numsegments++;
12427
12428 while (param->len) {
12429 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012430 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012431 else
12432 chunk_len = param->len;
12433
12434 buf = wmi_buf_alloc(wmi_handle,
12435 (chunk_len + sizeof(seghdrinfo) +
12436 WMI_TLV_HDR_SIZE));
12437 if (!buf) {
12438 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12439 return QDF_STATUS_E_NOMEM;
12440 }
12441
12442 cmd = (uint8_t *) wmi_buf_data(buf);
12443
12444 seghdrinfo.len = total_bytes;
12445 seghdrinfo.msgref = msgref;
12446 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12447 seghdrinfo.segmentInfo = seginfo;
12448
12449 segnumber++;
12450
12451 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12452 (chunk_len + sizeof(seghdrinfo)));
12453 cmd += WMI_TLV_HDR_SIZE;
12454 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12455 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12456
12457 ret = wmi_unified_cmd_send(wmi_handle, buf,
12458 (chunk_len + sizeof(seghdrinfo) +
12459 WMI_TLV_HDR_SIZE),
12460 WMI_PDEV_QVIT_CMDID);
12461
12462 if (ret != 0) {
12463 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12464 wmi_buf_free(buf);
12465 break;
12466 }
12467
12468 param->len -= chunk_len;
12469 bufpos += chunk_len;
12470 }
12471 msgref++;
12472
12473 return ret;
12474}
12475
12476/**
12477 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12478 * @wmi_handle: wmi handle
12479 * @param: pointer to wmm update param
12480 *
12481 * Return: 0 for success or error code
12482 */
12483static QDF_STATUS
12484send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12485 struct wmm_update_params *param)
12486{
12487 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12488 wmi_wmm_params *wmm_param;
12489 wmi_buf_t buf;
12490 QDF_STATUS ret;
12491 int32_t len;
12492 int ac = 0;
12493 struct wmi_host_wmeParams *wmep;
12494 uint8_t *buf_ptr;
12495
12496 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12497 buf = wmi_buf_alloc(wmi_handle, len);
12498 if (!buf) {
12499 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12500 return QDF_STATUS_E_FAILURE;
12501 }
12502
12503 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12504 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12505 WMITLV_SET_HDR(&cmd->tlv_header,
12506 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12507 WMITLV_GET_STRUCT_TLVLEN
12508 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12509
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012510 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012511
12512 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12513
12514 for (ac = 0; ac < WME_NUM_AC; ac++) {
12515 wmep = &param->wmep_array[ac];
12516 wmm_param = (wmi_wmm_params *)buf_ptr;
12517 WMITLV_SET_HDR(&wmm_param->tlv_header,
12518 WMITLV_TAG_STRUC_wmi_wmm_params,
12519 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12520 wmm_param->aifs = wmep->wmep_aifsn;
12521 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12522 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12523 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12524 wmm_param->acm = wmep->wmep_acm;
12525 wmm_param->no_ack = wmep->wmep_noackPolicy;
12526 buf_ptr += sizeof(wmi_wmm_params);
12527 }
12528 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12529 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12530
12531 if (ret != 0) {
12532 WMI_LOGE("Sending WMM update CMD failed\n");
12533 wmi_buf_free(buf);
12534 }
12535
12536 return ret;
12537}
12538
Sathish Kumar80f4f382017-04-24 11:36:00 +053012539/**
12540 * send_coex_config_cmd_tlv() - send coex config command to fw
12541 * @wmi_handle: wmi handle
12542 * @param: pointer to coex config param
12543 *
12544 * Return: 0 for success or error code
12545 */
12546static QDF_STATUS
12547send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12548 struct coex_config_params *param)
12549{
12550 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12551 wmi_buf_t buf;
12552 QDF_STATUS ret;
12553 int32_t len;
12554
12555 len = sizeof(*cmd);
12556 buf = wmi_buf_alloc(wmi_handle, len);
12557 if (!buf) {
12558 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12559 return QDF_STATUS_E_FAILURE;
12560 }
12561
12562 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12563 WMITLV_SET_HDR(&cmd->tlv_header,
12564 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12565 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012566 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012567
12568 cmd->vdev_id = param->vdev_id;
12569 cmd->config_type = param->config_type;
12570 cmd->config_arg1 = param->config_arg1;
12571 cmd->config_arg2 = param->config_arg2;
12572 cmd->config_arg3 = param->config_arg3;
12573 cmd->config_arg4 = param->config_arg4;
12574 cmd->config_arg5 = param->config_arg5;
12575 cmd->config_arg6 = param->config_arg6;
12576
12577 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12578 WMI_COEX_CONFIG_CMDID);
12579
12580 if (ret != 0) {
12581 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12582 wmi_buf_free(buf);
12583 }
12584
12585 return ret;
12586}
12587
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012588
12589#ifdef WLAN_SUPPORT_TWT
12590static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12591 target_resource_config *tgt_res_cfg)
12592{
12593 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12594 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12595}
12596#else
12597static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12598 target_resource_config *tgt_res_cfg)
12599{
12600 resource_cfg->twt_ap_pdev_count = 0;
12601 resource_cfg->twt_ap_sta_count = 0;
12602}
12603#endif
12604
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012605static
Govind Singh9ddd5162016-03-07 16:30:32 +053012606void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012607 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012608{
Govind Singhe7f2f342016-05-23 12:12:52 +053012609 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012610 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12611 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12612 resource_cfg->num_offload_reorder_buffs =
12613 tgt_res_cfg->num_offload_reorder_buffs;
12614 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12615 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12616 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12617 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12618 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12619 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12620 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12621 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12622 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12623 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12624 resource_cfg->scan_max_pending_req =
12625 tgt_res_cfg->scan_max_pending_req;
12626 resource_cfg->bmiss_offload_max_vdev =
12627 tgt_res_cfg->bmiss_offload_max_vdev;
12628 resource_cfg->roam_offload_max_vdev =
12629 tgt_res_cfg->roam_offload_max_vdev;
12630 resource_cfg->roam_offload_max_ap_profiles =
12631 tgt_res_cfg->roam_offload_max_ap_profiles;
12632 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12633 resource_cfg->num_mcast_table_elems =
12634 tgt_res_cfg->num_mcast_table_elems;
12635 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12636 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12637 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12638 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12639 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12640 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12641 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12642 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12643 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12644 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12645 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12646 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12647 resource_cfg->num_tdls_conn_table_entries =
12648 tgt_res_cfg->num_tdls_conn_table_entries;
12649 resource_cfg->beacon_tx_offload_max_vdev =
12650 tgt_res_cfg->beacon_tx_offload_max_vdev;
12651 resource_cfg->num_multicast_filter_entries =
12652 tgt_res_cfg->num_multicast_filter_entries;
12653 resource_cfg->num_wow_filters =
12654 tgt_res_cfg->num_wow_filters;
12655 resource_cfg->num_keep_alive_pattern =
12656 tgt_res_cfg->num_keep_alive_pattern;
12657 resource_cfg->keep_alive_pattern_size =
12658 tgt_res_cfg->keep_alive_pattern_size;
12659 resource_cfg->max_tdls_concurrent_sleep_sta =
12660 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12661 resource_cfg->max_tdls_concurrent_buffer_sta =
12662 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12663 resource_cfg->wmi_send_separate =
12664 tgt_res_cfg->wmi_send_separate;
12665 resource_cfg->num_ocb_vdevs =
12666 tgt_res_cfg->num_ocb_vdevs;
12667 resource_cfg->num_ocb_channels =
12668 tgt_res_cfg->num_ocb_channels;
12669 resource_cfg->num_ocb_schedules =
12670 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012671 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012672 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12673 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012674 resource_cfg->max_num_dbs_scan_duty_cycle =
12675 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012676 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012677 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12678 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012679
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012680 if (tgt_res_cfg->atf_config)
12681 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12682 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12683 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12684 resource_cfg->flag1, 1);
12685 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12686 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12687 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012688 if (tgt_res_cfg->cce_disable)
12689 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012690
12691 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012692}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012693
12694/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12695 * @wmi_handle: pointer to wmi handle
12696 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012697 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012698 * @param: point host parameters for init command
12699 *
12700 * Return: Updated pointer of buf_ptr.
12701 */
12702static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12703 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12704{
12705 uint16_t idx;
12706
12707 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12708 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12709 wmi_pdev_band_to_mac *band_to_mac;
12710
12711 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12712 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12713 sizeof(wmi_resource_config) +
12714 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12715 sizeof(wlan_host_memory_chunk)));
12716
12717 WMITLV_SET_HDR(&hw_mode->tlv_header,
12718 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12719 (WMITLV_GET_STRUCT_TLVLEN
12720 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12721
12722 hw_mode->hw_mode_index = param->hw_mode_id;
12723 hw_mode->num_band_to_mac = param->num_band_to_mac;
12724
12725 buf_ptr = (uint8_t *) (hw_mode + 1);
12726 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12727 WMI_TLV_HDR_SIZE);
12728 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12729 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12730 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12731 WMITLV_GET_STRUCT_TLVLEN
12732 (wmi_pdev_band_to_mac));
12733 band_to_mac[idx].pdev_id =
12734 wmi_handle->ops->convert_pdev_id_host_to_target(
12735 param->band_to_mac[idx].pdev_id);
12736 band_to_mac[idx].start_freq =
12737 param->band_to_mac[idx].start_freq;
12738 band_to_mac[idx].end_freq =
12739 param->band_to_mac[idx].end_freq;
12740 }
12741 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12742 (param->num_band_to_mac *
12743 sizeof(wmi_pdev_band_to_mac)) +
12744 WMI_TLV_HDR_SIZE;
12745
12746 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12747 (param->num_band_to_mac *
12748 sizeof(wmi_pdev_band_to_mac)));
12749 }
12750
12751 return buf_ptr;
12752}
12753
12754static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12755 wmi_init_cmd_fixed_param *cmd)
12756{
12757 int num_whitelist;
12758 wmi_abi_version my_vers;
12759
12760 num_whitelist = sizeof(version_whitelist) /
12761 sizeof(wmi_whitelist_version_info);
12762 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12763 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12764 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12765 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12766 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12767 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12768
12769 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12770 &my_vers,
12771 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12772 &cmd->host_abi_vers);
12773
12774 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12775 __func__,
12776 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12777 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12778 cmd->host_abi_vers.abi_version_ns_0,
12779 cmd->host_abi_vers.abi_version_ns_1,
12780 cmd->host_abi_vers.abi_version_ns_2,
12781 cmd->host_abi_vers.abi_version_ns_3);
12782
12783 /* Save version sent from host -
12784 * Will be used to check ready event
12785 */
12786 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12787 sizeof(wmi_abi_version));
12788}
12789
Sathish Kumarfd347372017-02-13 12:29:09 +053012790static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012791{
12792 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12793 wmi_service_ready_event_fixed_param *ev;
12794
12795
12796 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12797
12798 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12799 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012800 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012801
12802 /*Save fw version from service ready message */
12803 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012804 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012805 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012806
Govind Singhb53420c2016-03-09 14:32:57 +053012807 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012808}
12809
12810/**
12811 * wmi_unified_save_fw_version_cmd() - save fw version
12812 * @wmi_handle: pointer to wmi handle
12813 * @res_cfg: resource config
12814 * @num_mem_chunks: no of mem chunck
12815 * @mem_chunk: pointer to mem chunck structure
12816 *
12817 * This function sends IE information to firmware
12818 *
Govind Singhb53420c2016-03-09 14:32:57 +053012819 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012820 *
12821 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012822static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012823 void *evt_buf)
12824{
12825 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12826 wmi_ready_event_fixed_param *ev = NULL;
12827
12828 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12829 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012830 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12831 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012832 &ev->fw_abi_vers)) {
12833 /*
12834 * Error: Our host version and the given firmware version
12835 * are incompatible.
12836 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012837 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012838 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12839 __func__,
12840 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12841 abi_version_0),
12842 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12843 abi_version_0),
12844 wmi_handle->final_abi_vers.abi_version_ns_0,
12845 wmi_handle->final_abi_vers.abi_version_ns_1,
12846 wmi_handle->final_abi_vers.abi_version_ns_2,
12847 wmi_handle->final_abi_vers.abi_version_ns_3,
12848 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12849 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12850 ev->fw_abi_vers.abi_version_ns_0,
12851 ev->fw_abi_vers.abi_version_ns_1,
12852 ev->fw_abi_vers.abi_version_ns_2,
12853 ev->fw_abi_vers.abi_version_ns_3);
12854
Govind Singhb53420c2016-03-09 14:32:57 +053012855 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012856 }
Govind Singhb53420c2016-03-09 14:32:57 +053012857 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012858 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012859 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012860 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012861
Govind Singhb53420c2016-03-09 14:32:57 +053012862 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012863}
Govind Singha4836fd2016-03-07 16:45:38 +053012864
12865/**
12866 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12867 * @wmi_handle: wmi handle
12868 * @custom_addr: base mac address
12869 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012870 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012871 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012872static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012873 uint8_t *custom_addr)
12874{
12875 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12876 wmi_buf_t buf;
12877 int err;
12878
12879 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12880 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012881 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012882 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012883 }
12884
12885 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012886 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012887
12888 WMITLV_SET_HDR(&cmd->tlv_header,
12889 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12890 WMITLV_GET_STRUCT_TLVLEN
12891 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12892 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012893 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12894 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012895 err = wmi_unified_cmd_send(wmi_handle, buf,
12896 sizeof(*cmd),
12897 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12898 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012899 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012900 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012901 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012902 }
12903
12904 return 0;
12905}
12906
12907/**
12908 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12909 * @handle: wmi handle
12910 * @event: Event received from FW
12911 * @len: Length of the event
12912 *
12913 * Enables the low frequency events and disables the high frequency
12914 * events. Bit 17 indicates if the event if low/high frequency.
12915 * 1 - high frequency, 0 - low frequency
12916 *
12917 * Return: 0 on successfully enabling/disabling the events
12918 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012919static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012920 uint8_t *event,
12921 uint32_t len)
12922{
12923 uint32_t num_of_diag_events_logs;
12924 wmi_diag_event_log_config_fixed_param *cmd;
12925 wmi_buf_t buf;
12926 uint8_t *buf_ptr;
12927 uint32_t *cmd_args, *evt_args;
12928 uint32_t buf_len, i;
12929
12930 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12931 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12932
Govind Singhb53420c2016-03-09 14:32:57 +053012933 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012934
12935 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12936 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012937 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012938 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012939 }
12940 wmi_event = param_buf->fixed_param;
12941 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012942
12943 if (num_of_diag_events_logs >
12944 param_buf->num_diag_events_logs_list) {
12945 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12946 num_of_diag_events_logs,
12947 param_buf->num_diag_events_logs_list);
12948 return QDF_STATUS_E_INVAL;
12949 }
12950
Govind Singha4836fd2016-03-07 16:45:38 +053012951 evt_args = param_buf->diag_events_logs_list;
12952 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012953 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012954 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012955 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012956 }
12957
Govind Singhb53420c2016-03-09 14:32:57 +053012958 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012959 __func__, num_of_diag_events_logs);
12960
12961 /* Free any previous allocation */
12962 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012963 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012964
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012965 if (num_of_diag_events_logs >
12966 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12967 WMI_LOGE("%s: excess num of logs:%d", __func__,
12968 num_of_diag_events_logs);
12969 QDF_ASSERT(0);
12970 return QDF_STATUS_E_INVAL;
12971 }
Govind Singha4836fd2016-03-07 16:45:38 +053012972 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012973 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012974 sizeof(uint32_t));
12975 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012976 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012977 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012978 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012979 }
12980 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12981
12982 /* Prepare the send buffer */
12983 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12984 (num_of_diag_events_logs * sizeof(uint32_t));
12985
12986 buf = wmi_buf_alloc(wmi_handle, buf_len);
12987 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012988 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12989 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012990 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012991 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012992 }
12993
12994 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12995 buf_ptr = (uint8_t *) cmd;
12996
12997 WMITLV_SET_HDR(&cmd->tlv_header,
12998 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12999 WMITLV_GET_STRUCT_TLVLEN(
13000 wmi_diag_event_log_config_fixed_param));
13001
13002 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13003
13004 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13005
13006 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13007 (num_of_diag_events_logs * sizeof(uint32_t)));
13008
13009 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13010
13011 /* Populate the events */
13012 for (i = 0; i < num_of_diag_events_logs; i++) {
13013 /* Low freq (0) - Enable (1) the event
13014 * High freq (1) - Disable (0) the event
13015 */
13016 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13017 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13018 /* Set the event ID */
13019 WMI_DIAG_ID_SET(cmd_args[i],
13020 WMI_DIAG_ID_GET(evt_args[i]));
13021 /* Set the type */
13022 WMI_DIAG_TYPE_SET(cmd_args[i],
13023 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013024 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013025 wmi_handle->events_logs_list[i] = evt_args[i];
13026 }
13027
13028 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13029 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013030 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013031 __func__);
13032 wmi_buf_free(buf);
13033 /* Not clearing events_logs_list, though wmi cmd failed.
13034 * Host can still have this list
13035 */
Govind Singh67922e82016-04-01 16:48:57 +053013036 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013037 }
13038
13039 return 0;
13040}
13041
13042/**
13043 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13044 * @wmi_handle: wmi handle
13045 * @start_log: Start logging related parameters
13046 *
13047 * Send the command to the FW based on which specific logging of diag
13048 * event/log id can be started/stopped
13049 *
13050 * Return: None
13051 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013052static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013053 struct wmi_wifi_start_log *start_log)
13054{
13055 wmi_diag_event_log_config_fixed_param *cmd;
13056 wmi_buf_t buf;
13057 uint8_t *buf_ptr;
13058 uint32_t len, count, log_level, i;
13059 uint32_t *cmd_args;
13060 uint32_t total_len;
13061 count = 0;
13062
13063 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013064 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013065 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013066 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013067 }
13068 /* total_len stores the number of events where BITS 17 and 18 are set.
13069 * i.e., events of high frequency (17) and for extended debugging (18)
13070 */
13071 total_len = 0;
13072 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13073 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13074 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13075 total_len++;
13076 }
13077
13078 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13079 (total_len * sizeof(uint32_t));
13080
13081 buf = wmi_buf_alloc(wmi_handle, len);
13082 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013083 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013084 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013085 }
13086 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13087 buf_ptr = (uint8_t *) cmd;
13088
13089 WMITLV_SET_HDR(&cmd->tlv_header,
13090 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13091 WMITLV_GET_STRUCT_TLVLEN(
13092 wmi_diag_event_log_config_fixed_param));
13093
13094 cmd->num_of_diag_events_logs = total_len;
13095
13096 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13097
13098 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13099 (total_len * sizeof(uint32_t)));
13100
13101 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13102
Govind Singh224a7312016-06-21 14:33:26 +053013103 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013104 log_level = 1;
13105 else
13106 log_level = 0;
13107
Govind Singhb53420c2016-03-09 14:32:57 +053013108 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013109 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13110 uint32_t val = wmi_handle->events_logs_list[i];
13111 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13112 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13113
13114 WMI_DIAG_ID_SET(cmd_args[count],
13115 WMI_DIAG_ID_GET(val));
13116 WMI_DIAG_TYPE_SET(cmd_args[count],
13117 WMI_DIAG_TYPE_GET(val));
13118 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13119 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013120 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013121 count++;
13122 }
13123 }
13124
13125 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13126 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013127 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013128 __func__);
13129 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013130 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013131 }
13132
Govind Singhb53420c2016-03-09 14:32:57 +053013133 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013134}
13135
13136/**
13137 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13138 * @wmi_handle: WMI handle
13139 *
13140 * This function is used to send the flush command to the FW,
13141 * that will flush the fw logs that are residue in the FW
13142 *
13143 * Return: None
13144 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013145static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013146{
13147 wmi_debug_mesg_flush_fixed_param *cmd;
13148 wmi_buf_t buf;
13149 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013150 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013151
13152 buf = wmi_buf_alloc(wmi_handle, len);
13153 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013154 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013155 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013156 }
13157
13158 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13159 WMITLV_SET_HDR(&cmd->tlv_header,
13160 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13161 WMITLV_GET_STRUCT_TLVLEN(
13162 wmi_debug_mesg_flush_fixed_param));
13163 cmd->reserved0 = 0;
13164
13165 ret = wmi_unified_cmd_send(wmi_handle,
13166 buf,
13167 len,
13168 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013169 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013170 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013171 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013172 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013173 }
Govind Singhb53420c2016-03-09 14:32:57 +053013174 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013175
Govind Singh67922e82016-04-01 16:48:57 +053013176 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013177}
13178
13179/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013180 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013181 * @wmi_handle: wmi handle
13182 * @msg: PCL structure containing the PCL and the number of channels
13183 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013184 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013185 * firmware. The DBS Manager is the consumer of this information in the WLAN
13186 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13187 * to migrate to a new channel without host driver involvement. An example of
13188 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13189 * manage the channel selection without firmware involvement.
13190 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013191 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13192 * channel list. The weights corresponds to the channels sent in
13193 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13194 * weightage compared to the non PCL channels.
13195 *
Govind Singha4836fd2016-03-07 16:45:38 +053013196 * Return: Success if the cmd is sent successfully to the firmware
13197 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013198static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013199 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013200{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013201 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013202 wmi_buf_t buf;
13203 uint8_t *buf_ptr;
13204 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013205 uint32_t chan_len;
13206
13207 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013208
13209 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013210 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013211
13212 buf = wmi_buf_alloc(wmi_handle, len);
13213 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013214 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13215 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013216 }
13217
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013218 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013219 buf_ptr = (uint8_t *) cmd;
13220 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013221 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13222 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013223
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013224 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13225 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013226 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013227 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013228
13229 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013230 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013231 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013232 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013233 for (i = 0; i < chan_len ; i++) {
13234 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013235 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013236 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013237 }
13238 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013239 WMI_PDEV_SET_PCL_CMDID)) {
13240 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013241 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013242 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013243 }
Govind Singhb53420c2016-03-09 14:32:57 +053013244 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013245}
13246
13247/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013248 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013249 * @wmi_handle: wmi handle
13250 * @msg: Structure containing the following parameters
13251 *
13252 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13253 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13254 *
13255 * Provides notification to the WLAN firmware that host driver is requesting a
13256 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13257 * configurations that include the Dual Band Simultaneous (DBS) feature.
13258 *
13259 * Return: Success if the cmd is sent successfully to the firmware
13260 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013261static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013262 uint32_t hw_mode_index)
13263{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013264 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013265 wmi_buf_t buf;
13266 uint32_t len;
13267
13268 len = sizeof(*cmd);
13269
13270 buf = wmi_buf_alloc(wmi_handle, len);
13271 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013272 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13273 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013274 }
13275
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013276 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013277 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013278 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13279 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13280
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013281 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13282 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013283 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013284 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013285
13286 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013287 WMI_PDEV_SET_HW_MODE_CMDID)) {
13288 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013289 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013290 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013291 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013292 }
13293
Govind Singhb53420c2016-03-09 14:32:57 +053013294 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013295}
13296
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013297#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013298/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013299 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013300 * @wmi_handle: wmi handle
13301 * @msg: Dual MAC config parameters
13302 *
13303 * Configures WLAN firmware with the dual MAC features
13304 *
Govind Singhb53420c2016-03-09 14:32:57 +053013305 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013306 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013307static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013308QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013309 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013310{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013311 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013312 wmi_buf_t buf;
13313 uint32_t len;
13314
13315 len = sizeof(*cmd);
13316
13317 buf = wmi_buf_alloc(wmi_handle, len);
13318 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013319 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13320 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013321 }
13322
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013323 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013324 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013325 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013326 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013327 wmi_pdev_set_mac_config_cmd_fixed_param));
13328
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013329 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13330 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013331 cmd->concurrent_scan_config_bits = msg->scan_config;
13332 cmd->fw_mode_config_bits = msg->fw_mode_config;
Yeshwanth Sriram Guntuka03a37812018-08-16 15:55:25 +053013333 WMI_LOGD("%s: scan_config:%x fw_mode_config:%x",
13334 __func__, msg->scan_config, msg->fw_mode_config);
Govind Singha4836fd2016-03-07 16:45:38 +053013335
13336 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013337 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13338 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013339 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013340 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013341 }
Govind Singhb53420c2016-03-09 14:32:57 +053013342 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013343}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013344#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013345
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013346#ifdef BIG_ENDIAN_HOST
13347/**
13348* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13349* @param data_len - data length
13350* @param data - pointer to data
13351*
13352* Return: QDF_STATUS - success or error status
13353*/
13354static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13355 struct fips_params *param)
13356{
13357 unsigned char *key_unaligned, *data_unaligned;
13358 int c;
13359 u_int8_t *key_aligned = NULL;
13360 u_int8_t *data_aligned = NULL;
13361
13362 /* Assigning unaligned space to copy the key */
13363 key_unaligned = qdf_mem_malloc(
13364 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13365 data_unaligned = qdf_mem_malloc(
13366 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13367
Jeff Johnsonda263992018-05-12 14:22:00 -070013368 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013369 if (key_unaligned == NULL)
13370 return QDF_STATUS_SUCCESS;
13371 /* Checking if space is aligned */
13372 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13373 /* align to 4 */
13374 key_aligned =
13375 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13376 FIPS_ALIGN);
13377 } else {
13378 key_aligned = (u_int8_t *)key_unaligned;
13379 }
13380
13381 /* memset and copy content from key to key aligned */
13382 OS_MEMSET(key_aligned, 0, param->key_len);
13383 OS_MEMCPY(key_aligned, param->key, param->key_len);
13384
13385 /* print a hexdump for host debug */
13386 print_hex_dump(KERN_DEBUG,
13387 "\t Aligned and Copied Key:@@@@ ",
13388 DUMP_PREFIX_NONE,
13389 16, 1, key_aligned, param->key_len, true);
13390
Jeff Johnsonda263992018-05-12 14:22:00 -070013391 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013392 if (data_unaligned == NULL)
13393 return QDF_STATUS_SUCCESS;
13394 /* Checking of space is aligned */
13395 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13396 /* align to 4 */
13397 data_aligned =
13398 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13399 FIPS_ALIGN);
13400 } else {
13401 data_aligned = (u_int8_t *)data_unaligned;
13402 }
13403
13404 /* memset and copy content from data to data aligned */
13405 OS_MEMSET(data_aligned, 0, param->data_len);
13406 OS_MEMCPY(data_aligned, param->data, param->data_len);
13407
13408 /* print a hexdump for host debug */
13409 print_hex_dump(KERN_DEBUG,
13410 "\t Properly Aligned and Copied Data:@@@@ ",
13411 DUMP_PREFIX_NONE,
13412 16, 1, data_aligned, param->data_len, true);
13413
13414 /* converting to little Endian both key_aligned and
13415 * data_aligned*/
13416 for (c = 0; c < param->key_len/4; c++) {
13417 *((u_int32_t *)key_aligned+c) =
13418 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13419 }
13420 for (c = 0; c < param->data_len/4; c++) {
13421 *((u_int32_t *)data_aligned+c) =
13422 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13423 }
13424
13425 /* update endian data to key and data vectors */
13426 OS_MEMCPY(param->key, key_aligned, param->key_len);
13427 OS_MEMCPY(param->data, data_aligned, param->data_len);
13428
13429 /* clean up allocated spaces */
13430 qdf_mem_free(key_unaligned);
13431 key_unaligned = NULL;
13432 key_aligned = NULL;
13433
13434 qdf_mem_free(data_unaligned);
13435 data_unaligned = NULL;
13436 data_aligned = NULL;
13437
13438 return QDF_STATUS_SUCCESS;
13439}
13440#else
13441/**
13442* fips_align_data_be() - DUMMY for LE platform
13443*
13444* Return: QDF_STATUS - success
13445*/
13446static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13447 struct fips_params *param)
13448{
13449 return QDF_STATUS_SUCCESS;
13450}
13451#endif
13452
13453
13454/**
13455 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13456 * @wmi_handle: wmi handle
13457 * @param: pointer to hold pdev fips param
13458 *
13459 * Return: 0 for success or error code
13460 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013461static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013462send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13463 struct fips_params *param)
13464{
13465 wmi_pdev_fips_cmd_fixed_param *cmd;
13466 wmi_buf_t buf;
13467 uint8_t *buf_ptr;
13468 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13469 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13470
13471 /* Length TLV placeholder for array of bytes */
13472 len += WMI_TLV_HDR_SIZE;
13473 if (param->data_len)
13474 len += (param->data_len*sizeof(uint8_t));
13475
13476 /*
13477 * Data length must be multiples of 16 bytes - checked against 0xF -
13478 * and must be less than WMI_SVC_MSG_SIZE - static size of
13479 * wmi_pdev_fips_cmd structure
13480 */
13481
13482 /* do sanity on the input */
13483 if (!(((param->data_len & 0xF) == 0) &&
13484 ((param->data_len > 0) &&
13485 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13486 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13487 return QDF_STATUS_E_INVAL;
13488 }
13489
13490 buf = wmi_buf_alloc(wmi_handle, len);
13491 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013492 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013493 return QDF_STATUS_E_FAILURE;
13494 }
13495
13496 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13497 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13498 WMITLV_SET_HDR(&cmd->tlv_header,
13499 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13500 WMITLV_GET_STRUCT_TLVLEN
13501 (wmi_pdev_fips_cmd_fixed_param));
13502
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013503 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13504 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013505 if (param->key != NULL && param->data != NULL) {
13506 cmd->key_len = param->key_len;
13507 cmd->data_len = param->data_len;
13508 cmd->fips_cmd = !!(param->op);
13509
13510 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13511 return QDF_STATUS_E_FAILURE;
13512
13513 qdf_mem_copy(cmd->key, param->key, param->key_len);
13514
13515 if (param->mode == FIPS_ENGINE_AES_CTR ||
13516 param->mode == FIPS_ENGINE_AES_MIC) {
13517 cmd->mode = param->mode;
13518 } else {
13519 cmd->mode = FIPS_ENGINE_AES_CTR;
13520 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013521 qdf_print("Key len = %d, Data len = %d",
13522 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013523
13524 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13525 cmd->key, cmd->key_len, true);
13526 buf_ptr += sizeof(*cmd);
13527
13528 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13529
13530 buf_ptr += WMI_TLV_HDR_SIZE;
13531 if (param->data_len)
13532 qdf_mem_copy(buf_ptr,
13533 (uint8_t *) param->data, param->data_len);
13534
13535 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13536 16, 1, buf_ptr, cmd->data_len, true);
13537
13538 buf_ptr += param->data_len;
13539
13540 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13541 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013542 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013543 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013544 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013545 wmi_buf_free(buf);
13546 retval = -QDF_STATUS_E_BADMSG;
13547 }
13548
13549 return retval;
13550}
13551
Wu Gao52c0b772018-05-17 16:14:00 +080013552#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013553/**
13554 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13555 * @wmi_handle: wmi handle
13556 * @vdev_id: vdev id
13557 * @bitmap: Event bitmap
13558 * @enable: enable/disable
13559 *
13560 * Return: CDF status
13561 */
13562static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13563 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013564 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013565 bool enable)
13566{
13567 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13568 uint16_t len;
13569 wmi_buf_t buf;
13570 int ret;
13571
13572 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13573 buf = wmi_buf_alloc(wmi_handle, len);
13574 if (!buf) {
13575 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13576 return QDF_STATUS_E_NOMEM;
13577 }
13578 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13579 WMITLV_SET_HDR(&cmd->tlv_header,
13580 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13581 WMITLV_GET_STRUCT_TLVLEN
13582 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13583 cmd->vdev_id = vdev_id;
13584 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013585 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13586 WMI_WOW_MAX_EVENT_BM_LEN);
13587
13588 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13589 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13590 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013591
13592 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13593 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13594 if (ret) {
13595 WMI_LOGE("Failed to config wow wakeup event");
13596 wmi_buf_free(buf);
13597 return QDF_STATUS_E_FAILURE;
13598 }
13599
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013600 return QDF_STATUS_SUCCESS;
13601}
13602
13603/**
13604 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13605 * @wmi_handle: wmi handle
13606 * @vdev_id: vdev id
13607 * @ptrn_id: pattern id
13608 * @ptrn: pattern
13609 * @ptrn_len: pattern length
13610 * @ptrn_offset: pattern offset
13611 * @mask: mask
13612 * @mask_len: mask length
13613 * @user: true for user configured pattern and false for default pattern
13614 * @default_patterns: default patterns
13615 *
13616 * Return: CDF status
13617 */
13618static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13619 uint8_t vdev_id, uint8_t ptrn_id,
13620 const uint8_t *ptrn, uint8_t ptrn_len,
13621 uint8_t ptrn_offset, const uint8_t *mask,
13622 uint8_t mask_len, bool user,
13623 uint8_t default_patterns)
13624{
13625 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13626 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13627 wmi_buf_t buf;
13628 uint8_t *buf_ptr;
13629 int32_t len;
13630 int ret;
13631
13632 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13633 WMI_TLV_HDR_SIZE +
13634 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13635 WMI_TLV_HDR_SIZE +
13636 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13637 WMI_TLV_HDR_SIZE +
13638 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13639 WMI_TLV_HDR_SIZE +
13640 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13641 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013642 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013643
13644 buf = wmi_buf_alloc(wmi_handle, len);
13645 if (!buf) {
13646 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13647 return QDF_STATUS_E_NOMEM;
13648 }
13649
13650 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13651 buf_ptr = (uint8_t *) cmd;
13652
13653 WMITLV_SET_HDR(&cmd->tlv_header,
13654 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13655 WMITLV_GET_STRUCT_TLVLEN
13656 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13657 cmd->vdev_id = vdev_id;
13658 cmd->pattern_id = ptrn_id;
13659
13660 cmd->pattern_type = WOW_BITMAP_PATTERN;
13661 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13662
13663 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13664 sizeof(WOW_BITMAP_PATTERN_T));
13665 buf_ptr += WMI_TLV_HDR_SIZE;
13666 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13667
13668 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13669 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13670 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13671
13672 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13673 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13674
13675 bitmap_pattern->pattern_offset = ptrn_offset;
13676 bitmap_pattern->pattern_len = ptrn_len;
13677
13678 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13679 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13680
13681 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13682 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13683
13684 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13685 bitmap_pattern->pattern_id = ptrn_id;
13686
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013687 WMI_LOGD("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013688 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13689 bitmap_pattern->pattern_offset, user);
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013690 WMI_LOGD("Pattern : ");
13691 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13692 &bitmap_pattern->patternbuf[0],
13693 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013694
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013695 WMI_LOGD("Mask : ");
13696 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13697 &bitmap_pattern->bitmaskbuf[0],
13698 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013699
13700 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13701
13702 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13703 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13704 buf_ptr += WMI_TLV_HDR_SIZE;
13705
13706 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13707 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13708 buf_ptr += WMI_TLV_HDR_SIZE;
13709
13710 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13711 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13712 buf_ptr += WMI_TLV_HDR_SIZE;
13713
13714 /* Fill TLV for pattern_info_timeout but no data. */
13715 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13716 buf_ptr += WMI_TLV_HDR_SIZE;
13717
13718 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013719 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013720 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013721 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013722
13723 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13724 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13725 if (ret) {
13726 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13727 wmi_buf_free(buf);
13728 return QDF_STATUS_E_FAILURE;
13729 }
13730
13731 return QDF_STATUS_SUCCESS;
13732}
13733
Govind Singha4836fd2016-03-07 16:45:38 +053013734/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013735 * fill_arp_offload_params_tlv() - Fill ARP offload data
13736 * @wmi_handle: wmi handle
13737 * @offload_req: offload request
13738 * @buf_ptr: buffer pointer
13739 *
13740 * To fill ARP offload data to firmware
13741 * when target goes to wow mode.
13742 *
13743 * Return: None
13744 */
13745static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013746 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013747{
13748
13749 int i;
13750 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013751 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013752
13753 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13754 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13755 *buf_ptr += WMI_TLV_HDR_SIZE;
13756 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13757 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13758 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13759 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13760 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13761
13762 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013763 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013764 /* Copy the target ip addr and flags */
13765 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13766 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013767 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013768 WMI_IPV4_ADDR_LEN);
13769 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013770 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013771 }
13772 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13773 }
13774}
13775
13776#ifdef WLAN_NS_OFFLOAD
13777/**
13778 * fill_ns_offload_params_tlv() - Fill NS offload data
13779 * @wmi|_handle: wmi handle
13780 * @offload_req: offload request
13781 * @buf_ptr: buffer pointer
13782 *
13783 * To fill NS offload data to firmware
13784 * when target goes to wow mode.
13785 *
13786 * Return: None
13787 */
13788static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013789 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013790{
13791
13792 int i;
13793 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013794
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013795 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13796 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13797 *buf_ptr += WMI_TLV_HDR_SIZE;
13798 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13799 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13800 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13801 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13802 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13803
13804 /*
13805 * Fill data only for NS offload in the first ARP tuple for LA
13806 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013807 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013808 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13809 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013810 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013811 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013812 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013813 sizeof(WMI_IPV6_ADDR));
13814 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013815 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013816 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013817 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013818 ns_tuple->flags |=
13819 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13820 }
13821 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013822 i, &ns_req->self_ipv6_addr[i],
13823 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013824
13825 /* target MAC is optional, check if it is valid,
13826 * if this is not valid, the target will use the known
13827 * local MAC address rather than the tuple
13828 */
13829 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013830 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013831 &ns_tuple->target_mac);
13832 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13833 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13834 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13835 }
13836 }
13837 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13838 }
13839}
13840
13841
13842/**
13843 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13844 * @wmi: wmi handle
13845 * @offload_req: offload request
13846 * @buf_ptr: buffer pointer
13847 *
13848 * To fill extended NS offload extended data to firmware
13849 * when target goes to wow mode.
13850 *
13851 * Return: None
13852 */
13853static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013854 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013855{
13856 int i;
13857 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13858 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013859
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013860 count = ns_req->num_ns_offload_count;
13861 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013862 WMI_MAX_NS_OFFLOADS;
13863
13864 /* Populate extended NS offload tuples */
13865 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13866 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13867 *buf_ptr += WMI_TLV_HDR_SIZE;
13868 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13869 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13870 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13871 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13872 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13873
13874 /*
13875 * Fill data only for NS offload in the first ARP tuple for LA
13876 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013877 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013878 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13879 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013880 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013881 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013882 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013883 sizeof(WMI_IPV6_ADDR));
13884 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013885 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013886 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013887 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013888 ns_tuple->flags |=
13889 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13890 }
13891 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013892 i, &ns_req->self_ipv6_addr[i],
13893 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013894
13895 /* target MAC is optional, check if it is valid,
13896 * if this is not valid, the target will use the
13897 * known local MAC address rather than the tuple
13898 */
13899 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013900 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013901 &ns_tuple->target_mac);
13902 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13903 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13904 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13905 }
13906 }
13907 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13908 }
13909}
13910#else
13911static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013912 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013913{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013914}
13915
13916static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013917 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013918{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013919}
13920#endif
13921
13922/**
Govind Singha4836fd2016-03-07 16:45:38 +053013923 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13924 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013925 * @arp_offload_req: arp offload request
13926 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013927 * @arp_only: flag
13928 *
13929 * To configure ARP NS off load data to firmware
13930 * when target goes to wow mode.
13931 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013932 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013933 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013934static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013935 struct pmo_arp_offload_params *arp_offload_req,
13936 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013937 uint8_t vdev_id)
13938{
Govind Singha4836fd2016-03-07 16:45:38 +053013939 int32_t res;
13940 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013941 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013942 wmi_buf_t buf;
13943 int32_t len;
13944 uint32_t count = 0, num_ns_ext_tuples = 0;
13945
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013946 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013947
Govind Singha4836fd2016-03-07 16:45:38 +053013948 /*
13949 * TLV place holder size for array of NS tuples
13950 * TLV place holder size for array of ARP tuples
13951 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013952 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13953 WMI_TLV_HDR_SIZE +
13954 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13955 WMI_TLV_HDR_SIZE +
13956 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013957
13958 /*
13959 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13960 * extra length for extended NS offload tuples which follows ARP offload
13961 * tuples. Host needs to fill this structure in following format:
13962 * 2 NS ofload tuples
13963 * 2 ARP offload tuples
13964 * N numbers of extended NS offload tuples if HDD has given more than
13965 * 2 NS offload addresses
13966 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013967 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013968 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013969 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13970 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013971 }
13972
13973 buf = wmi_buf_alloc(wmi_handle, len);
13974 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013975 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013976 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013977 }
13978
Vivekc5823092018-03-22 23:27:21 +053013979 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013980 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13981 WMITLV_SET_HDR(&cmd->tlv_header,
13982 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13983 WMITLV_GET_STRUCT_TLVLEN
13984 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13985 cmd->flags = 0;
13986 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013987 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013988
Govind Singhb53420c2016-03-09 14:32:57 +053013989 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013990
Govind Singha4836fd2016-03-07 16:45:38 +053013991 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013992 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13993 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13994 if (num_ns_ext_tuples)
13995 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013996
13997 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13998 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13999 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014000 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014001 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014002 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014003 }
14004
Govind Singhb53420c2016-03-09 14:32:57 +053014005 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014006}
14007
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014008/**
14009 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14010 * @wmi_handle: wmi handle
14011 * @vdev_id: vdev id
14012 * @action: true for enable else false
14013 *
14014 * To enable enhance multicast offload to firmware
14015 * when target goes to wow mode.
14016 *
14017 * Return: QDF Status
14018 */
14019
14020static
14021QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14022 wmi_unified_t wmi_handle,
14023 uint8_t vdev_id, bool action)
14024{
14025 QDF_STATUS status;
14026 wmi_buf_t buf;
14027 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14028
14029 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14030 if (!buf) {
14031 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14032 return QDF_STATUS_E_NOMEM;
14033 }
14034
14035 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14036 wmi_buf_data(buf);
14037
14038 WMITLV_SET_HDR(&cmd->tlv_header,
14039 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14040 WMITLV_GET_STRUCT_TLVLEN(
14041 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14042
14043 cmd->vdev_id = vdev_id;
14044 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14045 ENHANCED_MCAST_FILTER_ENABLED);
14046 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14047 __func__, action, vdev_id);
14048 status = wmi_unified_cmd_send(wmi_handle, buf,
14049 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14050 if (status != QDF_STATUS_SUCCESS) {
14051 qdf_nbuf_free(buf);
14052 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14053 __func__);
14054 }
14055
14056 return status;
14057}
14058
14059/**
14060 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14061 * @wmi_handle: wmi handle
14062 * @param evt_buf: pointer to event buffer
14063 * @param hdr: Pointer to hold header
14064 * @param bufp: Pointer to hold pointer to rx param buffer
14065 *
14066 * Return: QDF_STATUS_SUCCESS for success or error code
14067 */
14068static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14069 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14070{
14071 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14072 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14073
14074 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14075 if (!param_buf) {
14076 WMI_LOGE("gtk param_buf is NULL");
14077 return QDF_STATUS_E_INVAL;
14078 }
14079
14080 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14081 WMI_LOGE("Invalid length for GTK status");
14082 return QDF_STATUS_E_INVAL;
14083 }
14084
14085 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14086 param_buf->fixed_param;
14087 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14088 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14089 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14090 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14091 &fixed_param->replay_counter,
14092 GTK_REPLAY_COUNTER_BYTES);
14093
14094 return QDF_STATUS_SUCCESS;
14095
14096}
14097
14098#ifdef FEATURE_WLAN_RA_FILTERING
14099/**
14100 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14101 * @wmi_handle: wmi handle
14102 * @vdev_id: vdev id
14103 *
14104 * Return: CDF status
14105 */
14106static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14107 uint8_t vdev_id, uint8_t default_pattern,
14108 uint16_t rate_limit_interval)
14109{
14110
14111 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14112 wmi_buf_t buf;
14113 uint8_t *buf_ptr;
14114 int32_t len;
14115 int ret;
14116
14117 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14118 WMI_TLV_HDR_SIZE +
14119 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14120 WMI_TLV_HDR_SIZE +
14121 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14122 WMI_TLV_HDR_SIZE +
14123 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14124 WMI_TLV_HDR_SIZE +
14125 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14126 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014127 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014128
14129 buf = wmi_buf_alloc(wmi_handle, len);
14130 if (!buf) {
14131 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14132 return QDF_STATUS_E_NOMEM;
14133 }
14134
14135 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14136 buf_ptr = (uint8_t *) cmd;
14137
14138 WMITLV_SET_HDR(&cmd->tlv_header,
14139 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14140 WMITLV_GET_STRUCT_TLVLEN
14141 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14142 cmd->vdev_id = vdev_id;
14143 cmd->pattern_id = default_pattern,
14144 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14145 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14146
14147 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14148 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14149 buf_ptr += WMI_TLV_HDR_SIZE;
14150
14151 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14153 buf_ptr += WMI_TLV_HDR_SIZE;
14154
14155 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14157 buf_ptr += WMI_TLV_HDR_SIZE;
14158
14159 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14160 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14161 buf_ptr += WMI_TLV_HDR_SIZE;
14162
14163 /* Fill TLV for pattern_info_timeout but no data. */
14164 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14165 buf_ptr += WMI_TLV_HDR_SIZE;
14166
14167 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014169 buf_ptr += WMI_TLV_HDR_SIZE;
14170
Vivekc5823092018-03-22 23:27:21 +053014171 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014172
14173 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14174 rate_limit_interval, vdev_id);
14175
14176 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14177 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14178 if (ret) {
14179 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14180 wmi_buf_free(buf);
14181 return QDF_STATUS_E_FAILURE;
14182 }
14183
14184 return QDF_STATUS_SUCCESS;
14185
14186}
14187#endif /* FEATURE_WLAN_RA_FILTERING */
14188
14189/**
14190 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14191 * @wmi_handle: wmi handle
14192 * @vdev_id: vdev id
14193 * @multicastAddr: mcast address
14194 * @clearList: clear list flag
14195 *
14196 * Return: QDF_STATUS_SUCCESS for success or error code
14197 */
14198static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14199 uint8_t vdev_id,
14200 struct qdf_mac_addr multicast_addr,
14201 bool clearList)
14202{
14203 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14204 wmi_buf_t buf;
14205 int err;
14206
14207 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14208 if (!buf) {
14209 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14210 return QDF_STATUS_E_NOMEM;
14211 }
14212
14213 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14214 qdf_mem_zero(cmd, sizeof(*cmd));
14215
14216 WMITLV_SET_HDR(&cmd->tlv_header,
14217 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14218 WMITLV_GET_STRUCT_TLVLEN
14219 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14220 cmd->action =
14221 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14222 cmd->vdev_id = vdev_id;
14223 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14224
14225 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14226 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14227
14228 err = wmi_unified_cmd_send(wmi_handle, buf,
14229 sizeof(*cmd),
14230 WMI_SET_MCASTBCAST_FILTER_CMDID);
14231 if (err) {
14232 WMI_LOGE("Failed to send set_param cmd");
14233 wmi_buf_free(buf);
14234 return QDF_STATUS_E_FAILURE;
14235 }
14236
14237 return QDF_STATUS_SUCCESS;
14238}
14239
14240/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014241 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14242 * command to fw
14243 * @wmi_handle: wmi handle
14244 * @vdev_id: vdev id
14245 * @mcast_filter_params: mcast filter params
14246 *
14247 * Return: QDF_STATUS_SUCCESS for success or error code
14248 */
14249static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14250 wmi_unified_t wmi_handle,
14251 uint8_t vdev_id,
14252 struct pmo_mcast_filter_params *filter_param)
14253
14254{
14255 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14256 uint8_t *buf_ptr;
14257 wmi_buf_t buf;
14258 int err;
14259 int i;
14260 uint8_t *mac_addr_src_ptr = NULL;
14261 wmi_mac_addr *mac_addr_dst_ptr;
14262 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14263 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14264
14265 buf = wmi_buf_alloc(wmi_handle, len);
14266 if (!buf) {
14267 WMI_LOGE("Failed to allocate memory");
14268 return QDF_STATUS_E_NOMEM;
14269 }
14270
Vivekc5823092018-03-22 23:27:21 +053014271 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014272 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14273 wmi_buf_data(buf);
14274 qdf_mem_zero(cmd, sizeof(*cmd));
14275
14276 WMITLV_SET_HDR(&cmd->tlv_header,
14277 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14278 WMITLV_GET_STRUCT_TLVLEN
14279 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14280 cmd->operation =
14281 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14282 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14283 cmd->vdev_id = vdev_id;
14284 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14285
14286 buf_ptr += sizeof(*cmd);
14287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14288 sizeof(wmi_mac_addr) *
14289 filter_param->multicast_addr_cnt);
14290
14291 if (filter_param->multicast_addr_cnt == 0)
14292 goto send_cmd;
14293
14294 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14295 mac_addr_dst_ptr = (wmi_mac_addr *)
14296 (buf_ptr + WMI_TLV_HDR_SIZE);
14297
14298 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14299 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14300 mac_addr_src_ptr += ATH_MAC_LEN;
14301 mac_addr_dst_ptr++;
14302 }
14303
14304send_cmd:
14305 err = wmi_unified_cmd_send(wmi_handle, buf,
14306 len,
14307 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14308 if (err) {
14309 WMI_LOGE("Failed to send set_param cmd");
14310 wmi_buf_free(buf);
14311 return QDF_STATUS_E_FAILURE;
14312 }
14313
14314 return QDF_STATUS_SUCCESS;
14315}
14316
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014317static void
14318fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
14319 uint8_t vdev_id,
14320 struct pmo_gtk_req *params)
14321{
14322 uint8_t *buf_ptr;
14323 wmi_gtk_offload_fils_tlv_param *ext_param;
14324
14325 buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
14326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14327 sizeof(*ext_param));
14328 buf_ptr += WMI_TLV_HDR_SIZE;
14329
14330 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14331 WMITLV_SET_HDR(&ext_param->tlv_header,
14332 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14333 WMITLV_GET_STRUCT_TLVLEN(
14334 wmi_gtk_offload_fils_tlv_param));
14335 ext_param->vdev_id = vdev_id;
14336 ext_param->flags = cmd->flags;
14337 ext_param->kek_len = params->kek_len;
14338 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14339 qdf_mem_copy(ext_param->KCK, params->kck,
14340 WMI_GTK_OFFLOAD_KCK_BYTES);
14341 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14342 GTK_REPLAY_COUNTER_BYTES);
14343}
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014344
14345/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014346 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14347 * @wmi_handle: wmi handle
14348 * @vdev_id: vdev id
14349 * @params: GTK offload parameters
14350 *
14351 * Return: CDF status
14352 */
14353static
14354QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14355 struct pmo_gtk_req *params,
14356 bool enable_offload,
14357 uint32_t gtk_offload_opcode)
14358{
14359 int len;
14360 wmi_buf_t buf;
14361 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14362 QDF_STATUS status = QDF_STATUS_SUCCESS;
14363
14364 WMI_LOGD("%s Enter", __func__);
14365
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014366 len = sizeof(*cmd);
14367
14368 if (params->is_fils_connection)
14369 len += WMI_TLV_HDR_SIZE +
14370 sizeof(wmi_gtk_offload_fils_tlv_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014371
14372 /* alloc wmi buffer */
14373 buf = wmi_buf_alloc(wmi_handle, len);
14374 if (!buf) {
14375 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14376 status = QDF_STATUS_E_NOMEM;
14377 goto out;
14378 }
14379
14380 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14381 WMITLV_SET_HDR(&cmd->tlv_header,
14382 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14383 WMITLV_GET_STRUCT_TLVLEN
14384 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14385
14386 cmd->vdev_id = vdev_id;
14387
14388 /* Request target to enable GTK offload */
14389 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14390 cmd->flags = gtk_offload_opcode;
14391
14392 /* Copy the keys and replay counter */
14393 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014394 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014395 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14396 GTK_REPLAY_COUNTER_BYTES);
14397 } else {
14398 cmd->flags = gtk_offload_opcode;
14399 }
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014400 if (params->is_fils_connection)
14401 fill_fils_tlv_params(cmd, vdev_id, params);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014402
14403 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x kek len %d", vdev_id, cmd->flags, params->kek_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014404 /* send the wmi command */
14405 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14406 WMI_GTK_OFFLOAD_CMDID)) {
14407 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14408 wmi_buf_free(buf);
14409 status = QDF_STATUS_E_FAILURE;
14410 }
14411
14412out:
14413 WMI_LOGD("%s Exit", __func__);
14414 return status;
14415}
14416
14417/**
14418 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14419 * @wmi_handle: wmi handle
14420 * @params: GTK offload params
14421 *
14422 * Return: CDF status
14423 */
14424static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14425 wmi_unified_t wmi_handle,
14426 uint8_t vdev_id,
14427 uint64_t offload_req_opcode)
14428{
14429 int len;
14430 wmi_buf_t buf;
14431 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14432 QDF_STATUS status = QDF_STATUS_SUCCESS;
14433
14434 len = sizeof(*cmd);
14435
14436 /* alloc wmi buffer */
14437 buf = wmi_buf_alloc(wmi_handle, len);
14438 if (!buf) {
14439 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14440 status = QDF_STATUS_E_NOMEM;
14441 goto out;
14442 }
14443
14444 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14445 WMITLV_SET_HDR(&cmd->tlv_header,
14446 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14447 WMITLV_GET_STRUCT_TLVLEN
14448 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14449
14450 /* Request for GTK offload status */
14451 cmd->flags = offload_req_opcode;
14452 cmd->vdev_id = vdev_id;
14453
14454 /* send the wmi command */
14455 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14456 WMI_GTK_OFFLOAD_CMDID)) {
14457 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14458 wmi_buf_free(buf);
14459 status = QDF_STATUS_E_FAILURE;
14460 }
14461
14462out:
14463 return status;
14464}
14465
14466/**
14467 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14468 * @wmi_handle: wmi handler
14469 * @action_params: pointer to action_params
14470 *
14471 * Return: 0 for success, otherwise appropriate error code
14472 */
14473static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14474 struct pmo_action_wakeup_set_params *action_params)
14475{
14476 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14477 wmi_buf_t buf;
14478 int i;
14479 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014480 uint32_t len = 0, *cmd_args;
14481 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014482
Vivekc5823092018-03-22 23:27:21 +053014483 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014484 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14485 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014486 if (!buf) {
14487 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14488 return QDF_STATUS_E_NOMEM;
14489 }
14490 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014491 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014492 WMITLV_SET_HDR(&cmd->tlv_header,
14493 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14494 WMITLV_GET_STRUCT_TLVLEN(
14495 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14496
14497 cmd->vdev_id = action_params->vdev_id;
14498 cmd->operation = action_params->operation;
14499
14500 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14501 cmd->action_category_map[i] =
14502 action_params->action_category_map[i];
14503
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014504 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014506 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014507 buf_ptr += WMI_TLV_HDR_SIZE;
14508 cmd_args = (uint32_t *) buf_ptr;
14509 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14510 cmd_args[i] = action_params->action_per_category[i];
14511
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014512 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014513 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014514 if (err) {
14515 WMI_LOGE("Failed to send ap_ps_egap cmd");
14516 wmi_buf_free(buf);
14517 return QDF_STATUS_E_FAILURE;
14518 }
14519
14520 return QDF_STATUS_SUCCESS;
14521}
14522
14523#ifdef FEATURE_WLAN_LPHB
14524
14525/**
14526 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14527 * @wmi_handle: wmi handle
14528 * @lphb_conf_req: configuration info
14529 *
14530 * Return: CDF status
14531 */
14532static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14533 wmi_hb_set_enable_cmd_fixed_param *params)
14534{
14535 QDF_STATUS status;
14536 wmi_buf_t buf = NULL;
14537 uint8_t *buf_ptr;
14538 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14539 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14540
14541
14542 buf = wmi_buf_alloc(wmi_handle, len);
14543 if (!buf) {
14544 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14545 return QDF_STATUS_E_NOMEM;
14546 }
14547
14548 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14549 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14550 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14551 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14552 WMITLV_GET_STRUCT_TLVLEN
14553 (wmi_hb_set_enable_cmd_fixed_param));
14554
14555 /* fill in values */
14556 hb_enable_fp->vdev_id = params->session;
14557 hb_enable_fp->enable = params->enable;
14558 hb_enable_fp->item = params->item;
14559 hb_enable_fp->session = params->session;
14560
14561 status = wmi_unified_cmd_send(wmi_handle, buf,
14562 len, WMI_HB_SET_ENABLE_CMDID);
14563 if (QDF_IS_STATUS_ERROR(status)) {
14564 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14565 status);
14566 wmi_buf_free(buf);
14567 }
14568
14569 return status;
14570}
14571
14572/**
14573 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14574 * @wmi_handle: wmi handle
14575 * @lphb_conf_req: lphb config request
14576 *
14577 * Return: CDF status
14578 */
14579static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14580 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14581{
14582 QDF_STATUS status;
14583 wmi_buf_t buf = NULL;
14584 uint8_t *buf_ptr;
14585 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14586 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14587
14588 buf = wmi_buf_alloc(wmi_handle, len);
14589 if (!buf) {
14590 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14591 return QDF_STATUS_E_NOMEM;
14592 }
14593
14594 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14595 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14596 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14597 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14598 WMITLV_GET_STRUCT_TLVLEN
14599 (wmi_hb_set_tcp_params_cmd_fixed_param));
14600
14601 /* fill in values */
14602 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14603 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14604 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14605 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14606 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14607 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14608 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14609 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14610 hb_tcp_params_fp->session = lphb_conf_req->session;
14611 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14612 &lphb_conf_req->gateway_mac,
14613 sizeof(hb_tcp_params_fp->gateway_mac));
14614
14615 status = wmi_unified_cmd_send(wmi_handle, buf,
14616 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14617 if (QDF_IS_STATUS_ERROR(status)) {
14618 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14619 status);
14620 wmi_buf_free(buf);
14621 }
14622
14623 return status;
14624}
14625
14626/**
14627 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14628 * @wmi_handle: wmi handle
14629 * @lphb_conf_req: lphb config request
14630 *
14631 * Return: CDF status
14632 */
14633static
14634QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14635 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14636{
14637 QDF_STATUS status;
14638 wmi_buf_t buf = NULL;
14639 uint8_t *buf_ptr;
14640 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14641 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14642
14643 buf = wmi_buf_alloc(wmi_handle, len);
14644 if (!buf) {
14645 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14646 return QDF_STATUS_E_NOMEM;
14647 }
14648
14649 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14650 hb_tcp_filter_fp =
14651 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14652 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14653 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14654 WMITLV_GET_STRUCT_TLVLEN
14655 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14656
14657 /* fill in values */
14658 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14659 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14660 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14661 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14662 memcpy((void *)&hb_tcp_filter_fp->filter,
14663 (void *)&g_hb_tcp_filter_fp->filter,
14664 WMI_WLAN_HB_MAX_FILTER_SIZE);
14665
14666 status = wmi_unified_cmd_send(wmi_handle, buf,
14667 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14668 if (QDF_IS_STATUS_ERROR(status)) {
14669 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14670 status);
14671 wmi_buf_free(buf);
14672 }
14673
14674 return status;
14675}
14676
14677/**
14678 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14679 * @wmi_handle: wmi handle
14680 * @lphb_conf_req: lphb config request
14681 *
14682 * Return: CDF status
14683 */
14684static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14685 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14686{
14687 QDF_STATUS status;
14688 wmi_buf_t buf = NULL;
14689 uint8_t *buf_ptr;
14690 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14691 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14692
14693 buf = wmi_buf_alloc(wmi_handle, len);
14694 if (!buf) {
14695 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14696 return QDF_STATUS_E_NOMEM;
14697 }
14698
14699 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14700 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14701 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14702 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14703 WMITLV_GET_STRUCT_TLVLEN
14704 (wmi_hb_set_udp_params_cmd_fixed_param));
14705
14706 /* fill in values */
14707 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14708 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14709 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14710 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14711 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14712 hb_udp_params_fp->interval = lphb_conf_req->interval;
14713 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14714 hb_udp_params_fp->session = lphb_conf_req->session;
14715 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14716 &lphb_conf_req->gateway_mac,
14717 sizeof(lphb_conf_req->gateway_mac));
14718
14719 status = wmi_unified_cmd_send(wmi_handle, buf,
14720 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14721 if (QDF_IS_STATUS_ERROR(status)) {
14722 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14723 status);
14724 wmi_buf_free(buf);
14725 }
14726
14727 return status;
14728}
14729
14730/**
14731 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14732 * @wmi_handle: wmi handle
14733 * @lphb_conf_req: lphb config request
14734 *
14735 * Return: CDF status
14736 */
14737static
14738QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14739 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14740{
14741 QDF_STATUS status;
14742 wmi_buf_t buf = NULL;
14743 uint8_t *buf_ptr;
14744 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14745 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14746
14747 buf = wmi_buf_alloc(wmi_handle, len);
14748 if (!buf) {
14749 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14750 return QDF_STATUS_E_NOMEM;
14751 }
14752
14753 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14754 hb_udp_filter_fp =
14755 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14756 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14757 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14758 WMITLV_GET_STRUCT_TLVLEN
14759 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14760
14761 /* fill in values */
14762 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14763 hb_udp_filter_fp->length = lphb_conf_req->length;
14764 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14765 hb_udp_filter_fp->session = lphb_conf_req->session;
14766 memcpy((void *)&hb_udp_filter_fp->filter,
14767 (void *)&lphb_conf_req->filter,
14768 WMI_WLAN_HB_MAX_FILTER_SIZE);
14769
14770 status = wmi_unified_cmd_send(wmi_handle, buf,
14771 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14772 if (QDF_IS_STATUS_ERROR(status)) {
14773 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14774 status);
14775 wmi_buf_free(buf);
14776 }
14777
14778 return status;
14779}
14780#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014781
Dustin Brownf31f88b2017-05-12 14:01:44 -070014782static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14783 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014784{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014785 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014786 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014787 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014788
Dustin Brownf31f88b2017-05-12 14:01:44 -070014789 if (!req) {
14790 WMI_LOGE("req is null");
14791 return QDF_STATUS_E_INVAL;
14792 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014793
Dustin Brownf31f88b2017-05-12 14:01:44 -070014794 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14795 if (!wmi_buf) {
14796 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014797 return QDF_STATUS_E_NOMEM;
14798 }
14799
Dustin Brownf31f88b2017-05-12 14:01:44 -070014800 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014801 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014802 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14803 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14804 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014805 cmd->enable = req->enable;
14806 /* Set all modes in case of disable */
14807 if (!cmd->enable)
14808 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14809 else
14810 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014811
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014812 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14813 req->enable ? "enable" : "disable", req->mode_bitmap,
14814 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014815
Dustin Brownf31f88b2017-05-12 14:01:44 -070014816 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14817 WMI_HW_DATA_FILTER_CMDID);
14818 if (QDF_IS_STATUS_ERROR(status)) {
14819 WMI_LOGE("Failed to configure hw filter");
14820 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014821 }
14822
Dustin Brownf31f88b2017-05-12 14:01:44 -070014823 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014824}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014825
14826/**
14827 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14828 * @wmi_handle: wmi handle
14829 * @vdev_id: vdev id
14830 * @enable: Flag to enable/disable packet filter
14831 *
14832 * Return: QDF_STATUS_SUCCESS for success or error code
14833 */
14834static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14835 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14836{
14837 int32_t len;
14838 int ret = 0;
14839 wmi_buf_t buf;
14840 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14841
14842 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14843
14844 buf = wmi_buf_alloc(wmi_handle, len);
14845 if (!buf) {
14846 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14847 return QDF_STATUS_E_NOMEM;
14848 }
14849
14850 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14851 WMITLV_SET_HDR(&cmd->tlv_header,
14852 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14853 WMITLV_GET_STRUCT_TLVLEN(
14854 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14855
14856 cmd->vdev_id = vdev_id;
14857 if (enable)
14858 cmd->enable = PACKET_FILTER_SET_ENABLE;
14859 else
14860 cmd->enable = PACKET_FILTER_SET_DISABLE;
14861
14862 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14863 __func__, cmd->enable, vdev_id);
14864
14865 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14866 WMI_PACKET_FILTER_ENABLE_CMDID);
14867 if (ret) {
14868 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14869 wmi_buf_free(buf);
14870 }
14871
14872 return ret;
14873}
14874
14875/**
14876 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14877 * @wmi_handle: wmi handle
14878 * @vdev_id: vdev id
14879 * @rcv_filter_param: Packet filter parameters
14880 * @filter_id: Filter id
14881 * @enable: Flag to add/delete packet filter configuration
14882 *
14883 * Return: QDF_STATUS_SUCCESS for success or error code
14884 */
14885static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14886 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14887 uint8_t filter_id, bool enable)
14888{
14889 int len, i;
14890 int err = 0;
14891 wmi_buf_t buf;
14892 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14893
14894
14895 /* allocate the memory */
14896 len = sizeof(*cmd);
14897 buf = wmi_buf_alloc(wmi_handle, len);
14898 if (!buf) {
14899 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14900 return QDF_STATUS_E_NOMEM;
14901 }
14902
14903 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14904 WMITLV_SET_HDR(&cmd->tlv_header,
14905 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14906 WMITLV_GET_STRUCT_TLVLEN
14907 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14908
14909 cmd->vdev_id = vdev_id;
14910 cmd->filter_id = filter_id;
14911 if (enable)
14912 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14913 else
14914 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14915
14916 if (enable) {
14917 cmd->num_params = QDF_MIN(
14918 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14919 rcv_filter_param->num_params);
14920 cmd->filter_type = rcv_filter_param->filter_type;
14921 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14922
14923 for (i = 0; i < cmd->num_params; i++) {
14924 cmd->paramsData[i].proto_type =
14925 rcv_filter_param->params_data[i].protocol_layer;
14926 cmd->paramsData[i].cmp_type =
14927 rcv_filter_param->params_data[i].compare_flag;
14928 cmd->paramsData[i].data_length =
14929 rcv_filter_param->params_data[i].data_length;
14930 cmd->paramsData[i].data_offset =
14931 rcv_filter_param->params_data[i].data_offset;
14932 memcpy(&cmd->paramsData[i].compareData,
14933 rcv_filter_param->params_data[i].compare_data,
14934 sizeof(cmd->paramsData[i].compareData));
14935 memcpy(&cmd->paramsData[i].dataMask,
14936 rcv_filter_param->params_data[i].data_mask,
14937 sizeof(cmd->paramsData[i].dataMask));
14938 }
14939 }
14940
14941 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14942 cmd->filter_action, cmd->filter_id, cmd->num_params);
14943 /* send the command along with data */
14944 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14945 WMI_PACKET_FILTER_CONFIG_CMDID);
14946 if (err) {
14947 WMI_LOGE("Failed to send pkt_filter cmd");
14948 wmi_buf_free(buf);
14949 return QDF_STATUS_E_FAILURE;
14950 }
14951
14952 return QDF_STATUS_SUCCESS;
14953}
Wu Gao52c0b772018-05-17 16:14:00 +080014954#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014955
Govind Singha4836fd2016-03-07 16:45:38 +053014956/**
14957 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14958 * @wmi_handle: wmi handle
14959 * @request: SSID hotlist set request
14960 *
Govind Singhb53420c2016-03-09 14:32:57 +053014961 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014962 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014963static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014964send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14965 struct ssid_hotlist_request_params *request)
14966{
14967 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14968 wmi_buf_t wmi_buf;
14969 uint32_t len;
14970 uint32_t array_size;
14971 uint8_t *buf_ptr;
14972
14973 /* length of fixed portion */
14974 len = sizeof(*cmd);
14975
14976 /* length of variable portion */
14977 array_size =
14978 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14979 len += WMI_TLV_HDR_SIZE + array_size;
14980
14981 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14982 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014983 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14984 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014985 }
14986
14987 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14988 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14989 buf_ptr;
14990 WMITLV_SET_HDR
14991 (&cmd->tlv_header,
14992 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14993 WMITLV_GET_STRUCT_TLVLEN
14994 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14995
14996 cmd->request_id = request->request_id;
14997 cmd->requestor_id = 0;
14998 cmd->vdev_id = request->session_id;
14999 cmd->table_id = 0;
15000 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15001 cmd->total_entries = request->ssid_count;
15002 cmd->num_entries_in_page = request->ssid_count;
15003 cmd->first_entry_index = 0;
15004
15005 buf_ptr += sizeof(*cmd);
15006 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15007
15008 if (request->ssid_count) {
15009 wmi_extscan_hotlist_ssid_entry *entry;
15010 int i;
15011
15012 buf_ptr += WMI_TLV_HDR_SIZE;
15013 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15014 for (i = 0; i < request->ssid_count; i++) {
15015 WMITLV_SET_HDR
15016 (entry,
15017 WMITLV_TAG_ARRAY_STRUC,
15018 WMITLV_GET_STRUCT_TLVLEN
15019 (wmi_extscan_hotlist_ssid_entry));
15020 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015021 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015022 request->ssids[i].ssid.mac_ssid,
15023 request->ssids[i].ssid.length);
15024 entry->band = request->ssids[i].band;
15025 entry->min_rssi = request->ssids[i].rssi_low;
15026 entry->max_rssi = request->ssids[i].rssi_high;
15027 entry++;
15028 }
15029 cmd->mode = WMI_EXTSCAN_MODE_START;
15030 } else {
15031 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15032 }
15033
15034 if (wmi_unified_cmd_send
15035 (wmi_handle, wmi_buf, len,
15036 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015037 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015038 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015039 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015040 }
15041
Govind Singhb53420c2016-03-09 14:32:57 +053015042 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015043}
15044
15045/**
15046 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15047 * @wmi_handle: wmi handle
15048 * @vdev_id: vdev id
15049 *
15050 * This function sends roam synch complete event to fw.
15051 *
15052 * Return: CDF STATUS
15053 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015054static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015055 uint8_t vdev_id)
15056{
15057 wmi_roam_synch_complete_fixed_param *cmd;
15058 wmi_buf_t wmi_buf;
15059 uint8_t *buf_ptr;
15060 uint16_t len;
15061 len = sizeof(wmi_roam_synch_complete_fixed_param);
15062
15063 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15064 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015065 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15066 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015067 }
15068 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15069 buf_ptr = (uint8_t *) cmd;
15070 WMITLV_SET_HDR(&cmd->tlv_header,
15071 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15072 WMITLV_GET_STRUCT_TLVLEN
15073 (wmi_roam_synch_complete_fixed_param));
15074 cmd->vdev_id = vdev_id;
15075 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15076 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015077 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015078 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015079 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015080 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015081 }
15082
Govind Singhb53420c2016-03-09 14:32:57 +053015083 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015084}
15085
15086/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015087 * send_fw_test_cmd_tlv() - send fw test command to fw.
15088 * @wmi_handle: wmi handle
15089 * @wmi_fwtest: fw test command
15090 *
15091 * This function sends fw test command to fw.
15092 *
15093 * Return: CDF STATUS
15094 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015095static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015096QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15097 struct set_fwtest_params *wmi_fwtest)
15098{
15099 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15100 wmi_buf_t wmi_buf;
15101 uint16_t len;
15102
15103 len = sizeof(*cmd);
15104
15105 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15106 if (!wmi_buf) {
15107 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15108 return QDF_STATUS_E_NOMEM;
15109 }
15110
15111 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15112 WMITLV_SET_HDR(&cmd->tlv_header,
15113 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15114 WMITLV_GET_STRUCT_TLVLEN(
15115 wmi_fwtest_set_param_cmd_fixed_param));
15116 cmd->param_id = wmi_fwtest->arg;
15117 cmd->param_value = wmi_fwtest->value;
15118
15119 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15120 WMI_FWTEST_CMDID)) {
15121 WMI_LOGP("%s: failed to send fw test command", __func__);
15122 qdf_nbuf_free(wmi_buf);
15123 return QDF_STATUS_E_FAILURE;
15124 }
15125
15126 return QDF_STATUS_SUCCESS;
15127}
15128
15129/**
Govind Singha4836fd2016-03-07 16:45:38 +053015130 * send_unit_test_cmd_tlv() - send unit test command to fw.
15131 * @wmi_handle: wmi handle
15132 * @wmi_utest: unit test command
15133 *
15134 * This function send unit test command to fw.
15135 *
15136 * Return: CDF STATUS
15137 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015138static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015139 struct wmi_unit_test_cmd *wmi_utest)
15140{
15141 wmi_unit_test_cmd_fixed_param *cmd;
15142 wmi_buf_t wmi_buf;
15143 uint8_t *buf_ptr;
15144 int i;
15145 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015146 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015147
15148 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015149 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015150 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15151
15152 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15153 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015154 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15155 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015156 }
15157
15158 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15159 buf_ptr = (uint8_t *) cmd;
15160 WMITLV_SET_HDR(&cmd->tlv_header,
15161 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15162 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15163 cmd->vdev_id = wmi_utest->vdev_id;
15164 cmd->module_id = wmi_utest->module_id;
15165 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015166 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015167 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15169 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015170 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015171 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15172 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15173 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015174 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015175 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015176 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015177 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015178 }
15179 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15180 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015181 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015182 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015183 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015184 }
15185
Govind Singhb53420c2016-03-09 14:32:57 +053015186 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015187}
15188
15189/**
15190 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15191 * @wmi_handle: wma handle
15192 * @roaminvoke: roam invoke command
15193 *
15194 * Send roam invoke command to fw for fastreassoc.
15195 *
15196 * Return: CDF STATUS
15197 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015198static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015199 struct wmi_roam_invoke_cmd *roaminvoke,
15200 uint32_t ch_hz)
15201{
15202 wmi_roam_invoke_cmd_fixed_param *cmd;
15203 wmi_buf_t wmi_buf;
15204 u_int8_t *buf_ptr;
15205 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015206 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015207 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015208 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015209
15210 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015211 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015212 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15213 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015214 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15215 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15216 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015217 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15218 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015219 }
15220
15221 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15222 buf_ptr = (u_int8_t *) cmd;
15223 WMITLV_SET_HDR(&cmd->tlv_header,
15224 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15225 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15226 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015227 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015228 if (roaminvoke->is_same_bssid)
15229 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15230 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015231
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015232 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015233 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015234 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15235 cmd->num_buf = 1;
15236 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015237 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015238 cmd->num_buf = 0;
15239 }
Naveen Rawat77797922017-01-20 17:00:07 -080015240
Govind Singha4836fd2016-03-07 16:45:38 +053015241 cmd->roam_ap_sel_mode = 0;
15242 cmd->roam_delay = 0;
15243 cmd->num_chan = 1;
15244 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015245
Govind Singha4836fd2016-03-07 16:45:38 +053015246 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15247 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15248 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015249 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015250 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015251 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015252 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15253 (sizeof(wmi_mac_addr)));
15254 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15255 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015256
15257 /* move to next tlv i.e. bcn_prb_buf_list */
15258 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15259
15260 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15261 sizeof(wmi_tlv_buf_len_param));
15262
15263 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15264 buf_len_tlv->buf_len = roaminvoke->frame_len;
15265
15266 /* move to next tlv i.e. bcn_prb_frm */
15267 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15269 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15270
15271 /* copy frame after the header */
15272 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15273 roaminvoke->frame_buf,
15274 roaminvoke->frame_len);
15275
15276 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015277 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015278 buf_ptr + WMI_TLV_HDR_SIZE,
15279 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015280 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15281 cmd->flags, cmd->roam_scan_mode,
15282 cmd->roam_ap_sel_mode, cmd->roam_delay,
15283 cmd->num_chan, cmd->num_bssid);
15284 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015285
Govind Singha4836fd2016-03-07 16:45:38 +053015286 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15287 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015288 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015289 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015290 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015291 }
15292
Govind Singhb53420c2016-03-09 14:32:57 +053015293 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015294}
15295
15296/**
15297 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15298 * @wmi_handle: wmi handle
15299 * @command: command
15300 * @vdev_id: vdev id
15301 *
15302 * This function set roam offload command to fw.
15303 *
15304 * Return: CDF status
15305 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015306static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015307 uint32_t command, uint32_t vdev_id)
15308{
Govind Singh67922e82016-04-01 16:48:57 +053015309 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015310 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15311 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015312 int len;
15313 uint8_t *buf_ptr;
15314
15315 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15316 buf = wmi_buf_alloc(wmi_handle, len);
15317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015318 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15319 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015320 }
15321
15322 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15323
15324 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15325 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15326 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15327 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15328 cmd_fp->vdev_id = vdev_id;
15329 cmd_fp->command_arg = command;
15330
15331 status = wmi_unified_cmd_send(wmi_handle, buf,
15332 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015333 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015334 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015335 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015336 goto error;
15337 }
15338
Govind Singhb53420c2016-03-09 14:32:57 +053015339 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15340 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015341
15342error:
15343 wmi_buf_free(buf);
15344
Govind Singh67922e82016-04-01 16:48:57 +053015345 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015346}
15347
15348/**
15349 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15350 * @wmi_handle: wmi handle
15351 * @ap_profile_p: ap profile
15352 * @vdev_id: vdev id
15353 *
15354 * Send WMI_ROAM_AP_PROFILE to firmware
15355 *
15356 * Return: CDF status
15357 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015358static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015359 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015360{
Govind Singha4836fd2016-03-07 16:45:38 +053015361 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015362 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015363 int len;
15364 uint8_t *buf_ptr;
15365 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015366 wmi_roam_cnd_scoring_param *score_param;
15367 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015368
15369 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015370 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015371 buf = wmi_buf_alloc(wmi_handle, len);
15372 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015373 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15374 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015375 }
15376
15377 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15378 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15379 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15380 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15381 WMITLV_GET_STRUCT_TLVLEN
15382 (wmi_roam_ap_profile_fixed_param));
15383 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015384 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015385 roam_ap_profile_fp->id = 0;
15386 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15387
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015388 profile = (wmi_ap_profile *)buf_ptr;
15389 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015390 WMITLV_TAG_STRUC_wmi_ap_profile,
15391 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015392 profile->flags = ap_profile->profile.flags;
15393 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15394 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15395 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15396 profile->ssid.ssid_len);
15397 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15398 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15399 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15400 profile->rsn_mcastmgmtcipherset =
15401 ap_profile->profile.rsn_mcastmgmtcipherset;
15402 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15403
15404 WMI_LOGD("AP profile: flags %x rssi_threshold %d ssid:%.*s authmode %d uc cipher %d mc cipher %d mc mgmt cipher %d rssi abs thresh %d",
15405 profile->flags, profile->rssi_threshold,
15406 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15407 profile->rsn_authmode, profile->rsn_ucastcipherset,
15408 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15409 profile->rssi_abs_thresh);
15410
15411 buf_ptr += sizeof(wmi_ap_profile);
15412
15413 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15414 WMITLV_SET_HDR(&score_param->tlv_header,
15415 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15416 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15417 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15418 score_param->rssi_weightage_pcnt =
15419 ap_profile->param.rssi_weightage;
15420 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15421 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15422 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15423 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15424 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15425 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15426 score_param->esp_qbss_weightage_pcnt =
15427 ap_profile->param.esp_qbss_weightage;
15428 score_param->beamforming_weightage_pcnt =
15429 ap_profile->param.beamforming_weightage;
15430 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15431 score_param->oce_wan_weightage_pcnt =
15432 ap_profile->param.oce_wan_weightage;
15433
15434 WMI_LOGD("Score params weightage: disable_bitmap %x rssi %d ht %d vht %d he %d BW %d band %d NSS %d ESP %d BF %d PCL %d OCE WAN %d",
15435 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15436 score_param->ht_weightage_pcnt,
15437 score_param->vht_weightage_pcnt,
15438 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15439 score_param->band_weightage_pcnt,
15440 score_param->nss_weightage_pcnt,
15441 score_param->esp_qbss_weightage_pcnt,
15442 score_param->beamforming_weightage_pcnt,
15443 score_param->pcl_weightage_pcnt,
15444 score_param->oce_wan_weightage_pcnt);
15445
15446 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15447 score_param->band_scoring.score_pcnt =
15448 ap_profile->param.band_index_score;
15449 score_param->nss_scoring.score_pcnt =
15450 ap_profile->param.nss_index_score;
15451
15452 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15453 score_param->bw_scoring.score_pcnt,
15454 score_param->band_scoring.score_pcnt,
15455 score_param->nss_scoring.score_pcnt);
15456
15457 score_param->rssi_scoring.best_rssi_threshold =
15458 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15459 score_param->rssi_scoring.good_rssi_threshold =
15460 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15461 score_param->rssi_scoring.bad_rssi_threshold =
15462 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15463 score_param->rssi_scoring.good_rssi_pcnt =
15464 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15465 score_param->rssi_scoring.bad_rssi_pcnt =
15466 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15467 score_param->rssi_scoring.good_bucket_size =
15468 ap_profile->param.rssi_scoring.good_bucket_size;
15469 score_param->rssi_scoring.bad_bucket_size =
15470 ap_profile->param.rssi_scoring.bad_bucket_size;
15471 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15472 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15473
15474 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15475 score_param->rssi_scoring.best_rssi_threshold,
15476 score_param->rssi_scoring.good_rssi_threshold,
15477 score_param->rssi_scoring.bad_rssi_threshold,
15478 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15479 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15480 score_param->rssi_scoring.good_rssi_pcnt,
15481 score_param->rssi_scoring.bad_rssi_pcnt,
15482 score_param->rssi_scoring.good_bucket_size,
15483 score_param->rssi_scoring.bad_bucket_size);
15484
15485 score_param->esp_qbss_scoring.num_slot =
15486 ap_profile->param.esp_qbss_scoring.num_slot;
15487 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15488 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15489 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15490 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15491 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15492 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15493 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15494 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15495
15496 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15497 score_param->esp_qbss_scoring.num_slot,
15498 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15499 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15500 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15501 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15502
15503 score_param->oce_wan_scoring.num_slot =
15504 ap_profile->param.oce_wan_scoring.num_slot;
15505 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15506 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15507 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15508 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15509 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15510 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15511 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15512 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15513
15514 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15515 score_param->oce_wan_scoring.num_slot,
15516 score_param->oce_wan_scoring.score_pcnt3_to_0,
15517 score_param->oce_wan_scoring.score_pcnt7_to_4,
15518 score_param->oce_wan_scoring.score_pcnt11_to_8,
15519 score_param->oce_wan_scoring.score_pcnt15_to_12);
15520
Govind Singha4836fd2016-03-07 16:45:38 +053015521 status = wmi_unified_cmd_send(wmi_handle, buf,
15522 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015523 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015524 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015525 status);
Govind Singh67922e82016-04-01 16:48:57 +053015526 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015527 }
15528
Govind Singhb53420c2016-03-09 14:32:57 +053015529 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015530
Govind Singh67922e82016-04-01 16:48:57 +053015531 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015532}
15533
15534/**
15535 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15536 * @wmi_handle: wmi handle
15537 * @scan_period: scan period
15538 * @scan_age: scan age
15539 * @vdev_id: vdev id
15540 *
15541 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15542 *
15543 * Return: CDF status
15544 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015545static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015546 uint32_t scan_period,
15547 uint32_t scan_age,
15548 uint32_t vdev_id)
15549{
Govind Singh67922e82016-04-01 16:48:57 +053015550 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015551 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015552 int len;
15553 uint8_t *buf_ptr;
15554 wmi_roam_scan_period_fixed_param *scan_period_fp;
15555
15556 /* Send scan period values */
15557 len = sizeof(wmi_roam_scan_period_fixed_param);
15558 buf = wmi_buf_alloc(wmi_handle, len);
15559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015560 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15561 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015562 }
15563
15564 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15565 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15566 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15567 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15568 WMITLV_GET_STRUCT_TLVLEN
15569 (wmi_roam_scan_period_fixed_param));
15570 /* fill in scan period values */
15571 scan_period_fp->vdev_id = vdev_id;
15572 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15573 scan_period_fp->roam_scan_age = scan_age;
15574
15575 status = wmi_unified_cmd_send(wmi_handle, buf,
15576 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015577 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015578 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015579 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015580 goto error;
15581 }
15582
Govind Singhb53420c2016-03-09 14:32:57 +053015583 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015584 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015585 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015586error:
15587 wmi_buf_free(buf);
15588
Govind Singh67922e82016-04-01 16:48:57 +053015589 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015590}
15591
15592/**
15593 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15594 * @wmi_handle: wmi handle
15595 * @chan_count: channel count
15596 * @chan_list: channel list
15597 * @list_type: list type
15598 * @vdev_id: vdev id
15599 *
15600 * Set roam offload channel list.
15601 *
15602 * Return: CDF status
15603 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015604static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015605 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015606 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015607 uint8_t list_type, uint32_t vdev_id)
15608{
Govind Singha4836fd2016-03-07 16:45:38 +053015609 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015610 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015611 int len, list_tlv_len;
15612 int i;
15613 uint8_t *buf_ptr;
15614 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015615 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015616
15617 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015618 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015619 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015620 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015621 }
15622 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015623 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015624 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15625 buf = wmi_buf_alloc(wmi_handle, len);
15626 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015627 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15628 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015629 }
15630
15631 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15632 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15633 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15634 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15635 WMITLV_GET_STRUCT_TLVLEN
15636 (wmi_roam_chan_list_fixed_param));
15637 chan_list_fp->vdev_id = vdev_id;
15638 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015639 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015640 /* external app is controlling channel list */
15641 chan_list_fp->chan_list_type =
15642 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15643 } else {
15644 /* umac supplied occupied channel list in LFR */
15645 chan_list_fp->chan_list_type =
15646 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15647 }
15648
15649 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15651 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015652 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015653 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015654 for (i = 0; ((i < chan_list_fp->num_chan) &&
15655 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15656 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015657 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015658 }
15659
15660 status = wmi_unified_cmd_send(wmi_handle, buf,
15661 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015662 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015663 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015664 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015665 goto error;
15666 }
15667
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015668 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015669 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015670error:
15671 wmi_buf_free(buf);
15672
Govind Singh67922e82016-04-01 16:48:57 +053015673 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015674}
15675
15676/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015677 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15678 * @wmi_handle: wmi handle
15679 * @req_buf: per roam config buffer
15680 *
15681 * Return: QDF status
15682 */
15683static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15684 struct wmi_per_roam_config_req *req_buf)
15685{
15686 wmi_buf_t buf = NULL;
15687 QDF_STATUS status;
15688 int len;
15689 uint8_t *buf_ptr;
15690 wmi_roam_per_config_fixed_param *wmi_per_config;
15691
15692 len = sizeof(wmi_roam_per_config_fixed_param);
15693 buf = wmi_buf_alloc(wmi_handle, len);
15694 if (!buf) {
15695 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15696 return QDF_STATUS_E_NOMEM;
15697 }
15698
15699 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15700 wmi_per_config =
15701 (wmi_roam_per_config_fixed_param *) buf_ptr;
15702 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15703 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15704 WMITLV_GET_STRUCT_TLVLEN
15705 (wmi_roam_per_config_fixed_param));
15706
15707 /* fill in per roam config values */
15708 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015709
15710 wmi_per_config->enable = req_buf->per_config.enable;
15711 wmi_per_config->high_rate_thresh =
15712 (req_buf->per_config.tx_high_rate_thresh << 16) |
15713 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15714 wmi_per_config->low_rate_thresh =
15715 (req_buf->per_config.tx_low_rate_thresh << 16) |
15716 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15717 wmi_per_config->pkt_err_rate_thresh_pct =
15718 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15719 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15720 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015721 wmi_per_config->pkt_err_rate_mon_time =
15722 (req_buf->per_config.tx_per_mon_time << 16) |
15723 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015724 wmi_per_config->min_candidate_rssi =
15725 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015726
15727 /* Send per roam config parameters */
15728 status = wmi_unified_cmd_send(wmi_handle, buf,
15729 len, WMI_ROAM_PER_CONFIG_CMDID);
15730 if (QDF_IS_STATUS_ERROR(status)) {
15731 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15732 status);
15733 wmi_buf_free(buf);
15734 return status;
15735 }
15736
15737 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15738 req_buf->per_config.enable, req_buf->vdev_id);
15739 return QDF_STATUS_SUCCESS;
15740}
15741
15742/**
Govind Singha4836fd2016-03-07 16:45:38 +053015743 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15744 * @wmi_handle: wmi handle
15745 * @rssi_change_thresh: RSSI Change threshold
15746 * @bcn_rssi_weight: beacon RSSI weight
15747 * @vdev_id: vdev id
15748 *
15749 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15750 *
15751 * Return: CDF status
15752 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015753static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015754 uint32_t vdev_id,
15755 int32_t rssi_change_thresh,
15756 uint32_t bcn_rssi_weight,
15757 uint32_t hirssi_delay_btw_scans)
15758{
Govind Singha4836fd2016-03-07 16:45:38 +053015759 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015760 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015761 int len;
15762 uint8_t *buf_ptr;
15763 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15764
15765 /* Send rssi change parameters */
15766 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15767 buf = wmi_buf_alloc(wmi_handle, len);
15768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015769 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15770 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015771 }
15772
15773 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15774 rssi_change_fp =
15775 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15776 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15777 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15778 WMITLV_GET_STRUCT_TLVLEN
15779 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15780 /* fill in rssi change threshold (hysteresis) values */
15781 rssi_change_fp->vdev_id = vdev_id;
15782 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15783 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15784 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15785
15786 status = wmi_unified_cmd_send(wmi_handle, buf,
15787 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015788 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015789 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015790 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015791 goto error;
15792 }
15793
Govind Singhb53420c2016-03-09 14:32:57 +053015794 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015795 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015796 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15797 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015798error:
15799 wmi_buf_free(buf);
15800
Govind Singh67922e82016-04-01 16:48:57 +053015801 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015802}
15803
Govind Singhbca3b1b2016-05-02 17:59:24 +053015804/**
15805 * send_power_dbg_cmd_tlv() - send power debug commands
15806 * @wmi_handle: wmi handle
15807 * @param: wmi power debug parameter
15808 *
15809 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15810 *
15811 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15812 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015813static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15814 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015815{
15816 wmi_buf_t buf = NULL;
15817 QDF_STATUS status;
15818 int len, args_tlv_len;
15819 uint8_t *buf_ptr;
15820 uint8_t i;
15821 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15822 uint32_t *cmd_args;
15823
15824 /* Prepare and send power debug cmd parameters */
15825 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15826 len = sizeof(*cmd) + args_tlv_len;
15827 buf = wmi_buf_alloc(wmi_handle, len);
15828 if (!buf) {
15829 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15830 return QDF_STATUS_E_NOMEM;
15831 }
15832
15833 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15834 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15835 WMITLV_SET_HDR(&cmd->tlv_header,
15836 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15837 WMITLV_GET_STRUCT_TLVLEN
15838 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15839
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015840 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15841 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015842 cmd->module_id = param->module_id;
15843 cmd->num_args = param->num_args;
15844 buf_ptr += sizeof(*cmd);
15845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15846 (param->num_args * sizeof(uint32_t)));
15847 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15848 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015849 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015850 cmd_args[i] = param->args[i];
15851 WMI_LOGI("%d,", param->args[i]);
15852 }
15853
15854 status = wmi_unified_cmd_send(wmi_handle, buf,
15855 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15856 if (QDF_IS_STATUS_ERROR(status)) {
15857 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15858 status);
15859 goto error;
15860 }
15861
15862 return QDF_STATUS_SUCCESS;
15863error:
15864 wmi_buf_free(buf);
15865
15866 return status;
15867}
15868
Govind Singhe7f2f342016-05-23 12:12:52 +053015869/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015870 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15871 * @wmi_handle: wmi handle
15872 * @param: wmi multiple vdev restart req param
15873 *
15874 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15875 *
15876 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15877 */
15878static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15879 wmi_unified_t wmi_handle,
15880 struct multiple_vdev_restart_params *param)
15881{
15882 wmi_buf_t buf;
15883 QDF_STATUS qdf_status;
15884 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15885 int i;
15886 uint8_t *buf_ptr;
15887 uint32_t *vdev_ids;
15888 wmi_channel *chan_info;
15889 struct channel_param *tchan_info;
15890 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15891
15892 len += sizeof(wmi_channel);
15893 if (param->num_vdevs)
15894 len += sizeof(uint32_t) * param->num_vdevs;
15895
15896 buf = wmi_buf_alloc(wmi_handle, len);
15897 if (!buf) {
15898 WMI_LOGE("Failed to allocate memory\n");
15899 qdf_status = QDF_STATUS_E_NOMEM;
15900 goto end;
15901 }
15902
15903 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15904 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15905 buf_ptr;
15906
15907 WMITLV_SET_HDR(&cmd->tlv_header,
15908 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15909 WMITLV_GET_STRUCT_TLVLEN
15910 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015911 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15912 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015913 cmd->requestor_id = param->requestor_id;
15914 cmd->disable_hw_ack = param->disable_hw_ack;
15915 cmd->cac_duration_ms = param->cac_duration_ms;
15916 cmd->num_vdevs = param->num_vdevs;
15917
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015918 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15919 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15920 " cmd->num_vdevs: %d ",
15921 __func__, cmd->pdev_id, cmd->requestor_id,
15922 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015923 buf_ptr += sizeof(*cmd);
15924
15925 WMITLV_SET_HDR(buf_ptr,
15926 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015927 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015928 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15929 for (i = 0; i < param->num_vdevs; i++) {
15930 vdev_ids[i] = param->vdev_ids[i];
15931 }
15932
Vivekc5823092018-03-22 23:27:21 +053015933 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015934
15935 WMITLV_SET_HDR(buf_ptr,
15936 WMITLV_TAG_STRUC_wmi_channel,
15937 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015938 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015939 tchan_info = &(param->ch_param);
15940 chan_info->mhz = tchan_info->mhz;
15941 chan_info->band_center_freq1 = tchan_info->cfreq1;
15942 chan_info->band_center_freq2 = tchan_info->cfreq2;
15943 if (tchan_info->is_chan_passive)
15944 WMI_SET_CHANNEL_FLAG(chan_info,
15945 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015946 if (tchan_info->dfs_set)
15947 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15948
Sathish Kumar45e991b2017-02-27 10:35:40 +053015949 if (tchan_info->allow_vht)
15950 WMI_SET_CHANNEL_FLAG(chan_info,
15951 WMI_CHAN_FLAG_ALLOW_VHT);
15952 else if (tchan_info->allow_ht)
15953 WMI_SET_CHANNEL_FLAG(chan_info,
15954 WMI_CHAN_FLAG_ALLOW_HT);
15955 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15956 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15957 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15958 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15959 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15960 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015961 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015962
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015963 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15964 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15965 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15966 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15967 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15968 "tchan_info->reg_class_id: %d ,"
15969 "tchan_info->maxregpower : %d ", __func__,
15970 tchan_info->is_chan_passive, tchan_info->dfs_set,
15971 tchan_info->allow_vht, tchan_info->allow_ht,
15972 tchan_info->antennamax, tchan_info->phy_mode,
15973 tchan_info->minpower, tchan_info->maxpower,
15974 tchan_info->maxregpower, tchan_info->reg_class_id,
15975 tchan_info->maxregpower);
15976
Sathish Kumar45e991b2017-02-27 10:35:40 +053015977 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15978 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15979
15980 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15981 WMI_LOGE("%s: Failed to send\n", __func__);
15982 wmi_buf_free(buf);
15983 }
15984
15985end:
15986 return qdf_status;
15987}
15988
15989/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015990 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15991 * @wmi_handle: wmi handle
15992 * @pdev_id: pdev id
15993 *
15994 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15995 *
15996 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15997 */
15998static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15999 uint32_t pdev_id)
16000{
16001 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16002 wmi_buf_t buf;
16003 uint16_t len;
16004 QDF_STATUS ret;
16005
16006 len = sizeof(*cmd);
16007 buf = wmi_buf_alloc(wmi_handle, len);
16008
16009 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16010
16011 if (!buf) {
16012 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16013 return QDF_STATUS_E_NOMEM;
16014 }
16015
16016 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16017 wmi_buf_data(buf);
16018
16019 WMITLV_SET_HDR(&cmd->tlv_header,
16020 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16021 WMITLV_GET_STRUCT_TLVLEN(
16022 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16023
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016024 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016025 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16026 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16027 if (QDF_IS_STATUS_ERROR(ret)) {
16028 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16029 __func__, ret, pdev_id);
16030 wmi_buf_free(buf);
16031 return QDF_STATUS_E_FAILURE;
16032 }
16033
16034 return QDF_STATUS_SUCCESS;
16035}
16036
16037/**
16038 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16039 * @wmi_handle: wmi handle
16040 * @pdev_id: pdev id
16041 *
16042 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16043 *
16044 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16045 */
16046static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16047 uint32_t pdev_id)
16048{
16049 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16050 wmi_buf_t buf;
16051 uint16_t len;
16052 QDF_STATUS ret;
16053
16054 len = sizeof(*cmd);
16055 buf = wmi_buf_alloc(wmi_handle, len);
16056
16057 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16058
16059 if (!buf) {
16060 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16061 return QDF_STATUS_E_NOMEM;
16062 }
16063
16064 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16065 wmi_buf_data(buf);
16066
16067 WMITLV_SET_HDR(&cmd->tlv_header,
16068 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16069 WMITLV_GET_STRUCT_TLVLEN(
16070 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16071
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016072 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016073 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16074 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16075 if (QDF_IS_STATUS_ERROR(ret)) {
16076 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16077 __func__, ret, pdev_id);
16078 wmi_buf_free(buf);
16079 return QDF_STATUS_E_FAILURE;
16080 }
16081
16082 return QDF_STATUS_SUCCESS;
16083}
16084
16085/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016086 * init_cmd_send_tlv() - send initialization cmd to fw
16087 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016088 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016089 *
16090 * Return: QDF_STATUS_SUCCESS for success or error code
16091 */
16092static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016093 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016094{
16095 wmi_buf_t buf;
16096 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016097 uint8_t *buf_ptr;
16098 wmi_resource_config *resource_cfg;
16099 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016100 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016101 uint16_t idx;
16102 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016103 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016104
Kiran Venkatappa26117052016-12-23 19:58:54 +053016105 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16106 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016107 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016108
16109 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16110 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16111 WMI_TLV_HDR_SIZE +
16112 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16113
16114 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016115 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016116 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053016117 return QDF_STATUS_E_FAILURE;
16118 }
16119
16120 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16121 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16122 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16123
16124 host_mem_chunks = (wlan_host_memory_chunk *)
16125 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16126 + WMI_TLV_HDR_SIZE);
16127
16128 WMITLV_SET_HDR(&cmd->tlv_header,
16129 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16130 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16131
Kiran Venkatappa26117052016-12-23 19:58:54 +053016132 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016133 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16134 WMITLV_TAG_STRUC_wmi_resource_config,
16135 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16136
Kiran Venkatappa26117052016-12-23 19:58:54 +053016137 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016138 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16139 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16140 WMITLV_GET_STRUCT_TLVLEN
16141 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016142 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16143 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16144 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016145 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16146 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016147 idx, host_mem_chunks[idx].size,
16148 host_mem_chunks[idx].ptr);
16149 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016150 cmd->num_host_mem_chunks = param->num_mem_chunks;
16151 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16152
Govind Singhe7f2f342016-05-23 12:12:52 +053016153 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16154 WMITLV_TAG_ARRAY_STRUC,
16155 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016156 param->num_mem_chunks));
16157
16158 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016159 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016160
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016161 /* Fill fw_abi_vers */
16162 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016163
Abhishek Singh716c46c2016-05-04 16:24:07 +053016164 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16165 if (QDF_IS_STATUS_ERROR(ret)) {
16166 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16167 ret);
16168 wmi_buf_free(buf);
16169 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016170
Abhishek Singh716c46c2016-05-04 16:24:07 +053016171 return ret;
16172
Govind Singhe7f2f342016-05-23 12:12:52 +053016173}
16174
16175/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016176 * send_addba_send_cmd_tlv() - send addba send command to fw
16177 * @wmi_handle: wmi handle
16178 * @param: pointer to delba send params
16179 * @macaddr: peer mac address
16180 *
16181 * Send WMI_ADDBA_SEND_CMDID command to firmware
16182 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16183 */
16184static QDF_STATUS
16185send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16186 uint8_t macaddr[IEEE80211_ADDR_LEN],
16187 struct addba_send_params *param)
16188{
16189 wmi_addba_send_cmd_fixed_param *cmd;
16190 wmi_buf_t buf;
16191 uint16_t len;
16192 QDF_STATUS ret;
16193
16194 len = sizeof(*cmd);
16195
16196 buf = wmi_buf_alloc(wmi_handle, len);
16197 if (!buf) {
16198 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16199 return QDF_STATUS_E_NOMEM;
16200 }
16201
16202 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16203
16204 WMITLV_SET_HDR(&cmd->tlv_header,
16205 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16206 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16207
16208 cmd->vdev_id = param->vdev_id;
16209 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16210 cmd->tid = param->tidno;
16211 cmd->buffersize = param->buffersize;
16212
16213 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16214 if (QDF_IS_STATUS_ERROR(ret)) {
16215 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16216 wmi_buf_free(buf);
16217 return QDF_STATUS_E_FAILURE;
16218 }
16219
16220 return QDF_STATUS_SUCCESS;
16221}
16222
16223/**
16224 * send_delba_send_cmd_tlv() - send delba send command to fw
16225 * @wmi_handle: wmi handle
16226 * @param: pointer to delba send params
16227 * @macaddr: peer mac address
16228 *
16229 * Send WMI_DELBA_SEND_CMDID command to firmware
16230 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16231 */
16232static QDF_STATUS
16233send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16234 uint8_t macaddr[IEEE80211_ADDR_LEN],
16235 struct delba_send_params *param)
16236{
16237 wmi_delba_send_cmd_fixed_param *cmd;
16238 wmi_buf_t buf;
16239 uint16_t len;
16240 QDF_STATUS ret;
16241
16242 len = sizeof(*cmd);
16243
16244 buf = wmi_buf_alloc(wmi_handle, len);
16245 if (!buf) {
16246 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16247 return QDF_STATUS_E_NOMEM;
16248 }
16249
16250 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16251
16252 WMITLV_SET_HDR(&cmd->tlv_header,
16253 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16254 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16255
16256 cmd->vdev_id = param->vdev_id;
16257 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16258 cmd->tid = param->tidno;
16259 cmd->initiator = param->initiator;
16260 cmd->reasoncode = param->reasoncode;
16261
16262 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16263 if (QDF_IS_STATUS_ERROR(ret)) {
16264 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16265 wmi_buf_free(buf);
16266 return QDF_STATUS_E_FAILURE;
16267 }
16268
16269 return QDF_STATUS_SUCCESS;
16270}
16271
16272/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016273 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16274 * to fw
16275 * @wmi_handle: wmi handle
16276 * @param: pointer to addba clearresp params
16277 * @macaddr: peer mac address
16278 * Return: 0 for success or error code
16279 */
16280static QDF_STATUS
16281send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16282 uint8_t macaddr[IEEE80211_ADDR_LEN],
16283 struct addba_clearresponse_params *param)
16284{
16285 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16286 wmi_buf_t buf;
16287 uint16_t len;
16288 QDF_STATUS ret;
16289
16290 len = sizeof(*cmd);
16291
16292 buf = wmi_buf_alloc(wmi_handle, len);
16293 if (!buf) {
16294 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16295 return QDF_STATUS_E_FAILURE;
16296 }
16297 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16298
16299 WMITLV_SET_HDR(&cmd->tlv_header,
16300 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16301 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16302
16303 cmd->vdev_id = param->vdev_id;
16304 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16305
16306 ret = wmi_unified_cmd_send(wmi_handle,
16307 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16308 if (QDF_IS_STATUS_ERROR(ret)) {
16309 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16310 wmi_buf_free(buf);
16311 return QDF_STATUS_E_FAILURE;
16312 }
16313
16314 return QDF_STATUS_SUCCESS;
16315}
16316
16317/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016318 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16319 * @wmi_handle: wmi handle
16320 * @bcn_ctrl_param: pointer to bcn_offload_control param
16321 *
16322 * Return: QDF_STATUS_SUCCESS for success or error code
16323 */
16324static
16325QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16326 struct bcn_offload_control *bcn_ctrl_param)
16327{
16328 wmi_buf_t buf;
16329 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16330 QDF_STATUS ret;
16331 uint32_t len;
16332
16333 len = sizeof(*cmd);
16334
16335 buf = wmi_buf_alloc(wmi_handle, len);
16336 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016337 qdf_print("%s: wmi_buf_alloc failed", __func__);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016338 return QDF_STATUS_E_FAILURE;
16339 }
16340
16341 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16342 WMITLV_SET_HDR(&cmd->tlv_header,
16343 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16344 WMITLV_GET_STRUCT_TLVLEN
16345 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16346 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016347 switch (bcn_ctrl_param->bcn_ctrl_op) {
16348 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016349 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016350 break;
16351 case BCN_OFFLD_CTRL_TX_ENABLE:
16352 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16353 break;
16354 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16355 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16356 break;
16357 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16358 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16359 break;
16360 default:
16361 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16362 bcn_ctrl_param->bcn_ctrl_op);
16363 wmi_buf_free(buf);
16364 return QDF_STATUS_E_FAILURE;
16365 break;
16366 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16368 WMI_BCN_OFFLOAD_CTRL_CMDID);
16369
16370 if (QDF_IS_STATUS_ERROR(ret)) {
16371 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16372 ret);
16373 wmi_buf_free(buf);
16374 }
16375
16376 return ret;
16377}
16378
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016379#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16380static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16381 struct nan_datapath_initiator_req *ndp_req)
16382{
16383 uint16_t len;
16384 wmi_buf_t buf;
16385 uint8_t *tlv_ptr;
16386 QDF_STATUS status;
16387 wmi_channel *ch_tlv;
16388 wmi_ndp_initiator_req_fixed_param *cmd;
16389 uint32_t passphrase_len, service_name_len;
16390 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016391 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016392
16393 /*
16394 * WMI command expects 4 byte alligned len:
16395 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16396 */
16397 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16398 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16399 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16400 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16401 service_name_len =
16402 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16403 /* allocated memory for fixed params as well as variable size data */
16404 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16405 + ndp_cfg_len + ndp_app_info_len + pmk_len
16406 + passphrase_len + service_name_len;
16407
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016408 if (ndp_req->is_ipv6_addr_present)
16409 len += sizeof(*tcp_ip_param);
16410
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016411 buf = wmi_buf_alloc(wmi_handle, len);
16412 if (!buf) {
16413 WMI_LOGE("wmi_buf_alloc failed");
16414 return QDF_STATUS_E_NOMEM;
16415 }
16416
16417 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16418 WMITLV_SET_HDR(&cmd->tlv_header,
16419 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16420 WMITLV_GET_STRUCT_TLVLEN(
16421 wmi_ndp_initiator_req_fixed_param));
16422 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16423 cmd->transaction_id = ndp_req->transaction_id;
16424 cmd->service_instance_id = ndp_req->service_instance_id;
16425 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16426 &cmd->peer_discovery_mac_addr);
16427
16428 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16429 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16430 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16431 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16432 cmd->nan_csid = ndp_req->ncs_sk_type;
16433 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16434 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16435
16436 ch_tlv = (wmi_channel *)&cmd[1];
16437 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16438 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16439 ch_tlv->mhz = ndp_req->channel;
16440 tlv_ptr = (uint8_t *)&ch_tlv[1];
16441
16442 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16443 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16444 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16445 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16446
16447 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16448 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16449 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16450 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16451
16452 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16453 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16454 cmd->nan_pmk_len);
16455 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16456
16457 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16458 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16459 cmd->nan_passphrase_len);
16460 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16461
16462 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16463 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16464 ndp_req->service_name.service_name,
16465 cmd->nan_servicename_len);
16466 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16467
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016468 if (ndp_req->is_ipv6_addr_present) {
16469 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16470 WMITLV_SET_HDR(tcp_ip_param,
16471 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16472 WMITLV_GET_STRUCT_TLVLEN(
16473 wmi_ndp_transport_ip_param));
16474 tcp_ip_param->ipv6_addr_present = true;
16475 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16476 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16477 }
16478 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16479 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16480
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016481 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16482 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16483 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16484 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16485 cmd->peer_discovery_mac_addr.mac_addr31to0,
16486 cmd->peer_discovery_mac_addr.mac_addr47to32);
16487
16488 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016489 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016490 ndp_req->ndp_config.ndp_cfg,
16491 ndp_req->ndp_config.ndp_cfg_len);
16492
16493 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016494 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016495 ndp_req->ndp_info.ndp_app_info,
16496 ndp_req->ndp_info.ndp_app_info_len);
16497
16498 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016499 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016500 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16501
16502 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016503 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016504 ndp_req->passphrase.passphrase,
16505 cmd->nan_passphrase_len);
16506
16507 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016508 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016509 ndp_req->service_name.service_name,
16510 cmd->nan_servicename_len);
16511
16512 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16513 WMI_NDP_INITIATOR_REQ_CMDID);
16514
16515 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16516 WMI_NDP_INITIATOR_REQ_CMDID);
16517 if (QDF_IS_STATUS_ERROR(status)) {
16518 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16519 wmi_buf_free(buf);
16520 }
16521
16522 return status;
16523}
16524
16525static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16526 struct nan_datapath_responder_req *req)
16527{
16528 uint16_t len;
16529 wmi_buf_t buf;
16530 uint8_t *tlv_ptr;
16531 QDF_STATUS status;
16532 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016533 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016534 uint32_t passphrase_len, service_name_len;
16535 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16536
16537 vdev_id = wlan_vdev_get_id(req->vdev);
16538 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16539 vdev_id, req->transaction_id,
16540 req->ndp_rsp,
16541 req->ndp_instance_id,
16542 req->ndp_info.ndp_app_info_len);
16543
16544 /*
16545 * WMI command expects 4 byte alligned len:
16546 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16547 */
16548 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16549 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16550 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16551 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16552 service_name_len =
16553 qdf_roundup(req->service_name.service_name_len, 4);
16554
16555 /* allocated memory for fixed params as well as variable size data */
16556 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16557 + pmk_len + passphrase_len + service_name_len;
16558
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016559 if (req->is_ipv6_addr_present || req->is_port_present ||
16560 req->is_protocol_present)
16561 len += sizeof(*tcp_ip_param);
16562
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016563 buf = wmi_buf_alloc(wmi_handle, len);
16564 if (!buf) {
16565 WMI_LOGE("wmi_buf_alloc failed");
16566 return QDF_STATUS_E_NOMEM;
16567 }
16568 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16569 WMITLV_SET_HDR(&cmd->tlv_header,
16570 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16571 WMITLV_GET_STRUCT_TLVLEN(
16572 wmi_ndp_responder_req_fixed_param));
16573 cmd->vdev_id = vdev_id;
16574 cmd->transaction_id = req->transaction_id;
16575 cmd->ndp_instance_id = req->ndp_instance_id;
16576 cmd->rsp_code = req->ndp_rsp;
16577 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16578 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16579 cmd->nan_pmk_len = req->pmk.pmk_len;
16580 cmd->nan_csid = req->ncs_sk_type;
16581 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16582 cmd->nan_servicename_len = req->service_name.service_name_len;
16583
16584 tlv_ptr = (uint8_t *)&cmd[1];
16585 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16586 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16587 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16588
16589 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16590 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16591 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16592 req->ndp_info.ndp_app_info,
16593 req->ndp_info.ndp_app_info_len);
16594
16595 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16596 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16597 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16598 cmd->nan_pmk_len);
16599
16600 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16601 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16602 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16603 req->passphrase.passphrase,
16604 cmd->nan_passphrase_len);
16605 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16606
16607 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16608 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16609 req->service_name.service_name,
16610 cmd->nan_servicename_len);
16611
16612 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16613
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016614 if (req->is_ipv6_addr_present || req->is_port_present ||
16615 req->is_protocol_present) {
16616 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16617 WMITLV_SET_HDR(tcp_ip_param,
16618 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16619 WMITLV_GET_STRUCT_TLVLEN(
16620 wmi_ndp_transport_ip_param));
16621 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16622 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16623 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16624
16625 tcp_ip_param->trans_port_present = req->is_port_present;
16626 tcp_ip_param->transport_port = req->port;
16627
16628 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16629 tcp_ip_param->transport_protocol = req->protocol;
16630 }
16631 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16632 req->is_ipv6_addr_present, req->ipv6_addr);
16633 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16634 WMI_LOGD(FL("protocol: %d present: %d"),
16635 req->is_protocol_present, req->protocol);
16636
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016637 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16638 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16639
16640 WMI_LOGD("ndp_config len: %d",
16641 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016642 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016643 req->ndp_config.ndp_cfg,
16644 req->ndp_config.ndp_cfg_len);
16645
16646 WMI_LOGD("ndp_app_info len: %d",
16647 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016648 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016649 req->ndp_info.ndp_app_info,
16650 req->ndp_info.ndp_app_info_len);
16651
16652 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016653 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016654 req->pmk.pmk, cmd->nan_pmk_len);
16655
16656 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016657 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016658 req->passphrase.passphrase,
16659 cmd->nan_passphrase_len);
16660
16661 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016662 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016663 req->service_name.service_name,
16664 cmd->nan_servicename_len);
16665
16666 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16667 WMI_NDP_RESPONDER_REQ_CMDID);
16668 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16669 WMI_NDP_RESPONDER_REQ_CMDID);
16670 if (QDF_IS_STATUS_ERROR(status)) {
16671 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16672 wmi_buf_free(buf);
16673 }
16674 return status;
16675}
16676
16677static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16678 struct nan_datapath_end_req *req)
16679{
16680 uint16_t len;
16681 wmi_buf_t buf;
16682 QDF_STATUS status;
16683 uint32_t ndp_end_req_len, i;
16684 wmi_ndp_end_req *ndp_end_req_lst;
16685 wmi_ndp_end_req_fixed_param *cmd;
16686
16687 /* len of tlv following fixed param */
16688 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16689 /* above comes out to 4 byte alligned already, no need of padding */
16690 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16691 buf = wmi_buf_alloc(wmi_handle, len);
16692 if (!buf) {
16693 WMI_LOGE("Malloc failed");
16694 return QDF_STATUS_E_NOMEM;
16695 }
16696
16697 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16698 WMITLV_SET_HDR(&cmd->tlv_header,
16699 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16700 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16701
16702 cmd->transaction_id = req->transaction_id;
16703
16704 /* set tlv pointer to end of fixed param */
16705 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16706 ndp_end_req_len);
16707
16708 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16709 WMI_TLV_HDR_SIZE);
16710 for (i = 0; i < req->num_ndp_instances; i++) {
16711 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16712 WMITLV_TAG_ARRAY_FIXED_STRUC,
16713 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16714
16715 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16716 }
16717
16718 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16719 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16720 WMI_NDP_END_REQ_CMDID);
16721 if (QDF_IS_STATUS_ERROR(status)) {
16722 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16723 wmi_buf_free(buf);
16724 }
16725
16726 return status;
16727}
16728
16729static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016730 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016731{
16732 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16733 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16734
16735 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16736 fixed_params = event->fixed_param;
16737
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016738 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016739 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16740 fixed_params->vdev_id,
16741 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016742 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016743 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016744 return QDF_STATUS_E_INVAL;
16745 }
16746
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016747 rsp->transaction_id = fixed_params->transaction_id;
16748 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16749 rsp->status = fixed_params->rsp_status;
16750 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016751
16752 return QDF_STATUS_SUCCESS;
16753}
16754
16755static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016756 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016757{
16758 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16759 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016760 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016761
16762 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16763 fixed_params =
16764 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16765
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016766 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16767 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16768 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16769 return QDF_STATUS_E_INVAL;
16770 }
16771
16772 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16773 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16774 fixed_params->ndp_app_info_len,
16775 event->num_ndp_app_info);
16776 return QDF_STATUS_E_INVAL;
16777 }
16778
gaolezab037cf2018-05-23 14:40:32 +080016779 if (fixed_params->ndp_cfg_len >
16780 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16781 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16782 __func__, fixed_params->ndp_cfg_len);
16783 return QDF_STATUS_E_INVAL;
16784 }
16785
16786 total_array_len = fixed_params->ndp_cfg_len +
16787 sizeof(*fixed_params);
16788
16789 if (fixed_params->ndp_app_info_len >
16790 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16791 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16792 __func__, fixed_params->ndp_app_info_len);
16793 return QDF_STATUS_E_INVAL;
16794 }
16795 total_array_len += fixed_params->ndp_app_info_len;
16796
16797 if (fixed_params->nan_scid_len >
16798 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16799 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16800 __func__, fixed_params->nan_scid_len);
16801 return QDF_STATUS_E_INVAL;
16802 }
16803
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016804 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016805 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16806 fixed_params->vdev_id,
16807 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016808 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016809 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016810 return QDF_STATUS_E_INVAL;
16811 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016812 rsp->service_instance_id = fixed_params->service_instance_id;
16813 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16814 rsp->role = fixed_params->self_ndp_role;
16815 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016816
16817 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016818 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016819 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016820 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016821
16822 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16823 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16824 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16825 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16826 fixed_params->service_instance_id,
16827 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16828 fixed_params->accept_policy,
16829 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016830 rsp->peer_mac_addr.bytes,
16831 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016832
16833 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016834 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016835 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16836
16837 WMI_LOGD("ndp_app_info - %d bytes",
16838 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016839 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016840 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16841
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016842 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16843 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16844 rsp->ncs_sk_type = fixed_params->nan_csid;
16845 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016846
16847 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16848 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016849 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16850 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016851
16852 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16853 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016854 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16855 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016856
16857 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16858 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016859 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016860
16861 if (event->ndp_transport_ip_param &&
16862 event->num_ndp_transport_ip_param) {
16863 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16864 rsp->is_ipv6_addr_present = true;
16865 qdf_mem_copy(rsp->ipv6_addr,
16866 event->ndp_transport_ip_param->ipv6_intf_addr,
16867 WMI_NDP_IPV6_INTF_ADDR_LEN);
16868 }
16869 }
16870 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16871 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16872
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016873 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016874 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016875 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016876
16877 return QDF_STATUS_SUCCESS;
16878}
16879
16880static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016881 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016882{
Naveen Rawat38b21462018-05-31 15:04:16 -070016883 uint8_t i;
16884 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016885 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16886 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016887 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016888
16889 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16890 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016891 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) received. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016892 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16893 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16894 fixed_params->reason_code,
16895 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016896 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016897
16898 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16899 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16900 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16901 return QDF_STATUS_E_INVAL;
16902 }
16903
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016904 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016905 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016906 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16907
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016908 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16909 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16910 fixed_params->ndp_app_info_len,
16911 event->num_ndp_app_info);
16912 return QDF_STATUS_E_INVAL;
16913 }
16914
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016915 WMI_LOGD("ndp_app_info - %d bytes",
16916 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016917 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016918 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16919
gaolezab037cf2018-05-23 14:40:32 +080016920 if (fixed_params->ndp_cfg_len >
16921 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16922 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16923 __func__, fixed_params->ndp_cfg_len);
16924 return QDF_STATUS_E_INVAL;
16925 }
16926
16927 total_array_len = fixed_params->ndp_cfg_len +
16928 sizeof(*fixed_params);
16929
16930 if (fixed_params->ndp_app_info_len >
16931 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16932 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16933 __func__, fixed_params->ndp_app_info_len);
16934 return QDF_STATUS_E_INVAL;
16935 }
16936
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016937 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016938 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16939 fixed_params->vdev_id,
16940 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016941 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016942 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016943 return QDF_STATUS_E_INVAL;
16944 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016945 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16946 rsp->rsp_code = fixed_params->rsp_code;
16947 rsp->reason_code = fixed_params->reason_code;
16948 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016949 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016950 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016951 rsp->peer_ndi_mac_addr.bytes);
16952 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16953 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16954 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016955
Naveen Rawat38b21462018-05-31 15:04:16 -070016956 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16957 WMI_LOGE(FL("too many channels"));
16958 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16959 }
16960
16961 for (i = 0; i < rsp->num_channels; i++) {
16962 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16963 rsp->ch[i].nss = event->nss_list[i];
16964 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16965 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16966 ch_mode);
16967 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16968 rsp->ch[i].channel,
16969 rsp->ch[i].ch_width,
16970 rsp->ch[i].nss);
16971 }
16972
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016973 if (event->ndp_transport_ip_param &&
16974 event->num_ndp_transport_ip_param) {
16975 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16976 rsp->is_ipv6_addr_present = true;
16977 qdf_mem_copy(rsp->ipv6_addr,
16978 event->ndp_transport_ip_param->ipv6_intf_addr,
16979 WMI_NDP_IPV6_INTF_ADDR_LEN);
16980 }
16981
16982 if (event->ndp_transport_ip_param->trans_port_present) {
16983 rsp->is_port_present = true;
16984 rsp->port =
16985 event->ndp_transport_ip_param->transport_port;
16986 }
16987
16988 if (event->ndp_transport_ip_param->trans_proto_present) {
16989 rsp->is_protocol_present = true;
16990 rsp->protocol =
16991 event->ndp_transport_ip_param->transport_protocol;
16992 }
16993 }
16994 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16995 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16996 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
16997 WMI_LOGD(FL("protocol: %d present: %d"),
16998 rsp->protocol, rsp->is_protocol_present);
16999
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017000 return QDF_STATUS_SUCCESS;
17001}
17002
17003static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017004 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017005{
17006 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17007 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17008
17009 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17010 fixed_params = event->fixed_param;
17011
17012 WMI_LOGD("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: %pM,transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
17013 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017014 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17015 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017016
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017017 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017018 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17019 fixed_params->vdev_id,
17020 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017021 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017022 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017023 return QDF_STATUS_E_INVAL;
17024 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017025 rsp->transaction_id = fixed_params->transaction_id;
17026 rsp->reason = fixed_params->reason_code;
17027 rsp->status = fixed_params->rsp_status;
17028 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017029 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017030 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017031
17032 return QDF_STATUS_SUCCESS;
17033}
17034
17035static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017036 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017037{
17038 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17039 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17040
17041 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17042 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017043 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) received. transaction_id: %d, rsp_status: %d, reason_code: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017044 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17045 fixed_params->rsp_status, fixed_params->reason_code);
17046
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017047 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017048 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017049 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017050 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017051 return QDF_STATUS_E_INVAL;
17052 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017053 rsp->transaction_id = fixed_params->transaction_id;
17054 rsp->reason = fixed_params->reason_code;
17055 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017056
17057 return QDF_STATUS_SUCCESS;
17058}
17059
17060static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17061 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17062{
17063 uint32_t i, buf_size;
17064 wmi_ndp_end_indication *ind;
17065 struct qdf_mac_addr peer_addr;
17066 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17067
17068 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17069 ind = event->ndp_end_indication_list;
17070
17071 if (event->num_ndp_end_indication_list == 0) {
17072 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017073 return QDF_STATUS_E_INVAL;
17074 }
17075
17076 WMI_LOGD("number of ndp instances = %d",
17077 event->num_ndp_end_indication_list);
17078
17079 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17080 sizeof((*rsp)->ndp_map[0]))) {
17081 WMI_LOGE("num_ndp_end_ind_list %d too large",
17082 event->num_ndp_end_indication_list);
17083 return QDF_STATUS_E_INVAL;
17084 }
17085
17086 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17087 sizeof((*rsp)->ndp_map[0]);
17088 *rsp = qdf_mem_malloc(buf_size);
17089 if (!(*rsp)) {
17090 WMI_LOGE("Failed to allocate memory");
17091 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017092 }
17093
17094 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17095 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17096 if (!(*rsp)->vdev) {
17097 WMI_LOGE("vdev is null");
17098 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017099 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017100 return QDF_STATUS_E_INVAL;
17101 }
17102
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017103 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17104 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17105 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17106 peer_addr.bytes);
17107 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17108 i, ind[i].type, ind[i].reason_code,
17109 ind[i].ndp_instance_id,
17110 ind[i].num_active_ndps_on_peer);
17111 /* Add each instance entry to the list */
17112 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17113 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17114 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17115 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17116 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17117 ind[i].num_active_ndps_on_peer;
17118 (*rsp)->ndp_map[i].type = ind[i].type;
17119 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17120 }
17121
17122 return QDF_STATUS_SUCCESS;
17123}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017124
17125static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17126 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17127{
17128 uint8_t i;
17129 WMI_HOST_WLAN_PHY_MODE ch_mode;
17130 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17131 wmi_ndl_schedule_update_fixed_param *fixed_params;
17132
17133 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17134 fixed_params = event->fixed_param;
17135
17136 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17137 fixed_params->flags, fixed_params->num_channels,
17138 fixed_params->num_ndp_instances);
17139
17140 ind->vdev =
17141 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17142 fixed_params->vdev_id,
17143 WLAN_NAN_ID);
17144 if (!ind->vdev) {
17145 WMI_LOGE("vdev is null");
17146 return QDF_STATUS_E_INVAL;
17147 }
17148
17149 ind->flags = fixed_params->flags;
17150 ind->num_channels = fixed_params->num_channels;
17151 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17152 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17153 ind->peer_addr.bytes);
17154
17155 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17156 WMI_LOGE(FL("uint32 overflow"));
17157 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17158 return QDF_STATUS_E_INVAL;
17159 }
17160
17161 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17162 sizeof(uint32_t) * ind->num_ndp_instances);
17163
17164 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17165 WMI_LOGE(FL("too many channels"));
17166 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17167 }
17168 for (i = 0; i < ind->num_channels; i++) {
17169 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17170 ind->ch[i].nss = event->nss_list[i];
17171 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17172 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17173 ch_mode);
17174 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17175 ind->ch[i].channel,
17176 ind->ch[i].ch_width,
17177 ind->ch[i].nss);
17178 }
17179
17180 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17181 WMI_LOGD(FL("instance_id[%d]: %d"),
17182 i, event->ndp_instance_list[i]);
17183
17184 return QDF_STATUS_SUCCESS;
17185}
17186
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017187#endif
17188
Naveen Rawat963ee942018-04-13 16:38:36 -070017189#ifdef QCA_SUPPORT_CP_STATS
17190/**
17191 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17192 * @wmi_handle: wma handle
17193 * @evt_buf: event buffer
17194 * @out_buff: buffer to populated after stats extraction
17195 *
17196 * Return: status of operation
17197 */
17198static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17199 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17200{
17201 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17202 wmi_congestion_stats *congestion_stats;
17203
17204 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17205 congestion_stats = param_buf->congestion_stats;
17206 if (!congestion_stats) {
17207 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17208 return QDF_STATUS_E_INVAL;
17209 }
17210
17211 out_buff->vdev_id = congestion_stats->vdev_id;
17212 out_buff->congestion = congestion_stats->congestion;
17213
17214 WMI_LOGD("%s: cca stats event processed", __func__);
17215 return QDF_STATUS_SUCCESS;
17216}
17217#endif /* QCA_SUPPORT_CP_STATS */
17218
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017219/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017220 * save_service_bitmap_tlv() - save service bitmap
17221 * @wmi_handle: wmi handle
17222 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017223 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017224 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017225 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017226 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017227static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017228QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017229 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017230{
17231 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017232 struct wmi_soc *soc = wmi_handle->soc;
17233
Govind Singhe7f2f342016-05-23 12:12:52 +053017234 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17235
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017236 /* If it is already allocated, use that buffer. This can happen
17237 * during target stop/start scenarios where host allocation is skipped.
17238 */
17239 if (!soc->wmi_service_bitmap) {
17240 soc->wmi_service_bitmap =
17241 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17242 if (!soc->wmi_service_bitmap) {
17243 WMI_LOGE("Failed memory allocation for service bitmap");
17244 return QDF_STATUS_E_NOMEM;
17245 }
17246 }
17247
17248 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017249 param_buf->wmi_service_bitmap,
17250 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017251
17252 if (bitmap_buf)
17253 qdf_mem_copy(bitmap_buf,
17254 param_buf->wmi_service_bitmap,
17255 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017256
17257 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017258}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017259
17260/**
17261 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17262 * @wmi_handle: wmi handle
17263 * @param evt_buf: pointer to event buffer
17264 * @param bitmap_buf: bitmap buffer, for converged legacy support
17265 *
17266 * Return: QDF_STATUS
17267 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017268static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017269QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017270 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017271{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017272 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17273 wmi_service_available_event_fixed_param *ev;
17274 struct wmi_soc *soc = wmi_handle->soc;
17275
17276 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17277
17278 ev = param_buf->fixed_param;
17279
17280 /* If it is already allocated, use that buffer. This can happen
17281 * during target stop/start scenarios where host allocation is skipped.
17282 */
17283 if (!soc->wmi_ext_service_bitmap) {
17284 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17285 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17286 if (!soc->wmi_ext_service_bitmap) {
17287 WMI_LOGE("Failed memory allocation for service bitmap");
17288 return QDF_STATUS_E_NOMEM;
17289 }
17290 }
17291
17292 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17293 ev->wmi_service_segment_bitmap,
17294 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017295
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017296 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17297 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17298 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17299
Rajeev Kumar77901472017-02-12 02:12:17 -080017300 if (bitmap_buf)
17301 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017302 soc->wmi_ext_service_bitmap,
17303 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017304
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017305 return QDF_STATUS_SUCCESS;
17306}
Govind Singhe7f2f342016-05-23 12:12:52 +053017307/**
17308 * is_service_enabled_tlv() - Check if service enabled
17309 * @param wmi_handle: wmi handle
17310 * @param service_id: service identifier
17311 *
17312 * Return: 1 enabled, 0 disabled
17313 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017314static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17315 uint32_t service_id)
17316{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017317 struct wmi_soc *soc = wmi_handle->soc;
17318
17319 if (!soc->wmi_service_bitmap) {
17320 WMI_LOGE("WMI service bit map is not saved yet\n");
17321 return false;
17322 }
17323
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017324 /* if wmi_service_enabled was received with extended bitmap,
17325 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017326 */
17327 if (soc->wmi_ext_service_bitmap)
17328 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17329 soc->wmi_ext_service_bitmap,
17330 service_id);
17331
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017332 if (service_id >= WMI_MAX_SERVICE) {
17333 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17334 service_id);
17335 return false;
17336 }
17337
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017338 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17339 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017340}
Govind Singhe7f2f342016-05-23 12:12:52 +053017341
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017342static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17343 struct wlan_psoc_target_capability_info *cap)
17344{
17345 /* except LDPC all flags are common betwen legacy and here
17346 * also IBFEER is not defined for TLV
17347 */
17348 cap->ht_cap_info |= ev_target_cap & (
17349 WMI_HT_CAP_ENABLED
17350 | WMI_HT_CAP_HT20_SGI
17351 | WMI_HT_CAP_DYNAMIC_SMPS
17352 | WMI_HT_CAP_TX_STBC
17353 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17354 | WMI_HT_CAP_RX_STBC
17355 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17356 | WMI_HT_CAP_LDPC
17357 | WMI_HT_CAP_L_SIG_TXOP_PROT
17358 | WMI_HT_CAP_MPDU_DENSITY
17359 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17360 | WMI_HT_CAP_HT40_SGI);
17361 if (ev_target_cap & WMI_HT_CAP_LDPC)
17362 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17363 WMI_HOST_HT_CAP_TX_LDPC;
17364}
Govind Singhe7f2f342016-05-23 12:12:52 +053017365/**
17366 * extract_service_ready_tlv() - extract service ready event
17367 * @wmi_handle: wmi handle
17368 * @param evt_buf: pointer to received event buffer
17369 * @param cap: pointer to hold target capability information extracted from even
17370 *
17371 * Return: QDF_STATUS_SUCCESS for success or error code
17372 */
17373static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017374 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017375{
17376 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17377 wmi_service_ready_event_fixed_param *ev;
17378
17379
17380 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17381
17382 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17383 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017384 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017385 return QDF_STATUS_E_FAILURE;
17386 }
17387
17388 cap->phy_capability = ev->phy_capability;
17389 cap->max_frag_entry = ev->max_frag_entry;
17390 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017391 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017392 cap->vht_cap_info = ev->vht_cap_info;
17393 cap->vht_supp_mcs = ev->vht_supp_mcs;
17394 cap->hw_min_tx_power = ev->hw_min_tx_power;
17395 cap->hw_max_tx_power = ev->hw_max_tx_power;
17396 cap->sys_cap_info = ev->sys_cap_info;
17397 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17398 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17399 cap->max_num_scan_channels = ev->max_num_scan_channels;
17400 cap->max_supported_macs = ev->max_supported_macs;
17401 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17402 cap->txrx_chainmask = ev->txrx_chainmask;
17403 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17404 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017405 cap->fw_version = ev->fw_build_vers;
17406 /* fw_version_1 is not available in TLV. */
17407 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017408
17409 return QDF_STATUS_SUCCESS;
17410}
17411
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017412/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17413 * to host internal WMI_HOST_REGDMN_MODE values.
17414 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17415 * host currently. Add this in the future if required.
17416 * 11AX (Phase II) : 11ax related values are not currently
17417 * advertised separately by FW. As part of phase II regulatory bring-up,
17418 * finalize the advertisement mechanism.
17419 * @target_wireless_mode: target wireless mode received in message
17420 *
17421 * Return: returns the host internal wireless mode.
17422 */
17423static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17424{
17425
17426 uint32_t wireless_modes = 0;
17427
17428 if (target_wireless_mode & REGDMN_MODE_11A)
17429 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17430
17431 if (target_wireless_mode & REGDMN_MODE_TURBO)
17432 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17433
17434 if (target_wireless_mode & REGDMN_MODE_11B)
17435 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17436
17437 if (target_wireless_mode & REGDMN_MODE_PUREG)
17438 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17439
17440 if (target_wireless_mode & REGDMN_MODE_11G)
17441 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17442
17443 if (target_wireless_mode & REGDMN_MODE_108G)
17444 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17445
17446 if (target_wireless_mode & REGDMN_MODE_108A)
17447 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17448
17449 if (target_wireless_mode & REGDMN_MODE_XR)
17450 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17451
17452 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17453 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17454
17455 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17456 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17457
17458 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17459 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17460
17461 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17462 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17463
17464 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17465 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17466
17467 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17468 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17469
17470 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17471 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17472
17473 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17474 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17475
17476 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17477 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17478
17479 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17480 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17481
17482 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17483 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17484
17485 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17486 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17487
17488 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17489 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17490
17491 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17492 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17493
17494 return wireless_modes;
17495}
17496
Govind Singhe7f2f342016-05-23 12:12:52 +053017497/**
17498 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17499 * @wmi_handle: wmi handle
17500 * @param evt_buf: Pointer to event buffer
17501 * @param cap: pointer to hold HAL reg capabilities
17502 *
17503 * Return: QDF_STATUS_SUCCESS for success or error code
17504 */
17505static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017506 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017507{
17508 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17509
17510 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17511
17512 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17513 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017514 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017515
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017516 cap->wireless_modes = convert_wireless_modes_tlv(
17517 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017518
Govind Singhe7f2f342016-05-23 12:12:52 +053017519 return QDF_STATUS_SUCCESS;
17520}
17521
17522/**
17523 * extract_host_mem_req_tlv() - Extract host memory request event
17524 * @wmi_handle: wmi handle
17525 * @param evt_buf: pointer to event buffer
17526 * @param num_entries: pointer to hold number of entries requested
17527 *
17528 * Return: Number of entries requested
17529 */
17530static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17531 void *evt_buf, uint8_t *num_entries)
17532{
17533 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17534 wmi_service_ready_event_fixed_param *ev;
17535
17536 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17537
17538 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17539 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017540 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017541 return NULL;
17542 }
17543
17544 *num_entries = ev->num_mem_reqs;
17545
17546 return (host_mem_req *)param_buf->mem_reqs;
17547}
17548
17549/**
17550 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17551 * ready function
17552 * @wmi_handle: wmi handle
17553 * @param evt_buf: pointer to event buffer
17554 *
17555 * Return: QDF_STATUS_SUCCESS for success or error code
17556 */
17557static QDF_STATUS
17558save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17559{
17560 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17561 wmi_service_ready_event_fixed_param *ev;
17562
17563
17564 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17565
17566 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17567 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017568 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017569 return QDF_STATUS_E_FAILURE;
17570 }
17571
17572 /*Save fw version from service ready message */
17573 /*This will be used while sending INIT message */
17574 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17575 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017576
Govind Singhe7f2f342016-05-23 12:12:52 +053017577 return QDF_STATUS_SUCCESS;
17578}
17579
17580/**
17581 * ready_extract_init_status_tlv() - Extract init status from ready event
17582 * @wmi_handle: wmi handle
17583 * @param evt_buf: Pointer to event buffer
17584 *
17585 * Return: ready status
17586 */
17587static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17588 void *evt_buf)
17589{
17590 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17591 wmi_ready_event_fixed_param *ev = NULL;
17592
Govind Singhe7f2f342016-05-23 12:12:52 +053017593 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17594 ev = param_buf->fixed_param;
17595
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017596 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +053017597
17598 return ev->status;
17599}
17600
17601/**
17602 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17603 * @wmi_handle: wmi handle
17604 * @param evt_buf: pointer to event buffer
17605 * @param macaddr: Pointer to hold MAC address
17606 *
17607 * Return: QDF_STATUS_SUCCESS for success or error code
17608 */
17609static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17610 void *evt_buf, uint8_t *macaddr)
17611{
17612 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17613 wmi_ready_event_fixed_param *ev = NULL;
17614
17615
17616 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17617 ev = param_buf->fixed_param;
17618
17619 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17620
17621 return QDF_STATUS_SUCCESS;
17622}
17623
17624/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017625 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17626 * @wmi_handle: wmi handle
17627 * @param evt_buf: pointer to event buffer
17628 * @param macaddr: Pointer to hold number of MAC addresses
17629 *
17630 * Return: Pointer to addr list
17631 */
17632static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17633 void *evt_buf, uint8_t *num_mac)
17634{
17635 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17636 wmi_ready_event_fixed_param *ev = NULL;
17637
17638 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17639 ev = param_buf->fixed_param;
17640
17641 *num_mac = ev->num_extra_mac_addr;
17642
17643 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17644}
17645
17646/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017647 * extract_ready_params_tlv() - Extract data from ready event apart from
17648 * status, macaddr and version.
17649 * @wmi_handle: Pointer to WMI handle.
17650 * @evt_buf: Pointer to Ready event buffer.
17651 * @ev_param: Pointer to host defined struct to copy the data from event.
17652 *
17653 * Return: QDF_STATUS_SUCCESS on success.
17654 */
17655static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17656 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17657{
17658 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17659 wmi_ready_event_fixed_param *ev = NULL;
17660
17661 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17662 ev = param_buf->fixed_param;
17663
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017664 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017665 ev_param->num_dscp_table = ev->num_dscp_table;
17666 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17667 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017668 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017669 /* Agile_cap in ready event is not supported in TLV target */
17670 ev_param->agile_capability = false;
17671
17672 return QDF_STATUS_SUCCESS;
17673}
17674
17675/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017676 * extract_dbglog_data_len_tlv() - extract debuglog data length
17677 * @wmi_handle: wmi handle
17678 * @param evt_buf: pointer to event buffer
17679 *
17680 * Return: length
17681 */
17682static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017683 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017684{
17685 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17686
17687 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17688
17689 *len = param_buf->num_bufp;
17690
17691 return param_buf->bufp;
17692}
17693
17694/**
17695 * extract_vdev_start_resp_tlv() - extract vdev start response
17696 * @wmi_handle: wmi handle
17697 * @param evt_buf: pointer to event buffer
17698 * @param vdev_rsp: Pointer to hold vdev response
17699 *
17700 * Return: QDF_STATUS_SUCCESS for success or error code
17701 */
17702static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17703 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17704{
17705 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17706 wmi_vdev_start_response_event_fixed_param *ev;
17707
17708 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17709 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017710 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017711 return QDF_STATUS_E_INVAL;
17712 }
17713
17714 ev = param_buf->fixed_param;
17715 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017716 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017717 return QDF_STATUS_E_INVAL;
17718 }
17719
17720 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17721
17722 vdev_rsp->vdev_id = ev->vdev_id;
17723 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017724 switch (ev->resp_type) {
17725 case WMI_VDEV_START_RESP_EVENT:
17726 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17727 break;
17728 case WMI_VDEV_RESTART_RESP_EVENT:
17729 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17730 break;
17731 default:
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017732 qdf_print("Invalid start response event buffer");
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017733 break;
17734 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017735 vdev_rsp->status = ev->status;
17736 vdev_rsp->chain_mask = ev->chain_mask;
17737 vdev_rsp->smps_mode = ev->smps_mode;
17738 vdev_rsp->mac_id = ev->mac_id;
17739 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17740 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17741
17742 return QDF_STATUS_SUCCESS;
17743}
17744
17745/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017746 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17747 * @wmi_handle: wmi handle
17748 * @param evt_buf: pointer to event buffer
17749 * @param delete_rsp: Pointer to hold vdev delete response
17750 *
17751 * Return: QDF_STATUS_SUCCESS for success or error code
17752 */
17753static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17754 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17755{
17756 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17757 wmi_vdev_delete_resp_event_fixed_param *ev;
17758
17759 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17760 if (!param_buf) {
17761 WMI_LOGE("Invalid vdev delete response event buffer\n");
17762 return QDF_STATUS_E_INVAL;
17763 }
17764
17765 ev = param_buf->fixed_param;
17766 if (!ev) {
17767 WMI_LOGE("Invalid vdev delete response event\n");
17768 return QDF_STATUS_E_INVAL;
17769 }
17770
17771 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17772 delete_rsp->vdev_id = ev->vdev_id;
17773
17774 return QDF_STATUS_SUCCESS;
17775}
17776
17777
17778/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017779 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017780 * @wmi_handle: wmi handle
17781 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017782 * @param num_vdevs: Pointer to hold num vdev
17783 *
17784 * Return: QDF_STATUS_SUCCESS for success or error code
17785 */
17786static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17787 void *evt_buf, uint32_t *num_vdevs)
17788{
17789 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17790 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17791 uint32_t vdev_map;
17792
17793 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17794 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017795 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017796 return QDF_STATUS_E_INVAL;
17797 }
17798 tbtt_offset_event = param_buf->fixed_param;
17799 vdev_map = tbtt_offset_event->vdev_map;
17800 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17801
17802 return QDF_STATUS_SUCCESS;
17803}
17804
17805/**
17806 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17807 * @wmi_handle: wmi handle
17808 * @param evt_buf: pointer to event buffer
17809 * @param num_vdevs: Pointer to hold num vdev
17810 *
17811 * Return: QDF_STATUS_SUCCESS for success or error code
17812 */
17813static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17814 void *evt_buf, uint32_t *num_vdevs)
17815{
17816 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17817 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17818
17819 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17820 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017821 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017822 return QDF_STATUS_E_INVAL;
17823 }
17824 tbtt_offset_ext_event = param_buf->fixed_param;
17825
17826 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17827
17828 return QDF_STATUS_SUCCESS;
17829}
17830
17831/**
17832 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17833 * @wmi_handle: wmi handle
17834 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017835 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017836 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017837 *
17838 * Return: QDF_STATUS_SUCCESS for success or error code
17839 */
17840static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017841 void *evt_buf, uint8_t idx,
17842 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017843{
17844 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17845 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017846 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017847
17848 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17849 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017850 qdf_print("Invalid tbtt update event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017851 return QDF_STATUS_E_INVAL;
17852 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017853
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017854 tbtt_offset_event = param_buf->fixed_param;
17855 vdev_map = tbtt_offset_event->vdev_map;
17856 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17857 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17858 return QDF_STATUS_E_INVAL;
17859 tbtt_param->tbttoffset =
17860 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17861
17862 return QDF_STATUS_SUCCESS;
17863}
17864
17865/**
17866 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17867 * @wmi_handle: wmi handle
17868 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017869 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017870 * @param tbtt_param: Pointer to tbttoffset event param
17871 *
17872 * Return: QDF_STATUS_SUCCESS for success or error code
17873 */
17874static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17875 void *evt_buf, uint8_t idx,
17876 struct tbttoffset_params *tbtt_param)
17877{
17878 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17879 wmi_tbtt_offset_info *tbtt_offset_info;
17880
17881 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17882 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017883 qdf_print("Invalid tbtt update event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017884 return QDF_STATUS_E_INVAL;
17885 }
17886 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17887
17888 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17889 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017890
17891 return QDF_STATUS_SUCCESS;
17892}
17893
Jinwei Chenb69924c2018-08-20 11:31:31 +080017894#ifdef CONFIG_MCL
17895#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
17896 ((_status) & WMI_RXERR_DECRYPT)
17897#else
17898#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
17899#endif
17900
Govind Singhe7f2f342016-05-23 12:12:52 +053017901/**
17902 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17903 * @wmi_handle: wmi handle
17904 * @param evt_buf: pointer to event buffer
17905 * @param hdr: Pointer to hold header
17906 * @param bufp: Pointer to hold pointer to rx param buffer
17907 *
17908 * Return: QDF_STATUS_SUCCESS for success or error code
17909 */
17910static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017911 void *evt_buf, struct mgmt_rx_event_params *hdr,
17912 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017913{
17914 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17915 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017916 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017917
17918 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17919 if (!param_tlvs) {
17920 WMI_LOGE("Get NULL point message from FW");
17921 return QDF_STATUS_E_INVAL;
17922 }
17923
17924 ev_hdr = param_tlvs->hdr;
17925 if (!hdr) {
17926 WMI_LOGE("Rx event is NULL");
17927 return QDF_STATUS_E_INVAL;
17928 }
17929
Jinwei Chenb69924c2018-08-20 11:31:31 +080017930 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
17931 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
17932 __func__);
17933 return QDF_STATUS_E_INVAL;
17934 }
17935
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017936 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17937 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017938
17939 hdr->channel = ev_hdr->channel;
17940 hdr->snr = ev_hdr->snr;
17941 hdr->rate = ev_hdr->rate;
17942 hdr->phy_mode = ev_hdr->phy_mode;
17943 hdr->buf_len = ev_hdr->buf_len;
17944 hdr->status = ev_hdr->status;
17945 hdr->flags = ev_hdr->flags;
17946 hdr->rssi = ev_hdr->rssi;
17947 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017948 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17949 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017950
17951 *bufp = param_tlvs->bufp;
17952
17953 return QDF_STATUS_SUCCESS;
17954}
17955
17956/**
17957 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17958 * @wmi_handle: wmi handle
17959 * @param evt_buf: pointer to event buffer
17960 * @param vdev_id: Pointer to hold vdev identifier
17961 *
17962 * Return: QDF_STATUS_SUCCESS for success or error code
17963 */
17964static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17965 void *evt_buf, uint32_t *vdev_id)
17966{
17967 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17968 wmi_vdev_stopped_event_fixed_param *resp_event;
17969
17970 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17971 if (!param_buf) {
17972 WMI_LOGE("Invalid event buffer");
17973 return QDF_STATUS_E_INVAL;
17974 }
17975 resp_event = param_buf->fixed_param;
17976 *vdev_id = resp_event->vdev_id;
17977
17978 return QDF_STATUS_SUCCESS;
17979}
17980
17981/**
17982 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17983 * @wmi_handle: wmi handle
17984 * @param evt_buf: pointer to event buffer
17985 * @param param: Pointer to hold roam param
17986 *
17987 * Return: QDF_STATUS_SUCCESS for success or error code
17988 */
17989static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17990 void *evt_buf, wmi_host_roam_event *param)
17991{
17992 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17993 wmi_roam_event_fixed_param *evt;
17994
17995 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17996 if (!param_buf) {
17997 WMI_LOGE("Invalid roam event buffer");
17998 return QDF_STATUS_E_INVAL;
17999 }
18000
18001 evt = param_buf->fixed_param;
18002 qdf_mem_zero(param, sizeof(*param));
18003
18004 param->vdev_id = evt->vdev_id;
18005 param->reason = evt->reason;
18006 param->rssi = evt->rssi;
18007
18008 return QDF_STATUS_SUCCESS;
18009}
18010
18011/**
18012 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18013 * @wmi_handle: wmi handle
18014 * @param evt_buf: pointer to event buffer
18015 * @param param: Pointer to hold vdev scan param
18016 *
18017 * Return: QDF_STATUS_SUCCESS for success or error code
18018 */
18019static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018020 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018021{
18022 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18023 wmi_scan_event_fixed_param *evt = NULL;
18024
18025 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18026 evt = param_buf->fixed_param;
18027
18028 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018029
Govind Singhe7f2f342016-05-23 12:12:52 +053018030 switch (evt->event) {
18031 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018032 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018033 break;
18034 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018035 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018036 break;
18037 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018038 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018039 break;
18040 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018041 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018042 break;
18043 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018044 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018045 break;
18046 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018047 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018048 break;
18049 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018050 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018051 break;
18052 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018053 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018054 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018055 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018056 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018057 break;
18058 case WMI_SCAN_EVENT_MAX:
18059 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018060 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018061 break;
18062 };
18063
18064 switch (evt->reason) {
18065 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018066 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018067 break;
18068 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018069 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018070 break;
18071 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018072 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018073 break;
18074 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018075 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018076 break;
18077 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018078 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018079 break;
18080 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018081 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018082 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018083 case WMI_SCAN_REASON_SUSPENDED:
18084 param->reason = SCAN_REASON_SUSPENDED;
18085 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018086 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018087 param->reason = SCAN_REASON_MAX;
18088 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018089 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018090 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018091 break;
18092 };
18093
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018094 param->chan_freq = evt->channel_freq;
18095 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018096 param->scan_id = evt->scan_id;
18097 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018098 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018099
18100 return QDF_STATUS_SUCCESS;
18101}
18102
Frank Liu3d5e9992017-03-15 17:51:43 +080018103#ifdef CONVERGED_TDLS_ENABLE
18104/**
18105 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18106 * @wmi_handle: wmi handle
18107 * @param evt_buf: pointer to event buffer
18108 * @param param: Pointer to hold vdev tdls param
18109 *
18110 * Return: QDF_STATUS_SUCCESS for success or error code
18111 */
18112static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18113 void *evt_buf, struct tdls_event_info *param)
18114{
18115 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18116 wmi_tdls_peer_event_fixed_param *evt;
18117
18118 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18119 if (!param_buf) {
18120 WMI_LOGE("%s: NULL param_buf", __func__);
18121 return QDF_STATUS_E_NULL_VALUE;
18122 }
18123
18124 evt = param_buf->fixed_param;
18125
18126 qdf_mem_zero(param, sizeof(*param));
18127
18128 param->vdev_id = evt->vdev_id;
18129 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18130 param->peermac.bytes);
18131 switch (evt->peer_status) {
18132 case WMI_TDLS_SHOULD_DISCOVER:
18133 param->message_type = TDLS_SHOULD_DISCOVER;
18134 break;
18135 case WMI_TDLS_SHOULD_TEARDOWN:
18136 param->message_type = TDLS_SHOULD_TEARDOWN;
18137 break;
18138 case WMI_TDLS_PEER_DISCONNECTED:
18139 param->message_type = TDLS_PEER_DISCONNECTED;
18140 break;
18141 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18142 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18143 break;
18144 default:
18145 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18146 __func__, evt->peer_status);
18147 return QDF_STATUS_E_INVAL;
18148 };
18149
18150 switch (evt->peer_reason) {
18151 case WMI_TDLS_TEARDOWN_REASON_TX:
18152 param->peer_reason = TDLS_TEARDOWN_TX;
18153 break;
18154 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18155 param->peer_reason = TDLS_TEARDOWN_RSSI;
18156 break;
18157 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18158 param->peer_reason = TDLS_TEARDOWN_SCAN;
18159 break;
18160 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18161 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18162 break;
18163 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18164 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18165 break;
18166 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18167 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18168 break;
18169 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18170 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18171 break;
18172 case WMI_TDLS_ENTER_BUF_STA:
18173 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18174 break;
18175 case WMI_TDLS_EXIT_BUF_STA:
18176 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18177 break;
18178 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18179 param->peer_reason = TDLS_ENTER_BT_BUSY;
18180 break;
18181 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18182 param->peer_reason = TDLS_EXIT_BT_BUSY;
18183 break;
18184 case WMI_TDLS_SCAN_STARTED_EVENT:
18185 param->peer_reason = TDLS_SCAN_STARTED;
18186 break;
18187 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18188 param->peer_reason = TDLS_SCAN_COMPLETED;
18189 break;
18190
18191 default:
18192 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18193 __func__, evt->peer_reason, evt->peer_status);
18194 return QDF_STATUS_E_INVAL;
18195 };
18196
18197 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18198 __func__, param->peermac.bytes, param->message_type,
18199 param->peer_reason, param->vdev_id);
18200
18201 return QDF_STATUS_SUCCESS;
18202}
18203#endif
18204
Govind Singhe7f2f342016-05-23 12:12:52 +053018205/**
18206 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18207 * @wmi_handle: wmi handle
18208 * @param evt_buf: pointer to event buffer
18209 * @param param: Pointer to hold MGMT TX completion params
18210 *
18211 * Return: QDF_STATUS_SUCCESS for success or error code
18212 */
18213static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18214 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18215{
18216 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18217 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18218
18219 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18220 evt_buf;
18221 if (!param_buf) {
18222 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18223 return QDF_STATUS_E_INVAL;
18224 }
18225 cmpl_params = param_buf->fixed_param;
18226
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018227 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18228 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018229 param->desc_id = cmpl_params->desc_id;
18230 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018231 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018232
18233 return QDF_STATUS_SUCCESS;
18234}
18235
18236/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018237 * extract_offchan_data_tx_compl_param_tlv() -
18238 * extract Offchan data tx completion event params
18239 * @wmi_handle: wmi handle
18240 * @param evt_buf: pointer to event buffer
18241 * @param param: Pointer to hold offchan data TX completion params
18242 *
18243 * Return: QDF_STATUS_SUCCESS for success or error code
18244 */
18245static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18246 wmi_unified_t wmi_handle, void *evt_buf,
18247 struct wmi_host_offchan_data_tx_compl_event *param)
18248{
18249 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18250 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18251
18252 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18253 evt_buf;
18254 if (!param_buf) {
18255 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18256 return QDF_STATUS_E_INVAL;
18257 }
18258 cmpl_params = param_buf->fixed_param;
18259
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018260 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18261 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018262 param->desc_id = cmpl_params->desc_id;
18263 param->status = cmpl_params->status;
18264
18265 return QDF_STATUS_SUCCESS;
18266}
18267
18268/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018269 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18270 * status tlv
18271 * @wmi_handle: wmi handle
18272 * @param evt_buf: pointer to event buffer
18273 * @param param: Pointer to hold csa switch count status event param
18274 *
18275 * Return: QDF_STATUS_SUCCESS for success or error code
18276 */
18277static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18278 wmi_unified_t wmi_handle,
18279 void *evt_buf,
18280 struct pdev_csa_switch_count_status *param)
18281{
18282 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18283 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18284
18285 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18286 evt_buf;
18287 if (!param_buf) {
18288 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18289 return QDF_STATUS_E_INVAL;
18290 }
18291
18292 csa_status = param_buf->fixed_param;
18293
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018294 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18295 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018296 param->current_switch_count = csa_status->current_switch_count;
18297 param->num_vdevs = csa_status->num_vdevs;
18298 param->vdev_ids = param_buf->vdev_ids;
18299
18300 return QDF_STATUS_SUCCESS;
18301}
18302
18303/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018304 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18305 * param from event
18306 * @wmi_handle: wmi handle
18307 * @param evt_buf: pointer to event buffer
18308 * @param param: Pointer to hold tpc configuration
18309 *
18310 * Return: 0 for success or error code
18311 */
18312static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18313 void *evt_buf,
18314 wmi_host_pdev_tpc_config_event *param)
18315{
18316 wmi_pdev_tpc_config_event_fixed_param *event =
18317 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18318
18319 if (!event) {
18320 WMI_LOGE("Invalid event buffer");
18321 return QDF_STATUS_E_INVAL;
18322 }
18323
18324 param->pdev_id = event->pdev_id;
18325 param->regDomain = event->regDomain;
18326 param->chanFreq = event->chanFreq;
18327 param->phyMode = event->phyMode;
18328 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018329 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018330 param->twiceMaxRDPower = event->twiceMaxRDPower;
18331 param->powerLimit = event->powerLimit;
18332 param->rateMax = event->rateMax;
18333 param->numTxChain = event->numTxChain;
18334 param->ctl = event->ctl;
18335 param->flags = event->flags;
18336
18337 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18338 sizeof(param->maxRegAllowedPower));
18339 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18340 event->maxRegAllowedPowerAGCDD,
18341 sizeof(param->maxRegAllowedPowerAGCDD));
18342 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18343 event->maxRegAllowedPowerAGSTBC,
18344 sizeof(param->maxRegAllowedPowerAGSTBC));
18345 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18346 event->maxRegAllowedPowerAGTXBF,
18347 sizeof(param->maxRegAllowedPowerAGTXBF));
18348 WMI_LOGD("%s:extract success", __func__);
18349
18350 return QDF_STATUS_SUCCESS;
18351}
18352
18353/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018354 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018355 * @wmi_handle: wmi handle
18356 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018357 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018358 *
18359 * Return: QDF_STATUS_SUCCESS for success or error code
18360 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018361static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18362 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018363{
18364 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18365 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018366 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018367
18368 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18369 if (!param_buf) {
18370 WMI_LOGE("Invalid swba event buffer");
18371 return QDF_STATUS_E_INVAL;
18372 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018373
Govind Singhe7f2f342016-05-23 12:12:52 +053018374 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018375 *num_vdevs = swba_event->num_vdevs;
18376 if (!(*num_vdevs)) {
18377 vdev_map = swba_event->vdev_map;
18378 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18379 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018380
18381 return QDF_STATUS_SUCCESS;
18382}
18383
18384/**
18385 * extract_swba_tim_info_tlv() - extract swba tim info from event
18386 * @wmi_handle: wmi handle
18387 * @param evt_buf: pointer to event buffer
18388 * @param idx: Index to bcn info
18389 * @param tim_info: Pointer to hold tim info
18390 *
18391 * Return: QDF_STATUS_SUCCESS for success or error code
18392 */
18393static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18394 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18395{
18396 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18397 wmi_tim_info *tim_info_ev;
18398
18399 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18400 if (!param_buf) {
18401 WMI_LOGE("Invalid swba event buffer");
18402 return QDF_STATUS_E_INVAL;
18403 }
18404
18405 tim_info_ev = &param_buf->tim_info[idx];
18406
18407 tim_info->tim_len = tim_info_ev->tim_len;
18408 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18409 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18410 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18411 tim_info->tim_changed = tim_info_ev->tim_changed;
18412 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018413 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018414
18415 return QDF_STATUS_SUCCESS;
18416}
18417
18418/**
18419 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18420 * @wmi_handle: wmi handle
18421 * @param evt_buf: pointer to event buffer
18422 * @param idx: Index to bcn info
18423 * @param p2p_desc: Pointer to hold p2p NoA info
18424 *
18425 * Return: QDF_STATUS_SUCCESS for success or error code
18426 */
18427static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18428 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18429{
18430 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18431 wmi_p2p_noa_info *p2p_noa_info;
18432 uint8_t i = 0;
18433
18434 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18435 if (!param_buf) {
18436 WMI_LOGE("Invalid swba event buffer");
18437 return QDF_STATUS_E_INVAL;
18438 }
18439
18440 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18441
18442 p2p_desc->modified = false;
18443 p2p_desc->num_descriptors = 0;
18444 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18445 p2p_desc->modified = true;
18446 p2p_desc->index =
18447 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18448 p2p_desc->oppPS =
18449 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18450 p2p_desc->ctwindow =
18451 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18452 p2p_desc->num_descriptors =
18453 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18454 (p2p_noa_info);
18455 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18456 p2p_desc->noa_descriptors[i].type_count =
18457 (uint8_t) p2p_noa_info->noa_descriptors[i].
18458 type_count;
18459 p2p_desc->noa_descriptors[i].duration =
18460 p2p_noa_info->noa_descriptors[i].duration;
18461 p2p_desc->noa_descriptors[i].interval =
18462 p2p_noa_info->noa_descriptors[i].interval;
18463 p2p_desc->noa_descriptors[i].start_time =
18464 p2p_noa_info->noa_descriptors[i].start_time;
18465 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018466 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018467 }
18468
18469 return QDF_STATUS_SUCCESS;
18470}
18471
Wu Gaocd3a8512017-03-13 20:17:34 +080018472#ifdef CONVERGED_P2P_ENABLE
18473/**
18474 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18475 * @wmi_handle: wmi handle
18476 * @param evt_buf: pointer to event buffer
18477 * @param param: Pointer to hold p2p noa info
18478 *
18479 * Return: QDF_STATUS_SUCCESS for success or error code
18480 */
18481static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18482 wmi_unified_t wmi_handle, void *evt_buf,
18483 struct p2p_noa_info *param)
18484{
18485 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18486 wmi_p2p_noa_event_fixed_param *fixed_param;
18487 uint8_t i;
18488 wmi_p2p_noa_info *wmi_noa_info;
18489 uint8_t *buf_ptr;
18490 uint32_t descriptors;
18491
18492 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18493 if (!param_tlvs) {
18494 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18495 return QDF_STATUS_E_INVAL;
18496 }
18497
18498 if (!param) {
18499 WMI_LOGE("noa information param is null");
18500 return QDF_STATUS_E_INVAL;
18501 }
18502
18503 fixed_param = param_tlvs->fixed_param;
18504 buf_ptr = (uint8_t *) fixed_param;
18505 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18506 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18507
18508 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18509 WMI_LOGE("%s: noa attr is not modified", __func__);
18510 return QDF_STATUS_E_INVAL;
18511 }
18512
18513 param->vdev_id = fixed_param->vdev_id;
18514 param->index =
18515 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18516 param->opps_ps =
18517 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18518 param->ct_window =
18519 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18520 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18521 param->num_desc = (uint8_t) descriptors;
18522
18523 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18524 param->index, param->opps_ps, param->ct_window,
18525 param->num_desc);
18526 for (i = 0; i < param->num_desc; i++) {
18527 param->noa_desc[i].type_count =
18528 (uint8_t) wmi_noa_info->noa_descriptors[i].
18529 type_count;
18530 param->noa_desc[i].duration =
18531 wmi_noa_info->noa_descriptors[i].duration;
18532 param->noa_desc[i].interval =
18533 wmi_noa_info->noa_descriptors[i].interval;
18534 param->noa_desc[i].start_time =
18535 wmi_noa_info->noa_descriptors[i].start_time;
18536 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18537 __func__, i, param->noa_desc[i].type_count,
18538 param->noa_desc[i].duration,
18539 param->noa_desc[i].interval,
18540 param->noa_desc[i].start_time);
18541 }
18542
18543 return QDF_STATUS_SUCCESS;
18544}
18545
18546/**
18547 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18548 * information from event
18549 * @wmi_handle: wmi handle
18550 * @param evt_buf: pointer to event buffer
18551 * @param param: Pointer to hold p2p lo stop event information
18552 *
18553 * Return: QDF_STATUS_SUCCESS for success or error code
18554 */
18555static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18556 wmi_unified_t wmi_handle, void *evt_buf,
18557 struct p2p_lo_event *param)
18558{
18559 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18560 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18561
18562 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18563 evt_buf;
18564 if (!param_tlvs) {
18565 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18566 return QDF_STATUS_E_INVAL;
18567 }
18568
18569 if (!param) {
18570 WMI_LOGE("lo stop event param is null");
18571 return QDF_STATUS_E_INVAL;
18572 }
18573
18574 lo_param = param_tlvs->fixed_param;
18575 param->vdev_id = lo_param->vdev_id;
18576 param->reason_code = lo_param->reason;
18577 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18578 param->vdev_id, param->reason_code);
18579
18580 return QDF_STATUS_SUCCESS;
18581}
18582#endif /* End of CONVERGED_P2P_ENABLE */
18583
Govind Singhe7f2f342016-05-23 12:12:52 +053018584/**
18585 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18586 * @wmi_handle: wmi handle
18587 * @param evt_buf: pointer to event buffer
18588 * @param ev: Pointer to hold peer param
18589 *
18590 * Return: QDF_STATUS_SUCCESS for success or error code
18591 */
18592static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18593 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18594{
18595 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18596 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18597
18598 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18599 kickout_event = param_buf->fixed_param;
18600
18601 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18602 ev->peer_macaddr);
18603
18604 ev->reason = kickout_event->reason;
18605 ev->rssi = kickout_event->rssi;
18606
18607 return QDF_STATUS_SUCCESS;
18608}
18609
18610/**
18611 * extract_all_stats_counts_tlv() - extract all stats count from event
18612 * @wmi_handle: wmi handle
18613 * @param evt_buf: pointer to event buffer
18614 * @param stats_param: Pointer to hold stats count
18615 *
18616 * Return: QDF_STATUS_SUCCESS for success or error code
18617 */
18618static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18619 void *evt_buf, wmi_host_stats_event *stats_param)
18620{
Govind Singhe7f2f342016-05-23 12:12:52 +053018621 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018622 wmi_per_chain_rssi_stats *rssi_event;
18623 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018624
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018625 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018626 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018627 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018628 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018629 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018630 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018631 return QDF_STATUS_E_FAILURE;
18632 }
18633
18634 switch (ev->stats_id) {
18635 case WMI_REQUEST_PEER_STAT:
18636 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18637 break;
18638
18639 case WMI_REQUEST_AP_STAT:
18640 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18641 break;
18642
18643 case WMI_REQUEST_PDEV_STAT:
18644 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18645 break;
18646
18647 case WMI_REQUEST_VDEV_STAT:
18648 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18649 break;
18650
18651 case WMI_REQUEST_BCNFLT_STAT:
18652 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18653 break;
18654
18655 case WMI_REQUEST_VDEV_RATE_STAT:
18656 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18657 break;
18658
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018659 case WMI_REQUEST_BCN_STAT:
18660 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18661 break;
18662
Govind Singhe7f2f342016-05-23 12:12:52 +053018663 default:
18664 stats_param->stats_id = 0;
18665 break;
18666
18667 }
18668
18669 stats_param->num_pdev_stats = ev->num_pdev_stats;
18670 stats_param->num_pdev_ext_stats = 0;
18671 stats_param->num_vdev_stats = ev->num_vdev_stats;
18672 stats_param->num_peer_stats = ev->num_peer_stats;
18673 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18674 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018675 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018676 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18677 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018678
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018679 /* if chain_stats is not populated */
18680 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18681 return QDF_STATUS_SUCCESS;
18682
18683 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18684 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18685 return QDF_STATUS_SUCCESS;
18686
18687 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018688 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018689 return QDF_STATUS_SUCCESS;
18690
18691 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18692
Govind Singhe7f2f342016-05-23 12:12:52 +053018693 return QDF_STATUS_SUCCESS;
18694}
18695
18696/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018697 * extract_pdev_tx_stats() - extract pdev tx stats from event
18698 */
18699static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18700{
18701 /* Tx Stats */
18702 tx->comp_queued = tx_stats->comp_queued;
18703 tx->comp_delivered = tx_stats->comp_delivered;
18704 tx->msdu_enqued = tx_stats->msdu_enqued;
18705 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18706 tx->wmm_drop = tx_stats->wmm_drop;
18707 tx->local_enqued = tx_stats->local_enqued;
18708 tx->local_freed = tx_stats->local_freed;
18709 tx->hw_queued = tx_stats->hw_queued;
18710 tx->hw_reaped = tx_stats->hw_reaped;
18711 tx->underrun = tx_stats->underrun;
18712 tx->tx_abort = tx_stats->tx_abort;
18713 tx->mpdus_requed = tx_stats->mpdus_requed;
18714 tx->data_rc = tx_stats->data_rc;
18715 tx->self_triggers = tx_stats->self_triggers;
18716 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18717 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18718 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18719 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18720 tx->pdev_resets = tx_stats->pdev_resets;
18721 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18722 tx->phy_underrun = tx_stats->phy_underrun;
18723 tx->txop_ovf = tx_stats->txop_ovf;
18724
18725 return;
18726}
18727
18728
18729/**
18730 * extract_pdev_rx_stats() - extract pdev rx stats from event
18731 */
18732static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18733{
18734 /* Rx Stats */
18735 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18736 rx->status_rcvd = rx_stats->status_rcvd;
18737 rx->r0_frags = rx_stats->r0_frags;
18738 rx->r1_frags = rx_stats->r1_frags;
18739 rx->r2_frags = rx_stats->r2_frags;
18740 /* Only TLV */
18741 rx->r3_frags = 0;
18742 rx->htt_msdus = rx_stats->htt_msdus;
18743 rx->htt_mpdus = rx_stats->htt_mpdus;
18744 rx->loc_msdus = rx_stats->loc_msdus;
18745 rx->loc_mpdus = rx_stats->loc_mpdus;
18746 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18747 rx->phy_errs = rx_stats->phy_errs;
18748 rx->phy_err_drop = rx_stats->phy_err_drop;
18749 rx->mpdu_errs = rx_stats->mpdu_errs;
18750
18751 return;
18752}
18753
18754/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018755 * extract_pdev_stats_tlv() - extract pdev stats from event
18756 * @wmi_handle: wmi handle
18757 * @param evt_buf: pointer to event buffer
18758 * @param index: Index into pdev stats
18759 * @param pdev_stats: Pointer to hold pdev stats
18760 *
18761 * Return: QDF_STATUS_SUCCESS for success or error code
18762 */
18763static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18764 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18765{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018766 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18767 wmi_stats_event_fixed_param *ev_param;
18768 uint8_t *data;
18769
18770 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18771 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18772
18773 data = param_buf->data;
18774
18775 if (index < ev_param->num_pdev_stats) {
18776 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18777 (index * sizeof(wmi_pdev_stats)));
18778
18779 pdev_stats->chan_nf = ev->chan_nf;
18780 pdev_stats->tx_frame_count = ev->tx_frame_count;
18781 pdev_stats->rx_frame_count = ev->rx_frame_count;
18782 pdev_stats->rx_clear_count = ev->rx_clear_count;
18783 pdev_stats->cycle_count = ev->cycle_count;
18784 pdev_stats->phy_err_count = ev->phy_err_count;
18785 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18786
18787 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18788 &(ev->pdev_stats.tx));
18789 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18790 &(ev->pdev_stats.rx));
18791 }
18792
Govind Singhe7f2f342016-05-23 12:12:52 +053018793 return QDF_STATUS_SUCCESS;
18794}
18795
18796/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018797 * extract_unit_test_tlv() - extract unit test data
18798 * @wmi_handle: wmi handle
18799 * @param evt_buf: pointer to event buffer
18800 * @param unit_test: pointer to hold unit test data
18801 * @param maxspace: Amount of space in evt_buf
18802 *
18803 * Return: QDF_STATUS_SUCCESS for success or error code
18804 */
18805static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18806 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18807{
18808 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18809 wmi_unit_test_event_fixed_param *ev_param;
18810 uint32_t num_bufp;
18811 uint32_t copy_size;
18812 uint8_t *bufp;
18813
18814 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18815 ev_param = param_buf->fixed_param;
18816 bufp = param_buf->bufp;
18817 num_bufp = param_buf->num_bufp;
18818 unit_test->vdev_id = ev_param->vdev_id;
18819 unit_test->module_id = ev_param->module_id;
18820 unit_test->diag_token = ev_param->diag_token;
18821 unit_test->flag = ev_param->flag;
18822 unit_test->payload_len = ev_param->payload_len;
18823 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18824 ev_param->vdev_id,
18825 ev_param->module_id,
18826 ev_param->diag_token,
18827 ev_param->flag);
18828 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18829 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18830 bufp, num_bufp);
18831 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18832 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18833 unit_test->buffer_len = copy_size;
18834
18835 return QDF_STATUS_SUCCESS;
18836}
18837
18838/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018839 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18840 * @wmi_handle: wmi handle
18841 * @param evt_buf: pointer to event buffer
18842 * @param index: Index into extended pdev stats
18843 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18844 *
18845 * Return: QDF_STATUS_SUCCESS for success or error code
18846 */
18847static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18848 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18849{
18850 return QDF_STATUS_SUCCESS;
18851}
18852
18853/**
18854 * extract_vdev_stats_tlv() - extract vdev stats from event
18855 * @wmi_handle: wmi handle
18856 * @param evt_buf: pointer to event buffer
18857 * @param index: Index into vdev stats
18858 * @param vdev_stats: Pointer to hold vdev stats
18859 *
18860 * Return: QDF_STATUS_SUCCESS for success or error code
18861 */
18862static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18863 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18864{
18865 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18866 wmi_stats_event_fixed_param *ev_param;
18867 uint8_t *data;
18868
18869 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18870 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18871 data = (uint8_t *) param_buf->data;
18872
18873 if (index < ev_param->num_vdev_stats) {
18874 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18875 ((ev_param->num_pdev_stats) *
18876 sizeof(wmi_pdev_stats)) +
18877 (index * sizeof(wmi_vdev_stats)));
18878
18879 vdev_stats->vdev_id = ev->vdev_id;
18880 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18881 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18882
18883 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18884 sizeof(ev->tx_frm_cnt));
18885 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18886 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18887 ev->multiple_retry_cnt,
18888 sizeof(ev->multiple_retry_cnt));
18889 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18890 sizeof(ev->fail_cnt));
18891 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18892 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18893 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18894 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18895 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18896 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18897 sizeof(ev->tx_rate_history));
18898 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18899 sizeof(ev->bcn_rssi_history));
18900
18901 }
18902
18903 return QDF_STATUS_SUCCESS;
18904}
18905
18906/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018907 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18908 * buffer
18909 * @wmi_handle: wmi handle
18910 * @evt_buf: pointer to event buffer
18911 * @index: Index into vdev stats
18912 * @rssi_stats: Pointer to hold rssi stats
18913 *
18914 * Return: QDF_STATUS_SUCCESS for success or error code
18915 */
18916static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18917 void *evt_buf, uint32_t index,
18918 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18919{
18920 uint8_t *data;
18921 wmi_rssi_stats *fw_rssi_stats;
18922 wmi_per_chain_rssi_stats *rssi_event;
18923 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18924
18925 if (!evt_buf) {
18926 WMI_LOGE("evt_buf is null");
18927 return QDF_STATUS_E_NULL_VALUE;
18928 }
18929
18930 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18931 rssi_event = param_buf->chain_stats;
18932
18933 if (index >= rssi_event->num_per_chain_rssi_stats) {
18934 WMI_LOGE("invalid index");
18935 return QDF_STATUS_E_INVAL;
18936 }
18937
18938 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18939 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18940
18941 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18942 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18943 fw_rssi_stats->rssi_avg_beacon,
18944 sizeof(fw_rssi_stats->rssi_avg_beacon));
18945 qdf_mem_copy(rssi_stats->rssi_avg_data,
18946 fw_rssi_stats->rssi_avg_data,
18947 sizeof(fw_rssi_stats->rssi_avg_data));
18948 qdf_mem_copy(&rssi_stats->peer_macaddr,
18949 &fw_rssi_stats->peer_macaddr,
18950 sizeof(fw_rssi_stats->peer_macaddr));
18951
18952 return QDF_STATUS_SUCCESS;
18953}
18954
18955
18956
18957/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018958 * extract_bcn_stats_tlv() - extract bcn stats from event
18959 * @wmi_handle: wmi handle
18960 * @param evt_buf: pointer to event buffer
18961 * @param index: Index into vdev stats
18962 * @param bcn_stats: Pointer to hold bcn stats
18963 *
18964 * Return: QDF_STATUS_SUCCESS for success or error code
18965 */
18966static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18967 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18968{
18969 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18970 wmi_stats_event_fixed_param *ev_param;
18971 uint8_t *data;
18972
18973 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18974 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18975 data = (uint8_t *) param_buf->data;
18976
18977 if (index < ev_param->num_bcn_stats) {
18978 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18979 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18980 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18981 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18982 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18983 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18984 (index * sizeof(wmi_bcn_stats)));
18985
18986 bcn_stats->vdev_id = ev->vdev_id;
18987 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18988 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18989 }
18990
18991 return QDF_STATUS_SUCCESS;
18992}
18993
18994/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018995 * extract_peer_stats_tlv() - extract peer stats from event
18996 * @wmi_handle: wmi handle
18997 * @param evt_buf: pointer to event buffer
18998 * @param index: Index into peer stats
18999 * @param peer_stats: Pointer to hold peer stats
19000 *
19001 * Return: QDF_STATUS_SUCCESS for success or error code
19002 */
19003static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19004 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19005{
19006 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19007 wmi_stats_event_fixed_param *ev_param;
19008 uint8_t *data;
19009
19010 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19011 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19012 data = (uint8_t *) param_buf->data;
19013
19014 if (index < ev_param->num_peer_stats) {
19015 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19016 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19017 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19018 (index * sizeof(wmi_peer_stats)));
19019
19020 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19021
19022 OS_MEMCPY(&(peer_stats->peer_macaddr),
19023 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19024
19025 peer_stats->peer_rssi = ev->peer_rssi;
19026 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19027 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19028 }
19029
19030 return QDF_STATUS_SUCCESS;
19031}
19032
19033/**
19034 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19035 * @wmi_handle: wmi handle
19036 * @param evt_buf: pointer to event buffer
19037 * @param index: Index into bcn fault stats
19038 * @param bcnflt_stats: Pointer to hold bcn fault stats
19039 *
19040 * Return: QDF_STATUS_SUCCESS for success or error code
19041 */
19042static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19043 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19044{
19045 return QDF_STATUS_SUCCESS;
19046}
19047
19048/**
19049 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19050 * @wmi_handle: wmi handle
19051 * @param evt_buf: pointer to event buffer
19052 * @param index: Index into extended peer stats
19053 * @param peer_extd_stats: Pointer to hold extended peer stats
19054 *
19055 * Return: QDF_STATUS_SUCCESS for success or error code
19056 */
19057static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19058 void *evt_buf, uint32_t index,
19059 wmi_host_peer_extd_stats *peer_extd_stats)
19060{
19061 return QDF_STATUS_SUCCESS;
19062}
19063
19064/**
19065 * extract_chan_stats_tlv() - extract chan stats from event
19066 * @wmi_handle: wmi handle
19067 * @param evt_buf: pointer to event buffer
19068 * @param index: Index into chan stats
19069 * @param vdev_extd_stats: Pointer to hold chan stats
19070 *
19071 * Return: QDF_STATUS_SUCCESS for success or error code
19072 */
19073static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19074 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19075{
19076 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19077 wmi_stats_event_fixed_param *ev_param;
19078 uint8_t *data;
19079
19080 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19081 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19082 data = (uint8_t *) param_buf->data;
19083
19084 if (index < ev_param->num_chan_stats) {
19085 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19086 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19087 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19088 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19089 (index * sizeof(wmi_chan_stats)));
19090
19091
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019092 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019093 chan_stats->chan_mhz = ev->chan_mhz;
19094 chan_stats->sampling_period_us = ev->sampling_period_us;
19095 chan_stats->rx_clear_count = ev->rx_clear_count;
19096 chan_stats->tx_duration_us = ev->tx_duration_us;
19097 chan_stats->rx_duration_us = ev->rx_duration_us;
19098 }
19099
19100 return QDF_STATUS_SUCCESS;
19101}
19102
19103/**
19104 * extract_profile_ctx_tlv() - extract profile context from event
19105 * @wmi_handle: wmi handle
19106 * @param evt_buf: pointer to event buffer
19107 * @idx: profile stats index to extract
19108 * @param profile_ctx: Pointer to hold profile context
19109 *
19110 * Return: QDF_STATUS_SUCCESS for success or error code
19111 */
19112static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19113 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19114{
19115 return QDF_STATUS_SUCCESS;
19116}
19117
19118/**
19119 * extract_profile_data_tlv() - extract profile data from event
19120 * @wmi_handle: wmi handle
19121 * @param evt_buf: pointer to event buffer
19122 * @param profile_data: Pointer to hold profile data
19123 *
19124 * Return: QDF_STATUS_SUCCESS for success or error code
19125 */
19126static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19127 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19128{
19129
19130 return QDF_STATUS_SUCCESS;
19131}
19132
19133/**
19134 * extract_chan_info_event_tlv() - extract chan information from event
19135 * @wmi_handle: wmi handle
19136 * @param evt_buf: pointer to event buffer
19137 * @param chan_info: Pointer to hold chan information
19138 *
19139 * Return: QDF_STATUS_SUCCESS for success or error code
19140 */
19141static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19142 void *evt_buf, wmi_host_chan_info_event *chan_info)
19143{
19144 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19145 wmi_chan_info_event_fixed_param *ev;
19146
19147 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19148
19149 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19150 if (!ev) {
19151 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19152 return QDF_STATUS_E_FAILURE;
19153 }
19154
19155 chan_info->err_code = ev->err_code;
19156 chan_info->freq = ev->freq;
19157 chan_info->cmd_flags = ev->cmd_flags;
19158 chan_info->noise_floor = ev->noise_floor;
19159 chan_info->rx_clear_count = ev->rx_clear_count;
19160 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019161 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19162 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019163 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19164 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19165 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019166 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19167 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19168 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19169 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19170 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19171 chan_info->rx_frame_count = ev->rx_frame_count;
19172 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19173 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019174
19175 return QDF_STATUS_SUCCESS;
19176}
19177
19178/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019179 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19180 * @wmi_handle: WMI handle
19181 * @param evt_buf: Pointer to event buffer
19182 * @param param: Pointer to hold data
19183 *
19184 * Return : QDF_STATUS_SUCCESS for success or error code
19185 */
19186static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19187 uint8_t *evt_buf,
19188 struct wmi_host_pdev_utf_event *event)
19189{
19190 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019191 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019192
19193 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19194 event->data = param_buf->data;
19195 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019196 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019197 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019198 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019199 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019200
19201 return QDF_STATUS_SUCCESS;
19202}
Govind Singhe7f2f342016-05-23 12:12:52 +053019203
Kiran Venkatappa06520822016-08-10 23:55:40 +053019204/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019205 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19206 * @wmi_handle: wmi handle
19207 * @param evt_buf: pointer to event buffer
19208 * @param param: Pointer to hold evt buf
19209 *
19210 * Return: QDF_STATUS_SUCCESS for success or error code
19211 */
19212static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19213 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19214{
19215 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19216 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19217 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19218 uint8_t i = 0, j = 0;
19219
19220 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19221 if (!param_buf)
19222 return QDF_STATUS_E_INVAL;
19223
19224 hw_caps = param_buf->soc_hw_mode_caps;
19225 if (!hw_caps)
19226 return QDF_STATUS_E_INVAL;
19227
19228 if (!hw_caps->num_chainmask_tables)
19229 return QDF_STATUS_E_INVAL;
19230
19231 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19232
19233 if (chainmask_caps == NULL)
19234 return QDF_STATUS_E_INVAL;
19235
19236 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19237
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019238 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019239 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19240
19241 chainmask_table[i].cap_list[j].chainmask =
19242 chainmask_caps->chainmask;
19243
19244 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19245 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19246
19247 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19248 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19249
19250 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19251 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19252
19253 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19254 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19255
19256 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19257 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19258
19259 chainmask_table[i].cap_list[j].chain_mask_2G =
19260 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19261
19262 chainmask_table[i].cap_list[j].chain_mask_5G =
19263 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19264
19265 chainmask_table[i].cap_list[j].chain_mask_tx =
19266 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19267
19268 chainmask_table[i].cap_list[j].chain_mask_rx =
19269 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19270
19271 chainmask_table[i].cap_list[j].supports_aDFS =
19272 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19273
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019274 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
19275 chainmask_caps->supported_flags,
19276 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019277 );
19278 chainmask_caps++;
19279 }
19280 }
19281
19282 return QDF_STATUS_SUCCESS;
19283}
19284
19285/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019286 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19287 * from event
19288 * @wmi_handle: wmi handle
19289 * @param evt_buf: pointer to event buffer
19290 * @param param: Pointer to hold evt buf
19291 *
19292 * Return: QDF_STATUS_SUCCESS for success or error code
19293 */
19294static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019295 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019296{
19297 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19298 wmi_service_ready_ext_event_fixed_param *ev;
19299 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19300 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019301 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19302 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019303
19304 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19305 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019306 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019307
19308 ev = param_buf->fixed_param;
19309 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019310 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019311
19312 /* Move this to host based bitmap */
19313 param->default_conc_scan_config_bits =
19314 ev->default_conc_scan_config_bits;
19315 param->default_fw_config_bits = ev->default_fw_config_bits;
19316 param->he_cap_info = ev->he_cap_info;
19317 param->mpdu_density = ev->mpdu_density;
19318 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019319 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019320 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019321 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19322
19323 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019324 if (hw_caps)
19325 param->num_hw_modes = hw_caps->num_hw_modes;
19326 else
19327 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019328
19329 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019330 if (reg_caps)
19331 param->num_phy = reg_caps->num_phy;
19332 else
19333 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019334
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019335 if (hw_caps) {
19336 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019337 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019338 } else
19339 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019340
19341 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19342
19343 if (chain_mask_combo == NULL)
19344 return QDF_STATUS_SUCCESS;
19345
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019346 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019347
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019348 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019349
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019350 qdf_print("table_id : %d Num valid chainmasks: %d",
19351 chain_mask_combo->chainmask_table_id,
19352 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019353 );
19354
19355 param->chainmask_table[i].table_id =
19356 chain_mask_combo->chainmask_table_id;
19357 param->chainmask_table[i].num_valid_chainmasks =
19358 chain_mask_combo->num_valid_chainmask;
19359 chain_mask_combo++;
19360 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019361 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019362
Kiran Venkatappa06520822016-08-10 23:55:40 +053019363 return QDF_STATUS_SUCCESS;
19364}
19365
19366/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019367 * extract_sar_cap_service_ready_ext_tlv() -
19368 * extract SAR cap from service ready event
19369 * @wmi_handle: wmi handle
19370 * @event: pointer to event buffer
19371 * @ext_param: extended target info
19372 *
19373 * Return: QDF_STATUS_SUCCESS for success or error code
19374 */
19375static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19376 wmi_unified_t wmi_handle,
19377 uint8_t *event,
19378 struct wlan_psoc_host_service_ext_param *ext_param)
19379{
19380 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19381 WMI_SAR_CAPABILITIES *sar_caps;
19382
19383 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19384
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019385 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019386 return QDF_STATUS_E_INVAL;
19387
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019388 sar_caps = param_buf->sar_caps;
19389 if (sar_caps)
19390 ext_param->sar_version = sar_caps->active_version;
19391 else
19392 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019393
19394 return QDF_STATUS_SUCCESS;
19395}
19396
19397/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019398 * extract_hw_mode_cap_service_ready_ext_tlv() -
19399 * extract HW mode cap from service ready event
19400 * @wmi_handle: wmi handle
19401 * @param evt_buf: pointer to event buffer
19402 * @param param: Pointer to hold evt buf
19403 * @param hw_mode_idx: hw mode idx should be less than num_mode
19404 *
19405 * Return: QDF_STATUS_SUCCESS for success or error code
19406 */
19407static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19408 wmi_unified_t wmi_handle,
19409 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019410 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019411{
19412 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19413 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19414
19415 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19416 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019417 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019418
19419 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019420 if (!hw_caps)
19421 return QDF_STATUS_E_INVAL;
19422
Kiran Venkatappa06520822016-08-10 23:55:40 +053019423 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019424 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019425
19426 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19427 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19428
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019429 param->hw_mode_config_type =
19430 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19431
Kiran Venkatappa06520822016-08-10 23:55:40 +053019432 return QDF_STATUS_SUCCESS;
19433}
19434
19435/**
19436 * extract_mac_phy_cap_service_ready_ext_tlv() -
19437 * extract MAC phy cap from service ready event
19438 * @wmi_handle: wmi handle
19439 * @param evt_buf: pointer to event buffer
19440 * @param param: Pointer to hold evt buf
19441 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019442 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019443 *
19444 * Return: QDF_STATUS_SUCCESS for success or error code
19445 */
19446static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19447 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019448 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019449 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019450{
19451 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019452 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019453 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19454 uint32_t phy_map;
19455 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019456
19457 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19458 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019459 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019460
19461 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019462 if (!hw_caps)
19463 return QDF_STATUS_E_INVAL;
19464
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019465 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19466 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19467 break;
19468
19469 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19470 while (phy_map) {
19471 phy_map >>= 1;
19472 phy_idx++;
19473 }
19474 }
19475
19476 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019477 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019478
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019479 phy_idx += phy_id;
19480 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019481 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019482
19483 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019484
19485 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019486 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19487 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019488 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019489 param->supports_11b =
19490 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19491 param->supports_11g =
19492 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19493 param->supports_11a =
19494 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19495 param->supports_11n =
19496 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19497 param->supports_11ac =
19498 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19499 param->supports_11ax =
19500 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019501
19502 param->supported_bands = mac_phy_caps->supported_bands;
19503 param->ampdu_density = mac_phy_caps->ampdu_density;
19504 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19505 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19506 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19507 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19508 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19509 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19510 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19511 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19512 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19513 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19514 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19515 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19516 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19517 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19518 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19519 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019520 qdf_mem_copy(&param->he_cap_phy_info_2G,
19521 &mac_phy_caps->he_cap_phy_info_2G,
19522 sizeof(param->he_cap_phy_info_2G));
19523 qdf_mem_copy(&param->he_cap_phy_info_5G,
19524 &mac_phy_caps->he_cap_phy_info_5G,
19525 sizeof(param->he_cap_phy_info_5G));
19526 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19527 sizeof(param->he_ppet2G));
19528 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19529 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019530 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019531
19532 return QDF_STATUS_SUCCESS;
19533}
19534
19535/**
19536 * extract_reg_cap_service_ready_ext_tlv() -
19537 * extract REG cap from service ready event
19538 * @wmi_handle: wmi handle
19539 * @param evt_buf: pointer to event buffer
19540 * @param param: Pointer to hold evt buf
19541 * @param phy_idx: phy idx should be less than num_mode
19542 *
19543 * Return: QDF_STATUS_SUCCESS for success or error code
19544 */
19545static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19546 wmi_unified_t wmi_handle,
19547 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019548 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019549{
19550 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19551 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19552 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19553
19554 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19555 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019556 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019557
19558 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019559 if (!reg_caps)
19560 return QDF_STATUS_E_INVAL;
19561
Kiran Venkatappa06520822016-08-10 23:55:40 +053019562 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019563 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019564
19565 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19566
19567 param->phy_id = ext_reg_cap->phy_id;
19568 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19569 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19570 param->regcap1 = ext_reg_cap->regcap1;
19571 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019572 param->wireless_modes = convert_wireless_modes_tlv(
19573 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019574 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19575 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19576 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19577 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19578
19579 return QDF_STATUS_SUCCESS;
19580}
19581
Sathish Kumarf396c722017-11-17 17:30:41 +053019582static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19583 wmi_unified_t wmi_handle,
19584 uint8_t *event, uint8_t idx,
19585 struct wlan_psoc_host_dbr_ring_caps *param)
19586{
19587 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19588 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19589
19590 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19591 if (!param_buf)
19592 return QDF_STATUS_E_INVAL;
19593
19594 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19595
19596 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19597 dbr_ring_caps->pdev_id);
19598 param->mod_id = dbr_ring_caps->mod_id;
19599 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19600 param->min_buf_size = dbr_ring_caps->min_buf_size;
19601 param->min_buf_align = dbr_ring_caps->min_buf_align;
19602
19603 return QDF_STATUS_SUCCESS;
19604}
19605
19606static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19607 uint8_t *event, struct direct_buf_rx_rsp *param)
19608{
19609 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19610 wmi_dma_buf_release_fixed_param *ev;
19611
19612 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19613 if (!param_buf)
19614 return QDF_STATUS_E_INVAL;
19615
19616 ev = param_buf->fixed_param;
19617 if (!ev)
19618 return QDF_STATUS_E_INVAL;
19619
19620 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19621 ev->pdev_id);
19622 param->mod_id = ev->mod_id;
19623 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019624 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019625 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19626 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19627
19628 return QDF_STATUS_SUCCESS;
19629}
19630
19631static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19632 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19633{
19634 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19635 wmi_dma_buf_release_entry *entry;
19636
19637 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19638 if (!param_buf)
19639 return QDF_STATUS_E_INVAL;
19640
19641 entry = &param_buf->entries[idx];
19642
19643 if (!entry) {
19644 WMI_LOGE("%s: Entry is NULL\n", __func__);
19645 return QDF_STATUS_E_FAILURE;
19646 }
19647
19648 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19649
19650 param->paddr_lo = entry->paddr_lo;
19651 param->paddr_hi = entry->paddr_hi;
19652
19653 return QDF_STATUS_SUCCESS;
19654}
19655
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019656static QDF_STATUS extract_dbr_buf_metadata_tlv(
19657 wmi_unified_t wmi_handle, uint8_t *event,
19658 uint8_t idx, struct direct_buf_rx_metadata *param)
19659{
19660 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19661 wmi_dma_buf_release_spectral_meta_data *entry;
19662
19663 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19664 if (!param_buf)
19665 return QDF_STATUS_E_INVAL;
19666
19667 entry = &param_buf->meta_data[idx];
19668
19669 if (!entry) {
19670 WMI_LOGE("%s: Entry is NULL\n", __func__);
19671 return QDF_STATUS_E_FAILURE;
19672 }
19673
19674 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19675 sizeof(entry->noise_floor));
19676 return QDF_STATUS_SUCCESS;
19677}
19678
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019679/**
19680 * extract_dcs_interference_type_tlv() - extract dcs interference type
19681 * from event
19682 * @wmi_handle: wmi handle
19683 * @param evt_buf: pointer to event buffer
19684 * @param param: Pointer to hold dcs interference param
19685 *
19686 * Return: 0 for success or error code
19687 */
19688static QDF_STATUS extract_dcs_interference_type_tlv(
19689 wmi_unified_t wmi_handle,
19690 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19691{
19692 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19693
19694 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19695 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019696 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019697
19698 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019699 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19700 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019701
19702 return QDF_STATUS_SUCCESS;
19703}
19704
19705/*
19706 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19707 * @wmi_handle: wmi handle
19708 * @param evt_buf: pointer to event buffer
19709 * @param cw_int: Pointer to hold cw interference
19710 *
19711 * Return: 0 for success or error code
19712 */
19713static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19714 void *evt_buf,
19715 wmi_host_ath_dcs_cw_int *cw_int)
19716{
19717 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19718 wlan_dcs_cw_int *ev;
19719
19720 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19721 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019722 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019723
19724 ev = param_buf->cw_int;
19725
19726 cw_int->channel = ev->channel;
19727
19728 return QDF_STATUS_SUCCESS;
19729}
19730
19731/**
19732 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19733 * @wmi_handle: wmi handle
19734 * @param evt_buf: pointer to event buffer
19735 * @param wlan_stat: Pointer to hold wlan stats
19736 *
19737 * Return: 0 for success or error code
19738 */
19739static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19740 void *evt_buf,
19741 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19742{
19743 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19744 wlan_dcs_im_tgt_stats_t *ev;
19745
19746 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19747 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019748 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019749
19750 ev = param_buf->wlan_stat;
19751 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19752 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19753 wlan_stat->tx_waste_time = ev->tx_waste_time;
19754 wlan_stat->rx_time = ev->rx_time;
19755 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19756 wlan_stat->mib_stats.listen_time = ev->listen_time;
19757 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19758 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19759 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19760 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19761 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19762 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19763 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19764 wlan_stat->chan_nf = ev->chan_nf;
19765 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19766
19767 return QDF_STATUS_SUCCESS;
19768}
19769
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019770/**
19771 * extract_thermal_stats_tlv() - extract thermal stats from event
19772 * @wmi_handle: wmi handle
19773 * @param evt_buf: Pointer to event buffer
19774 * @param temp: Pointer to hold extracted temperature
19775 * @param level: Pointer to hold extracted level
19776 *
19777 * Return: 0 for success or error code
19778 */
19779static QDF_STATUS
19780extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19781 void *evt_buf, uint32_t *temp,
19782 uint32_t *level, uint32_t *pdev_id)
19783{
19784 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19785 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19786
19787 param_buf =
19788 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19789 if (!param_buf)
19790 return QDF_STATUS_E_INVAL;
19791
19792 tt_stats_event = param_buf->fixed_param;
19793
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019794 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19795 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019796 *temp = tt_stats_event->temp;
19797 *level = tt_stats_event->level;
19798
19799 return QDF_STATUS_SUCCESS;
19800}
19801
19802/**
19803 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19804 * @wmi_handle: wmi handle
19805 * @param evt_buf: pointer to event buffer
19806 * @param idx: Index to level stats
19807 * @param levelcount: Pointer to hold levelcount
19808 * @param dccount: Pointer to hold dccount
19809 *
19810 * Return: 0 for success or error code
19811 */
19812static QDF_STATUS
19813extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19814 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19815 uint32_t *dccount)
19816{
19817 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19818 wmi_therm_throt_level_stats_info *tt_level_info;
19819
19820 param_buf =
19821 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19822 if (!param_buf)
19823 return QDF_STATUS_E_INVAL;
19824
19825 tt_level_info = param_buf->therm_throt_level_stats_info;
19826
19827 if (idx < THERMAL_LEVELS) {
19828 *levelcount = tt_level_info[idx].level_count;
19829 *dccount = tt_level_info[idx].dc_count;
19830 return QDF_STATUS_SUCCESS;
19831 }
19832
19833 return QDF_STATUS_E_FAILURE;
19834}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019835#ifdef BIG_ENDIAN_HOST
19836/**
19837 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19838 * @param data_len - data length
19839 * @param data - pointer to data
19840 *
19841 * Return: QDF_STATUS - success or error status
19842 */
19843static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19844{
19845 uint8_t *data_aligned = NULL;
19846 int c;
19847 unsigned char *data_unaligned;
19848
19849 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19850 FIPS_ALIGN));
19851 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019852 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019853 if (data_unaligned == NULL)
19854 return QDF_STATUS_E_FAILURE;
19855
19856 /* Checking if space is alligned */
19857 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19858 /* align the data space */
19859 data_aligned =
19860 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19861 } else {
19862 data_aligned = (u_int8_t *)data_unaligned;
19863 }
19864
19865 /* memset and copy content from data to data aligned */
19866 OS_MEMSET(data_aligned, 0, data_len);
19867 OS_MEMCPY(data_aligned, data, data_len);
19868 /* Endianness to LE */
19869 for (c = 0; c < data_len/4; c++) {
19870 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019871 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019872 }
19873
19874 /* Copy content to event->data */
19875 OS_MEMCPY(data, data_aligned, data_len);
19876
19877 /* clean up allocated space */
19878 qdf_mem_free(data_unaligned);
19879 data_aligned = NULL;
19880 data_unaligned = NULL;
19881
19882 /*************************************************************/
19883
19884 return QDF_STATUS_SUCCESS;
19885}
19886#else
19887/**
19888 * fips_conv_data_be() - DUMMY for LE platform
19889 *
19890 * Return: QDF_STATUS - success
19891 */
19892static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19893{
19894 return QDF_STATUS_SUCCESS;
19895}
19896#endif
19897
19898/**
19899 * extract_fips_event_data_tlv() - extract fips event data
19900 * @wmi_handle: wmi handle
19901 * @param evt_buf: pointer to event buffer
19902 * @param param: pointer FIPS event params
19903 *
19904 * Return: 0 for success or error code
19905 */
19906static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19907 void *evt_buf, struct wmi_host_fips_event_param *param)
19908{
19909 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19910 wmi_pdev_fips_event_fixed_param *event;
19911
19912 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19913 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19914
19915 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19916 QDF_STATUS_SUCCESS)
19917 return QDF_STATUS_E_FAILURE;
19918
19919 param->data = (uint32_t *)param_buf->data;
19920 param->data_len = event->data_len;
19921 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019922 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19923 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019924
19925 return QDF_STATUS_SUCCESS;
19926}
19927
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019928/*
19929 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19930 * @wmi_handle: wmi handle
19931 * @param evt_buf: pointer to event buffer
19932 * @param vdev_id: Pointer to hold vdev_id
19933 * @param mac_addr: Pointer to hold peer mac address
19934 *
19935 * Return: QDF_STATUS_SUCCESS for success or error code
19936 */
19937static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19938 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19939{
19940 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19941 wmi_peer_delete_resp_event_fixed_param *ev;
19942
19943 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19944
19945 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19946 if (!ev) {
19947 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19948 return QDF_STATUS_E_FAILURE;
19949 }
19950
19951 param->vdev_id = ev->vdev_id;
19952 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19953 &param->mac_address.bytes[0]);
19954
19955 return QDF_STATUS_SUCCESS;
19956}
19957
Govind Singhecf03cd2016-05-12 12:45:51 +053019958static bool is_management_record_tlv(uint32_t cmd_id)
19959{
jiad36c94d22018-01-22 15:37:03 +080019960 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19961 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19962 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019963 return true;
jiad36c94d22018-01-22 15:37:03 +080019964 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019965
Govind Singhecf03cd2016-05-12 12:45:51 +053019966 return false;
19967}
19968
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019969static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19970{
19971 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19972
19973 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19974
19975 switch (set_cmd->param_id) {
19976 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19977 case WMI_VDEV_PARAM_DTIM_POLICY:
19978 return HTC_TX_PACKET_TAG_AUTO_PM;
19979 default:
19980 break;
19981 }
19982
19983 return 0;
19984}
19985
19986static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19987{
19988 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19989
19990 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19991
19992 switch (ps_cmd->param) {
19993 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19994 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19995 case WMI_STA_PS_ENABLE_QPOWER:
19996 return HTC_TX_PACKET_TAG_AUTO_PM;
19997 default:
19998 break;
19999 }
20000
20001 return 0;
20002}
20003
20004static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20005 uint32_t cmd_id)
20006{
20007 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20008 return 0;
20009
20010 switch (cmd_id) {
20011 case WMI_VDEV_SET_PARAM_CMDID:
20012 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20013 case WMI_STA_POWERSAVE_PARAM_CMDID:
20014 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20015 default:
20016 break;
20017 }
20018
20019 return 0;
20020}
20021
20022static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20023{
20024 uint16_t tag = 0;
20025
20026 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20027 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20028 __func__);
20029 return tag;
20030 }
20031
20032 if (wmi_handle->tag_crash_inject)
20033 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20034
20035 wmi_handle->tag_crash_inject = false;
20036 return tag;
20037}
20038
20039/**
20040 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20041 * @wmi_handle: WMI handle
20042 * @buf: WMI buffer
20043 * @cmd_id: WMI command Id
20044 *
20045 * Return htc_tx_tag
20046 */
20047static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20048 wmi_buf_t buf,
20049 uint32_t cmd_id)
20050{
20051 uint16_t htc_tx_tag = 0;
20052
20053 switch (cmd_id) {
20054 case WMI_WOW_ENABLE_CMDID:
20055 case WMI_PDEV_SUSPEND_CMDID:
20056 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20057 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20058 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20059 case WMI_PDEV_RESUME_CMDID:
20060 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20061 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20062#ifdef FEATURE_WLAN_D0WOW
20063 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20064#endif
20065 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20066 break;
20067 case WMI_FORCE_FW_HANG_CMDID:
20068 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20069 break;
20070 case WMI_VDEV_SET_PARAM_CMDID:
20071 case WMI_STA_POWERSAVE_PARAM_CMDID:
20072 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20073 default:
20074 break;
20075 }
20076
20077 return htc_tx_tag;
20078}
20079
Sathish Kumard3ab1002017-02-07 17:10:59 +053020080/**
20081 * extract_channel_hopping_event_tlv() - extract channel hopping param
20082 * from event
20083 * @wmi_handle: wmi handle
20084 * @param evt_buf: pointer to event buffer
20085 * @param ch_hopping: Pointer to hold channel hopping param
20086 *
20087 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20088 */
20089static QDF_STATUS extract_channel_hopping_event_tlv(
20090 wmi_unified_t wmi_handle, void *evt_buf,
20091 wmi_host_pdev_channel_hopping_event *ch_hopping)
20092{
20093 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20094 wmi_pdev_channel_hopping_event_fixed_param *event;
20095
20096 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20097 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20098 param_buf->fixed_param;
20099
20100 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20101 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020102 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20103 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020104
20105 return QDF_STATUS_SUCCESS;
20106}
20107
20108/**
20109 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20110 * @wmi_handle: wmi handle
20111 * @param evt_buf: pointer to event buffer
20112 * @param param: Pointer to hold tpc param
20113 *
20114 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20115 */
20116static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20117 void *evt_buf,
20118 wmi_host_pdev_tpc_event *param)
20119{
20120 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20121 wmi_pdev_tpc_event_fixed_param *event;
20122
20123 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20124 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20125
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020126 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20127 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020128 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20129
20130 return QDF_STATUS_SUCCESS;
20131}
20132
nobeljf74583b2018-01-25 16:35:36 -080020133/**
20134 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20135 * power param from event
20136 * @wmi_handle: wmi handle
20137 * @param evt_buf: pointer to event buffer
20138 * @param param: Pointer to hold nf cal power param
20139 *
20140 * Return: 0 for success or error code
20141 */
20142static QDF_STATUS
20143extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20144 void *evt_buf,
20145 wmi_host_pdev_nfcal_power_all_channels_event *param)
20146{
20147 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20148 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20149 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20150 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20151 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20152 uint32_t i;
20153
20154 param_buf =
20155 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20156 event = param_buf->fixed_param;
20157 ch_nfdbr = param_buf->nfdbr;
20158 ch_nfdbm = param_buf->nfdbm;
20159 ch_freqnum = param_buf->freqnum;
20160
20161 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20162 event->pdev_id, param_buf->num_nfdbr,
20163 param_buf->num_nfdbm, param_buf->num_freqnum);
20164
20165 if (param_buf->num_nfdbr >
20166 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20167 WMI_LOGE("invalid number of nfdBr");
20168 return QDF_STATUS_E_FAILURE;
20169 }
20170
20171 if (param_buf->num_nfdbm >
20172 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20173 WMI_LOGE("invalid number of nfdBm");
20174 return QDF_STATUS_E_FAILURE;
20175 }
20176
20177 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20178 WMI_LOGE("invalid number of freqNum");
20179 return QDF_STATUS_E_FAILURE;
20180 }
20181
20182 for (i = 0; i < param_buf->num_nfdbr; i++) {
20183 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20184 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20185 ch_nfdbr++;
20186 ch_nfdbm++;
20187 }
20188
20189 for (i = 0; i < param_buf->num_freqnum; i++) {
20190 param->freqnum[i] = ch_freqnum->freqNum;
20191 ch_freqnum++;
20192 }
20193
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020194 param->pdev_id = wmi_handle->ops->
20195 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020196
20197 return QDF_STATUS_SUCCESS;
20198}
20199
Sathish Kumard3ab1002017-02-07 17:10:59 +053020200
20201#ifdef BIG_ENDIAN_HOST
20202/**
20203 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20204 * @param data_len - data length
20205 * @param data - pointer to data
20206 *
20207 * Return: QDF_STATUS - success or error status
20208 */
20209static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20210{
20211 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020212 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020213 /* Skip swapping the first word */
20214 datap += sizeof(uint32_t);
20215 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20216 i++, datap += sizeof(uint32_t)) {
20217 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20218 }
20219
20220 return QDF_STATUS_SUCCESS;
20221}
20222#else
20223/**
20224 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20225 * @param data_len - data length
20226 * @param data - pointer to data
20227 *
20228 * Return: QDF_STATUS - success or error status
20229 */
20230static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20231{
20232 return QDF_STATUS_SUCCESS;
20233}
20234#endif
20235
20236/**
20237 * extract_wds_addr_event_tlv() - extract wds address from event
20238 * @wmi_handle: wmi handle
20239 * @param evt_buf: pointer to event buffer
20240 * @param wds_ev: Pointer to hold wds address
20241 *
20242 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20243 */
20244static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20245 void *evt_buf,
20246 uint16_t len, wds_addr_event_t *wds_ev)
20247{
20248 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20249 wmi_wds_addr_event_fixed_param *ev;
20250 int i;
20251
20252 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20253 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20254
20255 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20256 return QDF_STATUS_E_FAILURE;
20257
20258 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20259 sizeof(wds_ev->event_type));
20260 for (i = 0; i < 4; i++) {
20261 wds_ev->peer_mac[i] =
20262 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20263 wds_ev->dest_mac[i] =
20264 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20265 }
20266 for (i = 0; i < 2; i++) {
20267 wds_ev->peer_mac[4+i] =
20268 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20269 wds_ev->dest_mac[4+i] =
20270 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20271 }
20272 return QDF_STATUS_SUCCESS;
20273}
20274
20275/**
20276 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20277 * from event
20278 * @wmi_handle: wmi handle
20279 * @param evt_buf: pointer to event buffer
20280 * @param ev: Pointer to hold peer param and ps state
20281 *
20282 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20283 */
20284static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20285 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20286{
20287 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20288 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20289
20290 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20291 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20292 param_buf->fixed_param;
20293
20294 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20295 ev->peer_ps_state = event->peer_ps_state;
20296
20297 return QDF_STATUS_SUCCESS;
20298}
20299
20300/**
20301 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20302 * @wmi_handle: wmi handle
20303 * @param evt_buf: pointer to event buffer
20304 * @param inst_rssi_resp: Pointer to hold inst rssi response
20305 *
20306 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20307 */
20308static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20309 wmi_unified_t wmi_handle, void *evt_buf,
20310 wmi_host_inst_stats_resp *inst_rssi_resp)
20311{
20312 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20313 wmi_inst_rssi_stats_resp_fixed_param *event;
20314
20315 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20316 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20317
20318 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20319 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20320 inst_rssi_resp->iRSSI = event->iRSSI;
20321
20322 return QDF_STATUS_SUCCESS;
20323}
20324
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020325static struct cur_reg_rule
20326*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20327 wmi_regulatory_rule_struct *wmi_reg_rule)
20328{
20329 struct cur_reg_rule *reg_rule_ptr;
20330 uint32_t count;
20331
20332 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20333
20334 if (NULL == reg_rule_ptr) {
20335 WMI_LOGE("memory allocation failure");
20336 return NULL;
20337 }
20338
20339 for (count = 0; count < num_reg_rules; count++) {
20340 reg_rule_ptr[count].start_freq =
20341 WMI_REG_RULE_START_FREQ_GET(
20342 wmi_reg_rule[count].freq_info);
20343 reg_rule_ptr[count].end_freq =
20344 WMI_REG_RULE_END_FREQ_GET(
20345 wmi_reg_rule[count].freq_info);
20346 reg_rule_ptr[count].max_bw =
20347 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020348 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020349 reg_rule_ptr[count].reg_power =
20350 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020351 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020352 reg_rule_ptr[count].ant_gain =
20353 WMI_REG_RULE_ANTENNA_GAIN_GET(
20354 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020355 reg_rule_ptr[count].flags =
20356 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020357 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020358 }
20359
20360 return reg_rule_ptr;
20361}
20362
20363static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20364 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20365 struct cur_regulatory_info *reg_info, uint32_t len)
20366{
20367 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20368 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20369 wmi_regulatory_rule_struct *wmi_reg_rule;
20370 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20371
20372 WMI_LOGD("processing regulatory channel list");
20373
20374 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20375 if (!param_buf) {
20376 WMI_LOGE("invalid channel list event buf");
20377 return QDF_STATUS_E_FAILURE;
20378 }
20379
20380 chan_list_event_hdr = param_buf->fixed_param;
20381
20382 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20383 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20384 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020385 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020386 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20387 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020388 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020389 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020390 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020391 reg_info->ctry_code = chan_list_event_hdr->country_id;
20392 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20393 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20394 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20395 else if (chan_list_event_hdr->status_code ==
20396 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20397 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20398 else if (chan_list_event_hdr->status_code ==
20399 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20400 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20401 else if (chan_list_event_hdr->status_code ==
20402 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20403 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20404 else if (chan_list_event_hdr->status_code ==
20405 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20406 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20407 else if (chan_list_event_hdr->status_code ==
20408 WMI_REG_SET_CC_STATUS_FAIL)
20409 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20410
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020411 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20412 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20413 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20414 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20415
20416 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20417 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20418
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020419 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20420 __func__, reg_info->alpha2, reg_info->dfs_region,
20421 reg_info->min_bw_2g, reg_info->max_bw_2g,
20422 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020423
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020424 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20425 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020426 wmi_reg_rule =
20427 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20428 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20429 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020430 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20431 wmi_reg_rule);
20432 wmi_reg_rule += num_2g_reg_rules;
20433
20434 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20435 wmi_reg_rule);
20436
20437 WMI_LOGD("processed regulatory channel list");
20438
20439 return QDF_STATUS_SUCCESS;
20440}
20441
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020442static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20443 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20444 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20445{
20446 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20447 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20448
20449 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20450 if (!param_buf) {
20451 WMI_LOGE("invalid 11d country event buf");
20452 return QDF_STATUS_E_FAILURE;
20453 }
20454
20455 reg_11d_country_event = param_buf->fixed_param;
20456
20457 qdf_mem_copy(reg_11d_country->alpha2,
20458 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20459
20460 WMI_LOGD("processed 11d country event, new cc %s",
20461 reg_11d_country->alpha2);
20462
20463 return QDF_STATUS_SUCCESS;
20464}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020465
20466static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20467 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20468 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20469{
20470 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20471 wmi_avoid_freq_range_desc *afr_desc;
20472 uint32_t num_freq_ranges, freq_range_idx;
20473 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20474 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20475
20476 if (!param_buf) {
20477 WMI_LOGE("Invalid channel avoid event buffer");
20478 return QDF_STATUS_E_INVAL;
20479 }
20480
20481 afr_fixed_param = param_buf->fixed_param;
20482 if (!afr_fixed_param) {
20483 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20484 return QDF_STATUS_E_INVAL;
20485 }
20486
20487 if (!ch_avoid_ind) {
20488 WMI_LOGE("Invalid channel avoid indication buffer");
20489 return QDF_STATUS_E_INVAL;
20490 }
20491 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20492 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20493 afr_fixed_param->num_freq_ranges;
20494
20495 WMI_LOGD("Channel avoid event received with %d ranges",
20496 num_freq_ranges);
20497
20498 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20499 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20500 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20501 freq_range_idx++) {
20502 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20503 afr_desc->start_freq;
20504 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20505 afr_desc->end_freq;
20506 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20507 freq_range_idx, afr_desc->tlv_header,
20508 afr_desc->start_freq, afr_desc->end_freq);
20509 afr_desc++;
20510 }
20511
20512 return QDF_STATUS_SUCCESS;
20513}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020514#ifdef DFS_COMPONENT_ENABLE
20515/**
20516 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20517 * @wmi_handle: wma handle
20518 * @evt_buf: event buffer
20519 * @vdev_id: vdev id
20520 * @len: length of buffer
20521 *
20522 * Return: 0 for success or error code
20523 */
20524static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20525 uint8_t *evt_buf,
20526 uint32_t *vdev_id,
20527 uint32_t len)
20528{
20529 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20530 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20531
20532 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20533 if (!param_tlvs) {
20534 WMI_LOGE("invalid cac complete event buf");
20535 return QDF_STATUS_E_FAILURE;
20536 }
20537
20538 cac_event = param_tlvs->fixed_param;
20539 *vdev_id = cac_event->vdev_id;
20540 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20541
20542 return QDF_STATUS_SUCCESS;
20543}
20544
20545/**
20546 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20547 * @wmi_handle: wma handle
20548 * @evt_buf: event buffer
20549 * @radar_found: radar found event info
20550 * @len: length of buffer
20551 *
20552 * Return: 0 for success or error code
20553 */
20554static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20555 wmi_unified_t wmi_handle,
20556 uint8_t *evt_buf,
20557 struct radar_found_info *radar_found,
20558 uint32_t len)
20559{
20560 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20561 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20562
20563 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20564 if (!param_tlv) {
20565 WMI_LOGE("invalid radar detection event buf");
20566 return QDF_STATUS_E_FAILURE;
20567 }
20568
20569 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020570 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20571 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020572 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020573 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020574 radar_found->chan_width = radar_event->chan_width;
20575 radar_found->detector_id = radar_event->detector_id;
20576 radar_found->segment_id = radar_event->segment_id;
20577 radar_found->timestamp = radar_event->timestamp;
20578 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020579 radar_found->freq_offset = radar_event->freq_offset;
20580 radar_found->sidx = radar_event->sidx;
20581
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020582 WMI_LOGI("processed radar found event pdev %d,"
20583 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20584 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20585 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20586 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020587 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020588 radar_event->timestamp, radar_event->chan_freq,
20589 radar_event->chan_width, radar_event->detector_id,
20590 radar_event->freq_offset, radar_event->segment_id,
20591 radar_event->sidx, radar_event->is_chirp,
20592 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020593
20594 return QDF_STATUS_SUCCESS;
20595}
bings1ea12532017-12-18 16:56:53 +080020596
20597#ifdef QCA_MCL_DFS_SUPPORT
20598/**
20599 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20600 * @wmi_handle: wma handle
20601 * @evt_buf: event buffer
20602 * @wlan_radar_event: Pointer to struct radar_event_info
20603 * @len: length of buffer
20604 *
20605 * Return: QDF_STATUS
20606 */
20607static QDF_STATUS extract_wlan_radar_event_info_tlv(
20608 wmi_unified_t wmi_handle,
20609 uint8_t *evt_buf,
20610 struct radar_event_info *wlan_radar_event,
20611 uint32_t len)
20612{
20613 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20614 wmi_dfs_radar_event_fixed_param *radar_event;
20615
20616 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20617 if (!param_tlv) {
20618 WMI_LOGE("invalid wlan radar event buf");
20619 return QDF_STATUS_E_FAILURE;
20620 }
20621
20622 radar_event = param_tlv->fixed_param;
20623 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20624 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20625 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20626 wlan_radar_event->rssi = radar_event->rssi;
20627 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20628 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20629 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20630 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020631 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20632 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020633 if (radar_event->pulse_flags &
20634 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20635 wlan_radar_event->is_psidx_diff_valid = true;
20636 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20637 } else {
20638 wlan_radar_event->is_psidx_diff_valid = false;
20639 }
20640
bings1ea12532017-12-18 16:56:53 +080020641 wlan_radar_event->pdev_id = radar_event->pdev_id;
20642
20643 return QDF_STATUS_SUCCESS;
20644}
20645#else
20646static QDF_STATUS extract_wlan_radar_event_info_tlv(
20647 wmi_unified_t wmi_handle,
20648 uint8_t *evt_buf,
20649 struct radar_event_info *wlan_radar_event,
20650 uint32_t len)
20651{
20652 return QDF_STATUS_SUCCESS;
20653}
20654#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020655#endif
20656
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020657/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020658 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20659 * @wmi_handle: wmi handle
20660 * @get_rcpi_param: rcpi params
20661 *
20662 * Return: QDF status
20663 */
20664static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20665 struct rcpi_req *get_rcpi_param)
20666{
20667 wmi_buf_t buf;
20668 wmi_request_rcpi_cmd_fixed_param *cmd;
20669 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20670
20671 buf = wmi_buf_alloc(wmi_handle, len);
20672 if (!buf) {
20673 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20674 return QDF_STATUS_E_NOMEM;
20675 }
20676
20677 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20678 WMITLV_SET_HDR(&cmd->tlv_header,
20679 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20680 WMITLV_GET_STRUCT_TLVLEN
20681 (wmi_request_rcpi_cmd_fixed_param));
20682
20683 cmd->vdev_id = get_rcpi_param->vdev_id;
20684 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20685 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020686
20687 switch (get_rcpi_param->measurement_type) {
20688
20689 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20690 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20691 break;
20692
20693 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20694 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20695 break;
20696
20697 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20698 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20699 break;
20700
20701 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20702 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20703 break;
20704
20705 default:
20706 /*
20707 * invalid rcpi measurement type, fall back to
20708 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20709 */
20710 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20711 break;
20712 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020713 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20714 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20715 WMI_REQUEST_RCPI_CMDID)) {
20716
20717 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20718 __func__);
20719 wmi_buf_free(buf);
20720 return QDF_STATUS_E_FAILURE;
20721 }
20722
20723 return QDF_STATUS_SUCCESS;
20724}
20725
20726/**
20727 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20728 * @wmi_handle: wmi handle
20729 * @evt_buf: pointer to event buffer
20730 * @res: pointer to hold rcpi response from firmware
20731 *
20732 * Return: QDF_STATUS_SUCCESS for successful event parse
20733 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20734 */
20735static QDF_STATUS
20736extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20737 void *evt_buf, struct rcpi_res *res)
20738{
20739 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20740 wmi_update_rcpi_event_fixed_param *event;
20741
20742 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20743 if (!param_buf) {
20744 WMI_LOGE(FL("Invalid rcpi event"));
20745 return QDF_STATUS_E_INVAL;
20746 }
20747
20748 event = param_buf->fixed_param;
20749 res->vdev_id = event->vdev_id;
20750 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20751
20752 switch (event->measurement_type) {
20753
20754 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20755 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20756 break;
20757
20758 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20759 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20760 break;
20761
20762 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20763 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20764 break;
20765
20766 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20767 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20768 break;
20769
20770 default:
20771 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20772 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20773 return QDF_STATUS_E_FAILURE;
20774 }
20775
20776 if (event->status)
20777 return QDF_STATUS_E_FAILURE;
20778 else
20779 return QDF_STATUS_SUCCESS;
20780}
20781
20782/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020783 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20784 * host to target defines. For legacy there is not conversion
20785 * required. Just return pdev_id as it is.
20786 * @param pdev_id: host pdev_id to be converted.
20787 * Return: target pdev_id after conversion.
20788 */
20789static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20790 uint32_t pdev_id)
20791{
20792 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20793 return WMI_PDEV_ID_SOC;
20794
20795 /*No conversion required*/
20796 return pdev_id;
20797}
20798
20799/**
20800 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20801 * target to host defines. For legacy there is not conversion
20802 * required. Just return pdev_id as it is.
20803 * @param pdev_id: target pdev_id to be converted.
20804 * Return: host pdev_id after conversion.
20805 */
20806static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20807 uint32_t pdev_id)
20808{
20809 /*No conversion required*/
20810 return pdev_id;
20811}
20812
20813/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020814 * send_set_country_cmd_tlv() - WMI scan channel list function
20815 * @param wmi_handle : handle to WMI.
20816 * @param param : pointer to hold scan channel list parameter
20817 *
20818 * Return: 0 on success and -ve on failure.
20819 */
20820static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20821 struct set_country *params)
20822{
20823 wmi_buf_t buf;
20824 QDF_STATUS qdf_status;
20825 wmi_set_current_country_cmd_fixed_param *cmd;
20826 uint16_t len = sizeof(*cmd);
20827
20828 buf = wmi_buf_alloc(wmi_handle, len);
20829 if (!buf) {
20830 WMI_LOGE("Failed to allocate memory");
20831 qdf_status = QDF_STATUS_E_NOMEM;
20832 goto end;
20833 }
20834
20835 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20836 WMITLV_SET_HDR(&cmd->tlv_header,
20837 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20838 WMITLV_GET_STRUCT_TLVLEN
20839 (wmi_set_current_country_cmd_fixed_param));
20840
20841 WMI_LOGD("setting cuurnet country to %s", params->country);
20842
20843 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20844
20845 cmd->pdev_id = params->pdev_id;
20846
20847 qdf_status = wmi_unified_cmd_send(wmi_handle,
20848 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20849
20850 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20851 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20852 wmi_buf_free(buf);
20853 }
20854
20855end:
20856 return qdf_status;
20857}
20858
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020859#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20860 WMI_SET_BITS(alpha, 0, 8, val0); \
20861 WMI_SET_BITS(alpha, 8, 8, val1); \
20862 WMI_SET_BITS(alpha, 16, 8, val2); \
20863 } while (0)
20864
20865static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20866 uint8_t pdev_id, struct cc_regdmn_s *rd)
20867{
20868 wmi_set_init_country_cmd_fixed_param *cmd;
20869 uint16_t len;
20870 wmi_buf_t buf;
20871 int ret;
20872
20873 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20874 buf = wmi_buf_alloc(wmi_handle, len);
20875 if (!buf) {
20876 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20877 return QDF_STATUS_E_NOMEM;
20878 }
20879 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20880 WMITLV_SET_HDR(&cmd->tlv_header,
20881 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20882 WMITLV_GET_STRUCT_TLVLEN
20883 (wmi_set_init_country_cmd_fixed_param));
20884
20885 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20886
20887 if (rd->flags == CC_IS_SET) {
20888 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20889 cmd->country_code.country_id = rd->cc.country_code;
20890 } else if (rd->flags == ALPHA_IS_SET) {
20891 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20892 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20893 rd->cc.alpha[0],
20894 rd->cc.alpha[1],
20895 rd->cc.alpha[2]);
20896 } else if (rd->flags == REGDMN_IS_SET) {
20897 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20898 cmd->country_code.domain_code = rd->cc.regdmn_id;
20899 }
20900
20901 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20902 WMI_SET_INIT_COUNTRY_CMDID);
20903 if (ret) {
20904 WMI_LOGE("Failed to config wow wakeup event");
20905 wmi_buf_free(buf);
20906 return QDF_STATUS_E_FAILURE;
20907 }
20908
20909 return QDF_STATUS_SUCCESS;
20910}
20911
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020912/**
20913 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20914 * configuration params
20915 * @wmi_handle: wmi handler
20916 * @limit_off_chan_param: pointer to wmi_off_chan_param
20917 *
20918 * Return: 0 for success and non zero for failure
20919 */
20920static
20921QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20922 struct wmi_limit_off_chan_param *limit_off_chan_param)
20923{
20924 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20925 wmi_buf_t buf;
20926 uint32_t len = sizeof(*cmd);
20927 int err;
20928
20929 buf = wmi_buf_alloc(wmi_handle, len);
20930 if (!buf) {
20931 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20932 __func__);
20933 return QDF_STATUS_E_NOMEM;
20934 }
20935
20936 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20937
20938 WMITLV_SET_HDR(&cmd->tlv_header,
20939 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20940 WMITLV_GET_STRUCT_TLVLEN(
20941 wmi_vdev_limit_offchan_cmd_fixed_param));
20942
20943 cmd->vdev_id = limit_off_chan_param->vdev_id;
20944
20945 cmd->flags &= 0;
20946 if (limit_off_chan_param->status)
20947 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20948 if (limit_off_chan_param->skip_dfs_chans)
20949 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20950
20951 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20952 cmd->rest_time = limit_off_chan_param->rest_time;
20953
20954 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20955 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20956 cmd->rest_time);
20957
20958 err = wmi_unified_cmd_send(wmi_handle, buf,
20959 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20960 if (QDF_IS_STATUS_ERROR(err)) {
20961 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20962 wmi_buf_free(buf);
20963 return QDF_STATUS_E_FAILURE;
20964 }
20965
20966 return QDF_STATUS_SUCCESS;
20967}
20968
Anurag Chouhan97f00422017-09-11 14:56:30 +053020969/**
20970 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20971 * @wmi_handle: wmi handler
20972 * @req_buf: set arp stats request buffer
20973 *
20974 * Return: 0 for success and non zero for failure
20975 */
20976static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20977 struct set_arp_stats *req_buf)
20978{
20979 wmi_buf_t buf = NULL;
20980 QDF_STATUS status;
20981 int len;
20982 uint8_t *buf_ptr;
20983 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20984
20985 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020986 if (req_buf->pkt_type_bitmap) {
20987 len += WMI_TLV_HDR_SIZE;
20988 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20989 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020990 buf = wmi_buf_alloc(wmi_handle, len);
20991 if (!buf) {
20992 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20993 return QDF_STATUS_E_NOMEM;
20994 }
20995
20996 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20997 wmi_set_arp =
20998 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20999 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21000 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21001 WMITLV_GET_STRUCT_TLVLEN
21002 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21003
21004 /* fill in per roam config values */
21005 wmi_set_arp->vdev_id = req_buf->vdev_id;
21006
21007 wmi_set_arp->set_clr = req_buf->flag;
21008 wmi_set_arp->pkt_type = req_buf->pkt_type;
21009 wmi_set_arp->ipv4 = req_buf->ip_addr;
21010
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021011 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21012 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21013 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21014
21015 /*
21016 * pkt_type_bitmap should be non-zero to ensure
21017 * presence of additional stats.
21018 */
21019 if (req_buf->pkt_type_bitmap) {
21020 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21021
21022 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21023 WMITLV_SET_HDR(buf_ptr,
21024 WMITLV_TAG_ARRAY_STRUC,
21025 sizeof(wmi_vdev_set_connectivity_check_stats));
21026 buf_ptr += WMI_TLV_HDR_SIZE;
21027 wmi_set_connect_stats =
21028 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21029 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21030 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21031 WMITLV_GET_STRUCT_TLVLEN(
21032 wmi_vdev_set_connectivity_check_stats));
21033 wmi_set_connect_stats->pkt_type_bitmap =
21034 req_buf->pkt_type_bitmap;
21035 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21036 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21037 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21038
21039 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21040 wmi_set_connect_stats->pkt_type_bitmap,
21041 wmi_set_connect_stats->tcp_src_port,
21042 wmi_set_connect_stats->tcp_dst_port,
21043 wmi_set_connect_stats->icmp_ipv4);
21044 }
21045
Anurag Chouhan97f00422017-09-11 14:56:30 +053021046 /* Send per roam config parameters */
21047 status = wmi_unified_cmd_send(wmi_handle, buf,
21048 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21049 if (QDF_IS_STATUS_ERROR(status)) {
21050 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21051 status);
21052 goto error;
21053 }
21054
21055 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21056 req_buf->flag, req_buf->vdev_id);
21057 return QDF_STATUS_SUCCESS;
21058error:
21059 wmi_buf_free(buf);
21060
21061 return status;
21062}
21063
21064/**
21065 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21066 * @wmi_handle: wmi handler
21067 * @req_buf: get arp stats request buffer
21068 *
21069 * Return: 0 for success and non zero for failure
21070 */
21071static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21072 struct get_arp_stats *req_buf)
21073{
21074 wmi_buf_t buf = NULL;
21075 QDF_STATUS status;
21076 int len;
21077 uint8_t *buf_ptr;
21078 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21079
21080 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21081 buf = wmi_buf_alloc(wmi_handle, len);
21082 if (!buf) {
21083 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21084 return QDF_STATUS_E_NOMEM;
21085 }
21086
21087 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21088 get_arp_stats =
21089 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21090 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21091 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21092 WMITLV_GET_STRUCT_TLVLEN
21093 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21094
21095 /* fill in arp stats req cmd values */
21096 get_arp_stats->vdev_id = req_buf->vdev_id;
21097
21098 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21099 /* Send per roam config parameters */
21100 status = wmi_unified_cmd_send(wmi_handle, buf,
21101 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21102 if (QDF_IS_STATUS_ERROR(status)) {
21103 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21104 status);
21105 goto error;
21106 }
21107
21108 return QDF_STATUS_SUCCESS;
21109error:
21110 wmi_buf_free(buf);
21111
21112 return status;
21113}
21114
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021115/**
21116 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21117 * @wmi_handle: wmi handler
21118 * @pmk_info: pointer to PMK cache entry
21119 * @vdev_id: vdev id
21120 *
21121 * Return: 0 for success and non zero for failure
21122 */
21123static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21124 struct wmi_unified_pmk_cache *pmk_info)
21125{
21126 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21127 wmi_buf_t buf;
21128 QDF_STATUS status;
21129 uint8_t *buf_ptr;
21130 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021131 uint32_t len = sizeof(*cmd);
21132
21133 if (pmk_info->pmk_len)
21134 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021135
21136 buf = wmi_buf_alloc(wmi_handle, len);
21137 if (!buf) {
21138 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21139 __func__);
21140 return QDF_STATUS_E_NOMEM;
21141 }
21142
21143 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21144 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21145
21146 WMITLV_SET_HDR(&cmd->tlv_header,
21147 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21148 WMITLV_GET_STRUCT_TLVLEN(
21149 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21150
21151 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021152
21153 /* If pmk_info->pmk_len is 0, this is a flush request */
21154 if (!pmk_info->pmk_len) {
21155 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21156 cmd->num_cache = 0;
21157 goto send_cmd;
21158 }
21159
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021160 cmd->num_cache = 1;
21161 buf_ptr += sizeof(*cmd);
21162
21163 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21164 sizeof(*pmksa));
21165 buf_ptr += WMI_TLV_HDR_SIZE;
21166
21167 pmksa = (wmi_pmk_cache *)buf_ptr;
21168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21169 WMITLV_GET_STRUCT_TLVLEN
21170 (wmi_pmk_cache));
21171 pmksa->pmk_len = pmk_info->pmk_len;
21172 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21173 pmksa->pmkid_len = pmk_info->pmkid_len;
21174 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21175 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21176 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21177 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21178 pmksa->ssid.ssid_len);
21179 pmksa->cache_id = pmk_info->cache_id;
21180 pmksa->cat_flag = pmk_info->cat_flag;
21181 pmksa->action_flag = pmk_info->action_flag;
21182
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021183send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021184 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21185 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21186 if (status != QDF_STATUS_SUCCESS) {
21187 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21188 __func__, status);
21189 wmi_buf_free(buf);
21190 }
21191
21192 return status;
21193}
21194
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021195/**
21196 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21197 * @wmi_handle: wmi handle
21198 * @param: reserved param
21199 *
21200 * Return: 0 for success or error code
21201 */
21202static QDF_STATUS
21203send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21204 uint32_t param)
21205{
21206 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21207 wmi_buf_t buf;
21208 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21209
21210 buf = wmi_buf_alloc(wmi_handle, len);
21211 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021212 qdf_print("%s:wmi_buf_alloc failed", __func__);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021213 return QDF_STATUS_E_FAILURE;
21214 }
21215 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21216 WMITLV_SET_HDR(&cmd->tlv_header,
21217 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21218 WMITLV_GET_STRUCT_TLVLEN
21219 (wmi_pdev_check_cal_version_cmd_fixed_param));
21220 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21221 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21222 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21223 wmi_buf_free(buf);
21224 return QDF_STATUS_E_FAILURE;
21225 }
21226
21227 return QDF_STATUS_SUCCESS;
21228}
21229
21230/**
21231 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21232 * @wmi_handle: wmi handle
21233 * @param evt_buf: pointer to event buffer
21234 * @param param: Pointer to hold peer caldata version data
21235 *
21236 * Return: 0 for success or error code
21237 */
21238static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21239 wmi_unified_t wmi_handle,
21240 void *evt_buf,
21241 wmi_host_pdev_check_cal_version_event *param)
21242{
21243 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21244 wmi_pdev_check_cal_version_event_fixed_param *event;
21245
21246 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21247 if (!param_tlvs) {
21248 WMI_LOGE("invalid cal version event buf");
21249 return QDF_STATUS_E_FAILURE;
21250 }
21251 event = param_tlvs->fixed_param;
21252 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21253 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21254 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21255 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21256
21257 param->software_cal_version = event->software_cal_version;
21258 param->board_cal_version = event->board_cal_version;
21259 param->cal_ok = event->cal_status;
21260
21261 return QDF_STATUS_SUCCESS;
21262}
21263
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021264/*
21265 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21266 * @wmi_handle: wmi handle
21267 * @params: pointer to wmi_btm_config
21268 *
21269 * Return: QDF_STATUS
21270 */
21271static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21272 struct wmi_btm_config *params)
21273{
21274
21275 wmi_btm_config_fixed_param *cmd;
21276 wmi_buf_t buf;
21277 uint32_t len;
21278
21279 len = sizeof(*cmd);
21280 buf = wmi_buf_alloc(wmi_handle, len);
21281 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021282 qdf_print("%s:wmi_buf_alloc failed", __func__);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021283 return QDF_STATUS_E_NOMEM;
21284 }
21285
21286 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21287 WMITLV_SET_HDR(&cmd->tlv_header,
21288 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21289 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21290 cmd->vdev_id = params->vdev_id;
21291 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021292 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21293 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21294 cmd->stick_time_seconds = params->btm_sticky_time;
21295
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021296 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21297 WMI_ROAM_BTM_CONFIG_CMDID)) {
21298 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21299 __func__);
21300 wmi_buf_free(buf);
21301 return QDF_STATUS_E_FAILURE;
21302 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021303
21304 return QDF_STATUS_SUCCESS;
21305}
21306
21307/**
21308 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21309 * configurations to firmware.
21310 * @wmi_handle: wmi handle
21311 * @obss_cfg_param: obss detection configurations
21312 *
21313 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21314 *
21315 * Return: QDF_STATUS
21316 */
21317static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21318 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21319{
21320 wmi_buf_t buf;
21321 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21322 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21323
21324 buf = wmi_buf_alloc(wmi_handle, len);
21325 if (!buf) {
21326 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21327 return QDF_STATUS_E_NOMEM;
21328 }
21329
21330 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21331 WMITLV_SET_HDR(&cmd->tlv_header,
21332 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21333 WMITLV_GET_STRUCT_TLVLEN
21334 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21335
21336 cmd->vdev_id = obss_cfg_param->vdev_id;
21337 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21338 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21339 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21340 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21341 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21342 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21343 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21344 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021345
21346 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21347 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21348 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21349 wmi_buf_free(buf);
21350 return QDF_STATUS_E_FAILURE;
21351 }
21352
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021353 return QDF_STATUS_SUCCESS;
21354}
21355
Arif Hussain33d98502018-01-12 13:15:04 -080021356/**
21357 * extract_obss_detection_info_tlv() - Extract obss detection info
21358 * received from firmware.
21359 * @evt_buf: pointer to event buffer
21360 * @obss_detection: Pointer to hold obss detection info
21361 *
21362 * Return: QDF_STATUS
21363 */
21364static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21365 struct wmi_obss_detect_info
21366 *obss_detection)
21367{
21368 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21369 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21370
21371 if (!obss_detection) {
21372 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21373 return QDF_STATUS_E_INVAL;
21374 }
21375
21376 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21377 if (!param_buf) {
21378 WMI_LOGE("%s: Invalid evt_buf", __func__);
21379 return QDF_STATUS_E_INVAL;
21380 }
21381
21382 fix_param = param_buf->fixed_param;
21383 obss_detection->vdev_id = fix_param->vdev_id;
21384 obss_detection->matched_detection_masks =
21385 fix_param->matched_detection_masks;
21386 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21387 &obss_detection->matched_bssid_addr[0]);
21388 switch (fix_param->reason) {
21389 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21390 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21391 break;
21392 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21393 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21394 break;
21395 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21396 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21397 break;
21398 default:
21399 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21400 return QDF_STATUS_E_INVAL;
21401 }
21402
21403 return QDF_STATUS_SUCCESS;
21404}
21405
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021406/**
21407 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21408 * @wmi_handle: wmi handler
21409 * @params: pointer to 11k offload params
21410 *
21411 * Return: 0 for success and non zero for failure
21412 */
21413static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21414 struct wmi_11k_offload_params *params)
21415{
21416 wmi_11k_offload_report_fixed_param *cmd;
21417 wmi_buf_t buf;
21418 QDF_STATUS status;
21419 uint8_t *buf_ptr;
21420 wmi_neighbor_report_11k_offload_tlv_param
21421 *neighbor_report_offload_params;
21422 wmi_neighbor_report_offload *neighbor_report_offload;
21423
21424 uint32_t len = sizeof(*cmd);
21425
21426 if (params->offload_11k_bitmask &
21427 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21428 len += WMI_TLV_HDR_SIZE +
21429 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21430
21431 buf = wmi_buf_alloc(wmi_handle, len);
21432 if (!buf) {
21433 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21434 __func__);
21435 return QDF_STATUS_E_NOMEM;
21436 }
21437
21438 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21439 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21440
21441 WMITLV_SET_HDR(&cmd->tlv_header,
21442 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21443 WMITLV_GET_STRUCT_TLVLEN(
21444 wmi_11k_offload_report_fixed_param));
21445
21446 cmd->vdev_id = params->vdev_id;
21447 cmd->offload_11k = params->offload_11k_bitmask;
21448
21449 if (params->offload_11k_bitmask &
21450 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21451 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21452
21453 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21454 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21455 buf_ptr += WMI_TLV_HDR_SIZE;
21456
21457 neighbor_report_offload_params =
21458 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21459 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21460 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21461 WMITLV_GET_STRUCT_TLVLEN(
21462 wmi_neighbor_report_11k_offload_tlv_param));
21463
21464 neighbor_report_offload = &neighbor_report_offload_params->
21465 neighbor_rep_ofld_params;
21466
21467 neighbor_report_offload->time_offset =
21468 params->neighbor_report_params.time_offset;
21469 neighbor_report_offload->low_rssi_offset =
21470 params->neighbor_report_params.low_rssi_offset;
21471 neighbor_report_offload->bmiss_count_trigger =
21472 params->neighbor_report_params.bmiss_count_trigger;
21473 neighbor_report_offload->per_threshold_offset =
21474 params->neighbor_report_params.per_threshold_offset;
21475 neighbor_report_offload->neighbor_report_cache_timeout =
21476 params->neighbor_report_params.
21477 neighbor_report_cache_timeout;
21478 neighbor_report_offload->max_neighbor_report_req_cap =
21479 params->neighbor_report_params.
21480 max_neighbor_report_req_cap;
21481 neighbor_report_offload->ssid.ssid_len =
21482 params->neighbor_report_params.ssid.length;
21483 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21484 &params->neighbor_report_params.ssid.mac_ssid,
21485 neighbor_report_offload->ssid.ssid_len);
21486 }
21487
21488 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21489 WMI_11K_OFFLOAD_REPORT_CMDID);
21490 if (status != QDF_STATUS_SUCCESS) {
21491 WMI_LOGE("%s: failed to send 11k offload command %d",
21492 __func__, status);
21493 wmi_buf_free(buf);
21494 }
21495
21496 return status;
21497}
21498
21499/**
21500 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21501 * command
21502 * @wmi_handle: wmi handler
21503 * @params: pointer to neighbor report invoke params
21504 *
21505 * Return: 0 for success and non zero for failure
21506 */
21507static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21508 struct wmi_invoke_neighbor_report_params *params)
21509{
21510 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21511 wmi_buf_t buf;
21512 QDF_STATUS status;
21513 uint8_t *buf_ptr;
21514 uint32_t len = sizeof(*cmd);
21515
21516 buf = wmi_buf_alloc(wmi_handle, len);
21517 if (!buf) {
21518 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21519 __func__);
21520 return QDF_STATUS_E_NOMEM;
21521 }
21522
21523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21524 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21525
21526 WMITLV_SET_HDR(&cmd->tlv_header,
21527 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21528 WMITLV_GET_STRUCT_TLVLEN(
21529 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21530
21531 cmd->vdev_id = params->vdev_id;
21532 cmd->flags = params->send_resp_to_host;
21533
21534 cmd->ssid.ssid_len = params->ssid.length;
21535 qdf_mem_copy(cmd->ssid.ssid,
21536 &params->ssid.mac_ssid,
21537 cmd->ssid.ssid_len);
21538
21539 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21540 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21541 if (status != QDF_STATUS_SUCCESS) {
21542 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21543 __func__, status);
21544 wmi_buf_free(buf);
21545 }
21546
21547 return status;
21548}
21549
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021550#ifdef WLAN_SUPPORT_GREEN_AP
21551static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21552 uint8_t *evt_buf,
21553 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21554{
21555 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21556 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21557 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21558
21559 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21560 if (!param_buf) {
21561 WMI_LOGE("Invalid EGAP Info status event buffer");
21562 return QDF_STATUS_E_INVAL;
21563 }
21564
21565 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21566 param_buf->fixed_param;
21567 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21568 param_buf->chainmask_list;
21569
21570 egap_status_info_params->status = egap_info_event->status;
21571 egap_status_info_params->mac_id = chainmask_event->mac_id;
21572 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21573 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21574
21575 return QDF_STATUS_SUCCESS;
21576}
21577#endif
21578
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021579/*
21580 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21581 * updating bss color change within firmware when AP announces bss color change.
21582 * @wmi_handle: wmi handle
21583 * @vdev_id: vdev ID
21584 * @enable: enable bss color change within firmware
21585 *
21586 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21587 *
21588 * Return: QDF_STATUS
21589 */
21590static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21591 uint32_t vdev_id,
21592 bool enable)
21593{
21594 wmi_buf_t buf;
21595 wmi_bss_color_change_enable_fixed_param *cmd;
21596 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21597
21598 buf = wmi_buf_alloc(wmi_handle, len);
21599 if (!buf) {
21600 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21601 return QDF_STATUS_E_NOMEM;
21602 }
21603
21604 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21605 WMITLV_SET_HDR(&cmd->tlv_header,
21606 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21607 WMITLV_GET_STRUCT_TLVLEN
21608 (wmi_bss_color_change_enable_fixed_param));
21609 cmd->vdev_id = vdev_id;
21610 cmd->enable = enable;
21611 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21612 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21613 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21614 wmi_buf_free(buf);
21615 return QDF_STATUS_E_FAILURE;
21616 }
21617
21618 return QDF_STATUS_SUCCESS;
21619}
21620
21621/**
21622 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21623 * configurations to firmware.
21624 * @wmi_handle: wmi handle
21625 * @cfg_param: obss detection configurations
21626 *
21627 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21628 *
21629 * Return: QDF_STATUS
21630 */
21631static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21632 wmi_unified_t wmi_handle,
21633 struct wmi_obss_color_collision_cfg_param *cfg_param)
21634{
21635 wmi_buf_t buf;
21636 wmi_obss_color_collision_det_config_fixed_param *cmd;
21637 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21638
21639 buf = wmi_buf_alloc(wmi_handle, len);
21640 if (!buf) {
21641 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21642 return QDF_STATUS_E_NOMEM;
21643 }
21644
21645 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21646 buf);
21647 WMITLV_SET_HDR(&cmd->tlv_header,
21648 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21649 WMITLV_GET_STRUCT_TLVLEN
21650 (wmi_obss_color_collision_det_config_fixed_param));
21651 cmd->vdev_id = cfg_param->vdev_id;
21652 cmd->flags = cfg_param->flags;
21653 cmd->current_bss_color = cfg_param->current_bss_color;
21654 cmd->detection_period_ms = cfg_param->detection_period_ms;
21655 cmd->scan_period_ms = cfg_param->scan_period_ms;
21656 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21657
21658 switch (cfg_param->evt_type) {
21659 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21660 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21661 break;
21662 case OBSS_COLOR_COLLISION_DETECTION:
21663 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21664 break;
21665 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21666 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21667 break;
21668 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21669 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21670 break;
21671 default:
21672 WMI_LOGE("%s: invalid event type: %d",
21673 __func__, cfg_param->evt_type);
21674 wmi_buf_free(buf);
21675 return QDF_STATUS_E_FAILURE;
21676 }
21677
21678 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21679 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21680 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21681 __func__, cfg_param->vdev_id);
21682 wmi_buf_free(buf);
21683 return QDF_STATUS_E_FAILURE;
21684 }
21685
21686 return QDF_STATUS_SUCCESS;
21687}
21688
21689/**
21690 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21691 * received from firmware.
21692 * @evt_buf: pointer to event buffer
21693 * @info: Pointer to hold bss collision info
21694 *
21695 * Return: QDF_STATUS
21696 */
21697static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21698 struct wmi_obss_color_collision_info *info)
21699{
21700 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21701 wmi_obss_color_collision_evt_fixed_param *fix_param;
21702
21703 if (!info) {
21704 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21705 return QDF_STATUS_E_INVAL;
21706 }
21707
21708 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21709 evt_buf;
21710 if (!param_buf) {
21711 WMI_LOGE("%s: Invalid evt_buf", __func__);
21712 return QDF_STATUS_E_INVAL;
21713 }
21714
21715 fix_param = param_buf->fixed_param;
21716 info->vdev_id = fix_param->vdev_id;
21717 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21718 info->obss_color_bitmap_bit32to63 =
21719 fix_param->bss_color_bitmap_bit32to63;
21720
21721 switch (fix_param->evt_type) {
21722 case WMI_BSS_COLOR_COLLISION_DISABLE:
21723 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21724 break;
21725 case WMI_BSS_COLOR_COLLISION_DETECTION:
21726 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21727 break;
21728 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21729 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21730 break;
21731 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21732 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21733 break;
21734 default:
21735 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21736 __func__, fix_param->evt_type, fix_param->vdev_id);
21737 return QDF_STATUS_E_FAILURE;
21738 }
21739
21740 return QDF_STATUS_SUCCESS;
21741}
21742
Arif Hussaine0eb7302018-03-01 14:40:59 -080021743/*
21744 * extract_comb_phyerr_tlv() - extract comb phy error from event
21745 * @wmi_handle: wmi handle
21746 * @evt_buf: pointer to event buffer
21747 * @datalen: data length of event buffer
21748 * @buf_offset: Pointer to hold value of current event buffer offset
21749 * post extraction
21750 * @phyerr: Pointer to hold phyerr
21751 *
21752 * Return: QDF_STATUS
21753 */
21754static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21755 void *evt_buf,
21756 uint16_t datalen,
21757 uint16_t *buf_offset,
21758 wmi_host_phyerr_t *phyerr)
21759{
21760 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21761 wmi_comb_phyerr_rx_hdr *pe_hdr;
21762
21763 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21764 if (!param_tlvs) {
21765 WMI_LOGD("%s: Received null data from FW", __func__);
21766 return QDF_STATUS_E_FAILURE;
21767 }
21768
21769 pe_hdr = param_tlvs->hdr;
21770 if (!pe_hdr) {
21771 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21772 return QDF_STATUS_E_FAILURE;
21773 }
21774
21775 /* Ensure it's at least the size of the header */
21776 if (datalen < sizeof(*pe_hdr)) {
21777 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21778 __func__, sizeof(*pe_hdr), datalen);
21779 return QDF_STATUS_E_FAILURE;
21780 }
21781
21782 phyerr->pdev_id = wmi_handle->ops->
21783 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21784 phyerr->tsf64 = pe_hdr->tsf_l32;
21785 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21786 phyerr->bufp = param_tlvs->bufp;
21787 phyerr->buf_len = pe_hdr->buf_len;
21788 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21789 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21790 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21791
21792 return QDF_STATUS_SUCCESS;
21793}
21794
21795/**
21796 * extract_single_phyerr_tlv() - extract single phy error from event
21797 * @wmi_handle: wmi handle
21798 * @evt_buf: pointer to event buffer
21799 * @datalen: data length of event buffer
21800 * @buf_offset: Pointer to hold value of current event buffer offset
21801 * post extraction
21802 * @phyerr: Pointer to hold phyerr
21803 *
21804 * Return: QDF_STATUS
21805 */
21806static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21807 void *evt_buf,
21808 uint16_t datalen,
21809 uint16_t *buf_offset,
21810 wmi_host_phyerr_t *phyerr)
21811{
21812 wmi_single_phyerr_rx_event *ev;
21813 uint16_t n = *buf_offset;
21814 uint8_t *data = (uint8_t *)evt_buf;
21815
21816 if (n < datalen) {
21817 if ((datalen - n) < sizeof(ev->hdr)) {
21818 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21819 __func__, datalen, n, sizeof(ev->hdr));
21820 return QDF_STATUS_E_FAILURE;
21821 }
21822
21823 /*
21824 * Obtain a pointer to the beginning of the current event.
21825 * data[0] is the beginning of the WMI payload.
21826 */
21827 ev = (wmi_single_phyerr_rx_event *)&data[n];
21828
21829 /*
21830 * Sanity check the buffer length of the event against
21831 * what we currently have.
21832 *
21833 * Since buf_len is 32 bits, we check if it overflows
21834 * a large 32 bit value. It's not 0x7fffffff because
21835 * we increase n by (buf_len + sizeof(hdr)), which would
21836 * in itself cause n to overflow.
21837 *
21838 * If "int" is 64 bits then this becomes a moot point.
21839 */
21840 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21841 WMI_LOGD("%s: buf_len is garbage 0x%x",
21842 __func__, ev->hdr.buf_len);
21843 return QDF_STATUS_E_FAILURE;
21844 }
21845
21846 if ((n + ev->hdr.buf_len) > datalen) {
21847 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21848 __func__, n, ev->hdr.buf_len, datalen);
21849 return QDF_STATUS_E_FAILURE;
21850 }
21851
21852 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21853 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21854 phyerr->bufp = &ev->bufp[0];
21855 phyerr->buf_len = ev->hdr.buf_len;
21856 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21857
21858 /*
21859 * Advance the buffer pointer to the next PHY error.
21860 * buflen is the length of this payload, so we need to
21861 * advance past the current header _AND_ the payload.
21862 */
21863 n += sizeof(*ev) + ev->hdr.buf_len;
21864 }
21865 *buf_offset = n;
21866
21867 return QDF_STATUS_SUCCESS;
21868}
21869
Subrat Mishraa667b1c2018-08-02 15:02:04 +053021870/**
21871 * extract_esp_estimation_ev_param_tlv() - extract air time from event
21872 * @wmi_handle: wmi handle
21873 * @evt_buf: pointer to event buffer
21874 * @param: Pointer to hold esp event
21875 *
21876 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
21877 */
21878static QDF_STATUS
21879extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
21880 void *evt_buf,
21881 struct esp_estimation_event *param)
21882{
21883 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
21884 wmi_esp_estimate_event_fixed_param *esp_event;
21885
21886 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
21887 if (!param_buf) {
21888 WMI_LOGE("Invalid ESP Estimate Event buffer");
21889 return QDF_STATUS_E_INVAL;
21890 }
21891 esp_event = param_buf->fixed_param;
21892 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
21893 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
21894 esp_event->pdev_id);
21895
21896 return QDF_STATUS_SUCCESS;
21897}
21898
Govind Singh5eb51532016-03-09 11:34:12 +053021899struct wmi_ops tlv_ops = {
21900 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21901 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21902 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021903 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21904 .send_hidden_ssid_vdev_restart_cmd =
21905 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021906 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21907 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21908 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021909 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021910 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021911 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021912 .send_peer_rx_reorder_queue_setup_cmd =
21913 send_peer_rx_reorder_queue_setup_cmd_tlv,
21914 .send_peer_rx_reorder_queue_remove_cmd =
21915 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021916 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21917 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21918 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021919 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21920 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021921 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021922 .send_suspend_cmd = send_suspend_cmd_tlv,
21923 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021924#ifdef FEATURE_WLAN_D0WOW
21925 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21926 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21927#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021928 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21929 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21930 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21931 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021932#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021933 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021934#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021935 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21936 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21937 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021938 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021939 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021940 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021941 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021942 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21943 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21944 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21945 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021946 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021947 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021948 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21949 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021950 .send_set_sta_uapsd_auto_trig_cmd =
21951 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021952 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21953 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21954 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021955#ifdef CONVERGED_P2P_ENABLE
21956 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21957 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21958#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021959 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21960 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021961#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021962 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21963 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21964 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21965 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21966 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21967 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21968 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021969 .send_ocb_start_timing_advert_cmd =
21970 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021971 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21972 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21973 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21974 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21975#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021976 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21977 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21978 .send_set_mcc_channel_time_latency_cmd =
21979 send_set_mcc_channel_time_latency_cmd_tlv,
21980 .send_set_mcc_channel_time_quota_cmd =
21981 send_set_mcc_channel_time_quota_cmd_tlv,
21982 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21983 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021984 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021985 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21986 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21987 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021988 .send_probe_rsp_tmpl_send_cmd =
21989 send_probe_rsp_tmpl_send_cmd_tlv,
21990 .send_p2p_go_set_beacon_ie_cmd =
21991 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021992 .send_setup_install_key_cmd =
21993 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021994 .send_set_gateway_params_cmd =
21995 send_set_gateway_params_cmd_tlv,
21996 .send_set_rssi_monitoring_cmd =
21997 send_set_rssi_monitoring_cmd_tlv,
21998 .send_scan_probe_setoui_cmd =
21999 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022000 .send_roam_scan_offload_rssi_thresh_cmd =
22001 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022002 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022003 .send_roam_scan_filter_cmd =
22004 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022005#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022006 .send_ipa_offload_control_cmd =
22007 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022008#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022009 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22010 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22011 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22012 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022013 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022014 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022015#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053022016 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22017 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22018 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022019#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022020 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022021 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22022 .send_snr_cmd = send_snr_cmd_tlv,
22023 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022024#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022025 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22026 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22027 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22028 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022029 .send_multiple_add_clear_mcbc_filter_cmd =
22030 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022031 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022032 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22033 .send_process_gtk_offload_getinfo_cmd =
22034 send_process_gtk_offload_getinfo_cmd_tlv,
22035 .send_enable_enhance_multicast_offload_cmd =
22036 send_enable_enhance_multicast_offload_tlv,
22037 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22038#ifdef FEATURE_WLAN_RA_FILTERING
22039 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22040#endif
22041 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022042 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22043 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022044 .send_lphb_config_tcp_pkt_filter_cmd =
22045 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022046 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22047 .send_lphb_config_udp_pkt_filter_cmd =
22048 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022049 .send_enable_disable_packet_filter_cmd =
22050 send_enable_disable_packet_filter_cmd_tlv,
22051 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022052#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022053#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022054 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22055 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022056 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022057 .send_roam_scan_offload_mode_cmd =
22058 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022059#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053022060 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022061#endif
Govind Singh87542482016-06-08 19:40:11 +053022062 .send_roam_scan_offload_ap_profile_cmd =
22063 send_roam_scan_offload_ap_profile_cmd_tlv,
22064#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022065#ifdef WLAN_SUPPORT_GREEN_AP
22066 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22067 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022068 .extract_green_ap_egap_status_info =
22069 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022070#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022071 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22072 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022073 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022074 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022075 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022076#ifdef WLAN_FEATURE_CIF_CFR
22077 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22078#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022079 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022080 .send_dfs_phyerr_filter_offload_en_cmd =
22081 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022082 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22083 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22084 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22085 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22086 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022087 .send_process_add_periodic_tx_ptrn_cmd =
22088 send_process_add_periodic_tx_ptrn_cmd_tlv,
22089 .send_process_del_periodic_tx_ptrn_cmd =
22090 send_process_del_periodic_tx_ptrn_cmd_tlv,
22091 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22092 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22093 .send_set_app_type2_params_in_fw_cmd =
22094 send_set_app_type2_params_in_fw_cmd_tlv,
22095 .send_set_auto_shutdown_timer_cmd =
22096 send_set_auto_shutdown_timer_cmd_tlv,
22097 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22098 .send_process_dhcpserver_offload_cmd =
22099 send_process_dhcpserver_offload_cmd_tlv,
22100 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22101 .send_process_ch_avoid_update_cmd =
22102 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022103 .send_pdev_set_regdomain_cmd =
22104 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022105 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22106 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22107 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22108 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022109 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022110 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022111 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022112 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022113 .send_set_base_macaddr_indicate_cmd =
22114 send_set_base_macaddr_indicate_cmd_tlv,
22115 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22116 .send_enable_specific_fw_logs_cmd =
22117 send_enable_specific_fw_logs_cmd_tlv,
22118 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022119 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022120 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022121#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022122 .send_pdev_set_dual_mac_config_cmd =
22123 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022124#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022125 .send_app_type1_params_in_fw_cmd =
22126 send_app_type1_params_in_fw_cmd_tlv,
22127 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22128 .send_process_roam_synch_complete_cmd =
22129 send_process_roam_synch_complete_cmd_tlv,
22130 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22131 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22132 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022133 .send_roam_scan_offload_scan_period_cmd =
22134 send_roam_scan_offload_scan_period_cmd_tlv,
22135 .send_roam_scan_offload_chan_list_cmd =
22136 send_roam_scan_offload_chan_list_cmd_tlv,
22137 .send_roam_scan_offload_rssi_change_cmd =
22138 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022139#ifdef FEATURE_WLAN_APF
22140 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22141 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22142 .send_apf_write_work_memory_cmd =
22143 wmi_send_apf_write_work_memory_cmd_tlv,
22144 .send_apf_read_work_memory_cmd =
22145 wmi_send_apf_read_work_memory_cmd_tlv,
22146 .extract_apf_read_memory_resp_event =
22147 wmi_extract_apf_read_memory_resp_event_tlv,
22148#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022149 .send_adapt_dwelltime_params_cmd =
22150 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022151 .send_dbs_scan_sel_params_cmd =
22152 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022153 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022154 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22155 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22156 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22157 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22158 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22159 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022160 .send_vdev_set_custom_aggr_size_cmd =
22161 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022162 .send_vdev_set_qdepth_thresh_cmd =
22163 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022164 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22165 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22166 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022167 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22168 .send_smart_ant_set_training_info_cmd =
22169 send_smart_ant_set_training_info_cmd_tlv,
22170 .send_smart_ant_set_node_config_cmd =
22171 send_smart_ant_set_node_config_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022172#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053022173 .send_set_atf_cmd = send_set_atf_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022174#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053022175 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22176 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022177 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22178 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22179 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22180 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022181 .send_periodic_chan_stats_config_cmd =
22182 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022183 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22184 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22185 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022186 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22187 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22188 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22189 .send_vdev_spectral_configure_cmd =
22190 send_vdev_spectral_configure_cmd_tlv,
22191 .send_vdev_spectral_enable_cmd =
22192 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022193 .send_thermal_mitigation_param_cmd =
22194 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022195 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22196 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022197 .send_process_update_edca_param_cmd =
22198 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022199 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022200 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022201 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022202 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22203 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022204 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022205 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22206 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22207 .extract_host_mem_req = extract_host_mem_req_tlv,
22208 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022209 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022210 .is_service_enabled = is_service_enabled_tlv,
22211 .save_fw_version = save_fw_version_in_service_ready_tlv,
22212 .ready_extract_init_status = ready_extract_init_status_tlv,
22213 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022214 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022215 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022216 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22217 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022218 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022219 .extract_tbttoffset_update_params =
22220 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022221 .extract_ext_tbttoffset_update_params =
22222 extract_ext_tbttoffset_update_params_tlv,
22223 .extract_tbttoffset_num_vdevs =
22224 extract_tbttoffset_num_vdevs_tlv,
22225 .extract_ext_tbttoffset_num_vdevs =
22226 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022227 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22228 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22229 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22230 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022231#ifdef CONVERGED_TDLS_ENABLE
22232 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22233#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022234 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022235 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022236 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22237 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022238#ifdef CONVERGED_P2P_ENABLE
22239 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22240 .extract_p2p_lo_stop_ev_param =
22241 extract_p2p_lo_stop_ev_param_tlv,
22242#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022243 .extract_offchan_data_tx_compl_param =
22244 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022245 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22246 .extract_all_stats_count = extract_all_stats_counts_tlv,
22247 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022248 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022249 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22250 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022251 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022252 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022253 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022254 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22255 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22256 .extract_chan_stats = extract_chan_stats_tlv,
22257 .extract_profile_ctx = extract_profile_ctx_tlv,
22258 .extract_profile_data = extract_profile_data_tlv,
22259 .extract_chan_info_event = extract_chan_info_event_tlv,
22260 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022261 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022262#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022263 .send_encrypt_decrypt_send_cmd =
22264 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022265 .extract_encrypt_decrypt_resp_event =
22266 extract_encrypt_decrypt_resp_event_tlv,
22267#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022268 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022269 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22270 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022271 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022272 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022273 .send_multiple_vdev_restart_req_cmd =
22274 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022275 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22276 .extract_hw_mode_cap_service_ready_ext =
22277 extract_hw_mode_cap_service_ready_ext_tlv,
22278 .extract_mac_phy_cap_service_ready_ext =
22279 extract_mac_phy_cap_service_ready_ext_tlv,
22280 .extract_reg_cap_service_ready_ext =
22281 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022282 .extract_dbr_ring_cap_service_ready_ext =
22283 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022284 .extract_sar_cap_service_ready_ext =
22285 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022286 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22287 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022288 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022289 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022290 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022291 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22292 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22293 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022294 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022295 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022296 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022297 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022298 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022299 .extract_pdev_csa_switch_count_status =
22300 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022301 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022302 .extract_pdev_tpc_config_ev_param =
22303 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022304 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022305 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22306 .extract_peer_sta_ps_statechange_ev =
22307 extract_peer_sta_ps_statechange_ev_tlv,
22308 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022309 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022310#ifdef WLAN_FEATURE_ACTION_OUI
22311 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22312#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022313 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22314 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022315 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022316 extract_reg_chan_list_update_event_tlv,
22317 .extract_chainmask_tables =
22318 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022319 .extract_thermal_stats = extract_thermal_stats_tlv,
22320 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022321 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22322 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022323#ifdef DFS_COMPONENT_ENABLE
22324 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22325 .extract_dfs_radar_detection_event =
22326 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022327 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022328#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022329 .convert_pdev_id_host_to_target =
22330 convert_host_pdev_id_to_target_pdev_id_legacy,
22331 .convert_pdev_id_target_to_host =
22332 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022333
22334 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22335 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22336 .extract_reg_11d_new_country_event =
22337 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022338 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022339 .send_limit_off_chan_cmd =
22340 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022341 .extract_reg_ch_avoid_event =
22342 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022343 .send_pdev_caldata_version_check_cmd =
22344 send_pdev_caldata_version_check_cmd_tlv,
22345 .extract_pdev_caldata_version_check_ev_param =
22346 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022347 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22348 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022349 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22350#if defined(WLAN_FEATURE_FILS_SK)
22351 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22352#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022353 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022354#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22355 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22356 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22357 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22358 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22359 .extract_ndp_ind = extract_ndp_ind_tlv,
22360 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22361 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22362 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22363 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022364 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022365#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022366 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022367 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022368 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022369#ifdef WLAN_SUPPORT_FILS
22370 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22371 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22372 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22373#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022374 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22375 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022376 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22377 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22378 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22379 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022380 .send_bss_color_change_enable_cmd =
22381 send_bss_color_change_enable_cmd_tlv,
22382 .send_obss_color_collision_cfg_cmd =
22383 send_obss_color_collision_cfg_cmd_tlv,
22384 .extract_obss_color_collision_info =
22385 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022386 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22387 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022388#ifdef QCA_SUPPORT_CP_STATS
22389 .extract_cca_stats = extract_cca_stats_tlv,
22390#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022391 .extract_esp_estimation_ev_param =
22392 extract_esp_estimation_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022393};
22394
Govind Singhe7f2f342016-05-23 12:12:52 +053022395/**
22396 * populate_tlv_event_id() - populates wmi event ids
22397 *
22398 * @param event_ids: Pointer to hold event ids
22399 * Return: None
22400 */
22401static void populate_tlv_events_id(uint32_t *event_ids)
22402{
22403 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22404 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22405 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22406 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22407 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22408 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22409 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22410 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22411 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22412 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22413 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22414 event_ids[wmi_service_ready_ext_event_id] =
22415 WMI_SERVICE_READY_EXT_EVENTID;
22416 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22417 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22418 event_ids[wmi_vdev_install_key_complete_event_id] =
22419 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22420 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22421 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22422
22423 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22424 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22425 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22426 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22427 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22428 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22429 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22430 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022431 event_ids[wmi_peer_delete_response_event_id] =
22432 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022433 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22434 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22435 event_ids[wmi_tbttoffset_update_event_id] =
22436 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022437 event_ids[wmi_ext_tbttoffset_update_event_id] =
22438 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022439 event_ids[wmi_offload_bcn_tx_status_event_id] =
22440 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22441 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22442 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22443 event_ids[wmi_mgmt_tx_completion_event_id] =
22444 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022445 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22446 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022447 event_ids[wmi_tx_delba_complete_event_id] =
22448 WMI_TX_DELBA_COMPLETE_EVENTID;
22449 event_ids[wmi_tx_addba_complete_event_id] =
22450 WMI_TX_ADDBA_COMPLETE_EVENTID;
22451 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22452
22453 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22454
22455 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22456 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22457
22458 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022459 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022460
22461 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22462
22463 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022464 event_ids[wmi_p2p_lo_stop_event_id] =
22465 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022466 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22467 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022468 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022469 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22470 event_ids[wmi_wow_initial_wakeup_event_id] =
22471 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22472
22473 event_ids[wmi_rtt_meas_report_event_id] =
22474 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22475 event_ids[wmi_tsf_meas_report_event_id] =
22476 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22477 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22478 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22479 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22480 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22481 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022482 event_ids[wmi_diag_event_id_log_supported_event_id] =
22483 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22484 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22485 event_ids[wmi_nlo_scan_complete_event_id] =
22486 WMI_NLO_SCAN_COMPLETE_EVENTID;
22487 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22488 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22489
22490 event_ids[wmi_gtk_offload_status_event_id] =
22491 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22492 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22493 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22494 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22495
22496 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22497
22498 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22499
22500 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22501 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22502 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22503 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22504 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22505 event_ids[wmi_wlan_profile_data_event_id] =
22506 WMI_WLAN_PROFILE_DATA_EVENTID;
22507 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22508 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22509 event_ids[wmi_vdev_get_keepalive_event_id] =
22510 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22511 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22512
22513 event_ids[wmi_diag_container_event_id] =
22514 WMI_DIAG_DATA_CONTAINER_EVENTID;
22515
22516 event_ids[wmi_host_auto_shutdown_event_id] =
22517 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22518
22519 event_ids[wmi_update_whal_mib_stats_event_id] =
22520 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22521
22522 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22523 event_ids[wmi_update_vdev_rate_stats_event_id] =
22524 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22525
22526 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022527 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022528
22529 /** Set OCB Sched Response, deprecated */
22530 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22531
22532 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22533 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22534 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22535
22536 /* GPIO Event */
22537 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22538 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22539
22540 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22541 event_ids[wmi_rfkill_state_change_event_id] =
22542 WMI_RFKILL_STATE_CHANGE_EVENTID;
22543
22544 /* TDLS Event */
22545 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22546
22547 event_ids[wmi_batch_scan_enabled_event_id] =
22548 WMI_BATCH_SCAN_ENABLED_EVENTID;
22549 event_ids[wmi_batch_scan_result_event_id] =
22550 WMI_BATCH_SCAN_RESULT_EVENTID;
22551 /* OEM Event */
22552 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22553 event_ids[wmi_oem_meas_report_event_id] =
22554 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22555 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22556
22557 /* NAN Event */
22558 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22559
22560 /* LPI Event */
22561 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22562 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22563 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22564
22565 /* ExtScan events */
22566 event_ids[wmi_extscan_start_stop_event_id] =
22567 WMI_EXTSCAN_START_STOP_EVENTID;
22568 event_ids[wmi_extscan_operation_event_id] =
22569 WMI_EXTSCAN_OPERATION_EVENTID;
22570 event_ids[wmi_extscan_table_usage_event_id] =
22571 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22572 event_ids[wmi_extscan_cached_results_event_id] =
22573 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22574 event_ids[wmi_extscan_wlan_change_results_event_id] =
22575 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22576 event_ids[wmi_extscan_hotlist_match_event_id] =
22577 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22578 event_ids[wmi_extscan_capabilities_event_id] =
22579 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22580 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22581 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22582
22583 /* mDNS offload events */
22584 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22585
22586 /* SAP Authentication offload events */
22587 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22588 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22589
22590 /** Out-of-context-of-bss (OCB) events */
22591 event_ids[wmi_ocb_set_config_resp_event_id] =
22592 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22593 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22594 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22595 event_ids[wmi_dcc_get_stats_resp_event_id] =
22596 WMI_DCC_GET_STATS_RESP_EVENTID;
22597 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22598 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22599 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22600 /* System-On-Chip events */
22601 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22602 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22603 event_ids[wmi_soc_hw_mode_transition_event_id] =
22604 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22605 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22606 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022607 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022608 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22609 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022610 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022611 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22612 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22613 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22614 WMI_PEER_STA_PS_STATECHG_EVENTID;
22615 event_ids[wmi_pdev_channel_hopping_event_id] =
22616 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022617 event_ids[wmi_offchan_data_tx_completion_event] =
22618 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022619 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22620 event_ids[wmi_dfs_radar_detection_event_id] =
22621 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022622 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022623 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022624 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022625 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022626 event_ids[wmi_service_available_event_id] =
22627 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022628 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022629 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022630 /* NDP events */
22631 event_ids[wmi_ndp_initiator_rsp_event_id] =
22632 WMI_NDP_INITIATOR_RSP_EVENTID;
22633 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22634 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22635 event_ids[wmi_ndp_responder_rsp_event_id] =
22636 WMI_NDP_RESPONDER_RSP_EVENTID;
22637 event_ids[wmi_ndp_end_indication_event_id] =
22638 WMI_NDP_END_INDICATION_EVENTID;
22639 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022640 event_ids[wmi_ndl_schedule_update_event_id] =
22641 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022642
22643 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22644 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22645 event_ids[wmi_pdev_chip_power_stats_event_id] =
22646 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22647 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22648 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22649 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022650 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022651 WMI_BPF_CAPABILIY_INFO_EVENTID;
22652 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22653 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22654 event_ids[wmi_report_rx_aggr_failure_event_id] =
22655 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22656 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22657 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22658 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22659 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22660 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22661 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22662 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22663 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22664 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22665 event_ids[wmi_coex_bt_activity_event_id] =
22666 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22667 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22668 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22669 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22670 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22671 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022672 event_ids[wmi_dma_buf_release_event_id] =
22673 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022674 event_ids[wmi_sap_obss_detection_report_event_id] =
22675 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022676 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022677 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022678 event_ids[wmi_obss_color_collision_report_event_id] =
22679 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022680 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22681 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022682 event_ids[wmi_twt_enable_complete_event_id] =
22683 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022684 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22685 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022686 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022687 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022688}
22689
Soumya Bhat488092d2017-03-22 14:41:01 +053022690/**
22691 * populate_tlv_service() - populates wmi services
22692 *
22693 * @param wmi_service: Pointer to hold wmi_service
22694 * Return: None
22695 */
22696static void populate_tlv_service(uint32_t *wmi_service)
22697{
22698 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022699 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022700 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22701 wmi_service[wmi_service_roam_scan_offload] =
22702 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22703 wmi_service[wmi_service_bcn_miss_offload] =
22704 WMI_SERVICE_BCN_MISS_OFFLOAD;
22705 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22706 wmi_service[wmi_service_sta_advanced_pwrsave] =
22707 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22708 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22709 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22710 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22711 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22712 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22713 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22714 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22715 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22716 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22717 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22718 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22719 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22720 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22721 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22722 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22723 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22724 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22725 wmi_service[wmi_service_packet_power_save] =
22726 WMI_SERVICE_PACKET_POWER_SAVE;
22727 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22728 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22729 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22730 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22731 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22732 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22733 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22734 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22735 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22736 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22737 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22738 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22739 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22740 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22741 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22742 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22743 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22744 wmi_service[wmi_service_mcc_bcn_interval_change] =
22745 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22746 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22747 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22748 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22749 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22750 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22751 wmi_service[wmi_service_lte_ant_share_support] =
22752 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22753 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22754 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22755 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22756 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22757 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22758 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22759 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22760 wmi_service[wmi_service_bcn_txrate_override] =
22761 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22762 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22763 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22764 wmi_service[wmi_service_estimate_linkspeed] =
22765 WMI_SERVICE_ESTIMATE_LINKSPEED;
22766 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22767 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22768 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22769 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22770 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22771 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22772 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22773 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22774 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22775 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22776 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22777 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22778 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22779 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22780 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22781 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22782 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22783 wmi_service[wmi_service_sap_auth_offload] =
22784 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22785 wmi_service[wmi_service_dual_band_simultaneous_support] =
22786 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22787 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22788 wmi_service[wmi_service_ap_arpns_offload] =
22789 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22790 wmi_service[wmi_service_per_band_chainmask_support] =
22791 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22792 wmi_service[wmi_service_packet_filter_offload] =
22793 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22794 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22795 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22796 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22797 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22798 wmi_service[wmi_service_multiple_vdev_restart] =
22799 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22800
22801 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22802 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22803 wmi_service[wmi_service_smart_antenna_sw_support] =
22804 WMI_SERVICE_UNAVAILABLE;
22805 wmi_service[wmi_service_smart_antenna_hw_support] =
22806 WMI_SERVICE_UNAVAILABLE;
22807 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022808 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022809 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022810 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22811 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22812 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22813 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22814 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22815 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22816 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22817 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022818 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22819 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22820 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022821 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022822 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22823 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22824 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22825 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22826 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22827 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022828 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22829 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22830 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22831 wmi_service[wmi_service_unified_wow_capability] =
22832 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22833 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022834 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022835 wmi_service[wmi_service_sync_delete_cmds] =
22836 WMI_SERVICE_SYNC_DELETE_CMDS;
22837 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22838 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22839 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22840 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22841 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22842 wmi_service[wmi_service_deprecated_replace] =
22843 WMI_SERVICE_DEPRECATED_REPLACE;
22844 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22845 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22846 wmi_service[wmi_service_enhanced_mcast_filter] =
22847 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22848 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22849 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22850 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22851 wmi_service[wmi_service_p2p_listen_offload_support] =
22852 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22853 wmi_service[wmi_service_mark_first_wakeup_packet] =
22854 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22855 wmi_service[wmi_service_multiple_mcast_filter_set] =
22856 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22857 wmi_service[wmi_service_host_managed_rx_reorder] =
22858 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22859 wmi_service[wmi_service_flash_rdwr_support] =
22860 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22861 wmi_service[wmi_service_wlan_stats_report] =
22862 WMI_SERVICE_WLAN_STATS_REPORT;
22863 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22864 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22865 wmi_service[wmi_service_dfs_phyerr_offload] =
22866 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22867 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22868 wmi_service[wmi_service_fw_mem_dump_support] =
22869 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22870 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22871 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22872 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22873 wmi_service[wmi_service_hw_data_filtering] =
22874 WMI_SERVICE_HW_DATA_FILTERING;
22875 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22876 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022877 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022878 wmi_service[wmi_service_extended_nss_support] =
22879 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022880 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022881 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22882 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022883 wmi_service[wmi_service_offchan_data_tid_support] =
22884 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022885 wmi_service[wmi_service_support_dma] =
22886 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022887 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22888 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22889 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022890 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22891 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022892 wmi_service[wmi_service_11k_neighbour_report_support] =
22893 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022894 wmi_service[wmi_service_ap_obss_detection_offload] =
22895 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22896 wmi_service[wmi_service_bss_color_offload] =
22897 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022898 wmi_service[wmi_service_gmac_offload_support] =
22899 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022900 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22901 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22902 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22903 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022904 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22905 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022906 wmi_service[wmi_service_listen_interval_offload_support] =
22907 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022908
Soumya Bhat488092d2017-03-22 14:41:01 +053022909}
22910
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022911#ifndef CONFIG_MCL
22912
Govind Singhe7f2f342016-05-23 12:12:52 +053022913/**
22914 * populate_pdev_param_tlv() - populates pdev params
22915 *
22916 * @param pdev_param: Pointer to hold pdev params
22917 * Return: None
22918 */
22919static void populate_pdev_param_tlv(uint32_t *pdev_param)
22920{
22921 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22922 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22923 pdev_param[wmi_pdev_param_txpower_limit2g] =
22924 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22925 pdev_param[wmi_pdev_param_txpower_limit5g] =
22926 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22927 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22928 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22929 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22930 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22931 WMI_PDEV_PARAM_BEACON_TX_MODE;
22932 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22933 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22934 pdev_param[wmi_pdev_param_protection_mode] =
22935 WMI_PDEV_PARAM_PROTECTION_MODE;
22936 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22937 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22938 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22939 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22940 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22941 pdev_param[wmi_pdev_param_sta_kickout_th] =
22942 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22943 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22944 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22945 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22946 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22947 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22948 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22949 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22950 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22951 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22952 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22953 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22954 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22955 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22956 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22957 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22958 pdev_param[wmi_pdev_param_ltr_rx_override] =
22959 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22960 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22961 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22962 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22963 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22964 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22965 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22966 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22967 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22968 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22969 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22970 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22971 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22972 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22973 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22974 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22975 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22976 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22977 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22978 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22979 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22980 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22981 pdev_param[wmi_pdev_param_arp_ac_override] =
22982 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22983 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22984 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22985 pdev_param[wmi_pdev_param_ani_poll_period] =
22986 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22987 pdev_param[wmi_pdev_param_ani_listen_period] =
22988 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22989 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22990 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22991 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22992 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22993 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22994 pdev_param[wmi_pdev_param_idle_ps_config] =
22995 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22996 pdev_param[wmi_pdev_param_power_gating_sleep] =
22997 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22998 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22999 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23000 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23001 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23002 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23003 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23004 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23005 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23006 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23007 pdev_param[wmi_pdev_param_power_collapse_enable] =
23008 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23009 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23010 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23011 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23012 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23013 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23014 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23015 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23016 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23017 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23018 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23019 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23020 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23021 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23022 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23023 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23024 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23025 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23026 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23027 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23028 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23029 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23030 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23031 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23032 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23033 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23034 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23035 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23036 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23037 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23038 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23039 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23040 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23041 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23042 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23043 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23044 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23045 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23046 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23047 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23048 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23049 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23050 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23051 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23052 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023053 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23054 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23055 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023056 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23057 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023058 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023059 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023060 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23061 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23062 WMI_PDEV_PARAM_PROXY_STA_MODE;
23063 pdev_param[wmi_pdev_param_mu_group_policy] =
23064 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23065 pdev_param[wmi_pdev_param_noise_detection] =
23066 WMI_PDEV_PARAM_NOISE_DETECTION;
23067 pdev_param[wmi_pdev_param_noise_threshold] =
23068 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23069 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23070 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23071 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023072 pdev_param[wmi_pdev_param_atf_strict_sch] =
23073 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23074 pdev_param[wmi_pdev_param_atf_sched_duration] =
23075 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023076 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23077 pdev_param[wmi_pdev_param_sensitivity_level] =
23078 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23079 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23080 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23081 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23082 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023083 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23084 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23085 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23086 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023087 pdev_param[wmi_pdev_param_cca_threshold] =
23088 WMI_PDEV_PARAM_CCA_THRESHOLD;
23089 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23090 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023091 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023092 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23093 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23094 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23095 pdev_param[wmi_pdev_param_arp_srcaddr] =
23096 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23097 pdev_param[wmi_pdev_param_arp_dstaddr] =
23098 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23099 pdev_param[wmi_pdev_param_txpower_decr_db] =
23100 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023101 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23102 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023103 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23104 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023105 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023106 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023107 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23108 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023109 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23110 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023111 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23112 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023113 pdev_param[wmi_pdev_param_igmpmld_override] =
23114 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23115 pdev_param[wmi_pdev_param_igmpmld_tid] =
23116 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023117 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23118 pdev_param[wmi_pdev_param_block_interbss] =
23119 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023120 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023121 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23122 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23123 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023124 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023125 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023126 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23127 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023128 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023129 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23130 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023131 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23132 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23133 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23134 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023135 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23136 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23137 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23138 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23139 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23140 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23141 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23142 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23143 pdev_param[wmi_pdev_param_fast_channel_reset] =
23144 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23145 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023146 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023147 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023148 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23149 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053023150 pdev_param[wmi_pdev_param_esp_indication_period] =
23151 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Govind Singhe7f2f342016-05-23 12:12:52 +053023152}
23153
23154/**
23155 * populate_vdev_param_tlv() - populates vdev params
23156 *
23157 * @param vdev_param: Pointer to hold vdev params
23158 * Return: None
23159 */
23160static void populate_vdev_param_tlv(uint32_t *vdev_param)
23161{
23162 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23163 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23164 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23165 vdev_param[wmi_vdev_param_beacon_interval] =
23166 WMI_VDEV_PARAM_BEACON_INTERVAL;
23167 vdev_param[wmi_vdev_param_listen_interval] =
23168 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23169 vdev_param[wmi_vdev_param_multicast_rate] =
23170 WMI_VDEV_PARAM_MULTICAST_RATE;
23171 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23172 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23173 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23174 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23175 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23176 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23177 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23178 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23179 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23180 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23181 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23182 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23183 vdev_param[wmi_vdev_param_bmiss_count_max] =
23184 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23185 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23186 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23187 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23188 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23189 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23190 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23191 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23192 vdev_param[wmi_vdev_param_disable_htprotection] =
23193 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23194 vdev_param[wmi_vdev_param_sta_quickkickout] =
23195 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23196 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23197 vdev_param[wmi_vdev_param_protection_mode] =
23198 WMI_VDEV_PARAM_PROTECTION_MODE;
23199 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23200 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23201 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23202 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23203 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23204 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23205 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23206 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23207 vdev_param[wmi_vdev_param_bcast_data_rate] =
23208 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23209 vdev_param[wmi_vdev_param_mcast_data_rate] =
23210 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23211 vdev_param[wmi_vdev_param_mcast_indicate] =
23212 WMI_VDEV_PARAM_MCAST_INDICATE;
23213 vdev_param[wmi_vdev_param_dhcp_indicate] =
23214 WMI_VDEV_PARAM_DHCP_INDICATE;
23215 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23216 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23217 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23218 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23219 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23220 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23221 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23222 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23223 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23224 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23225 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23226 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23227 vdev_param[wmi_vdev_param_packet_powersave] =
23228 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23229 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23230 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23231 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23232 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23233 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23234 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23235 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23236 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23237 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23238 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23239 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23240 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23241 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23242 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23243 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23244 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23245 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23246 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23247 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23248 vdev_param[wmi_vdev_param_roam_fw_offload] =
23249 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23250 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23251 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23252 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23253 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23254 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23255 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23256 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23257 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23258 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23259 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23260 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23261 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23262 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23263 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23264 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23265 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23266 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23267 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23268 vdev_param[wmi_vdev_param_inactivity_cnt] =
23269 WMI_VDEV_PARAM_INACTIVITY_CNT;
23270 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23271 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23272 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23273 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23274 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23275 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23276 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23277 vdev_param[wmi_vdev_param_rx_leak_window] =
23278 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23279 vdev_param[wmi_vdev_param_stats_avg_factor] =
23280 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23281 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23282 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23283 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23284 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23285 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23286 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023287 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23288 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023289 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023290 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23291 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23292 WMI_VDEV_PARAM_HE_RANGE_EXT;
23293 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23294 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023295 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23296 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023297 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023298 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23299 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23300 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23301 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23302 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23303 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23304 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023305 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23306 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23307 vdev_param[wmi_vdev_param_rc_num_retries] =
23308 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23309 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23310 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23311 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23312 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23313 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23314 vdev_param[wmi_vdev_param_vht80_ratemask] =
23315 WMI_VDEV_PARAM_VHT80_RATEMASK;
23316 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23317 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23318 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023319 vdev_param[wmi_vdev_param_set_he_ltf] =
23320 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023321 vdev_param[wmi_vdev_param_disable_cabq] =
23322 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023323 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23324 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023325 vdev_param[wmi_vdev_param_set_ba_mode] =
23326 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023327 vdev_param[wmi_vdev_param_capabilities] =
23328 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023329 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23330 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023331}
23332#endif
23333
Govind Singh5eb51532016-03-09 11:34:12 +053023334/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023335 * populate_target_defines_tlv() - Populate target defines and params
23336 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023337 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023338 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023339 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023340#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023341static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023342{
Govind Singhe7f2f342016-05-23 12:12:52 +053023343 populate_pdev_param_tlv(wmi_handle->pdev_param);
23344 populate_vdev_param_tlv(wmi_handle->vdev_param);
23345}
23346#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023347static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23348{ }
23349#endif
23350
23351/**
Zhang Qian537fca62018-01-03 16:33:24 +080023352 * wmi_ocb_ut_attach() - Attach OCB test framework
23353 * @wmi_handle: wmi handle
23354 *
23355 * Return: None
23356 */
23357#ifdef WLAN_OCB_UT
23358void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23359#else
23360static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23361{
23362 return;
23363}
23364#endif
23365
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023366/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023367 * wmi_tlv_attach() - Attach TLV APIs
23368 *
23369 * Return: None
23370 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023371void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023372{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023373 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023374 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023375 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023376#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023377 /* Skip saving WMI_CMD_HDR and TLV HDR */
23378 wmi_handle->log_info.buf_offset_command = 8;
23379 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023380 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023381#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023382 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023383 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023384 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023385 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023386 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023387}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023388qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023389
23390/**
23391 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23392 *
23393 * Return: None
23394 */
23395void wmi_tlv_init(void)
23396{
23397 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23398}