blob: 8ab7075a13c09e85635d2edfd608b99f9cd40d2d [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;
Govind Singh87542482016-06-08 19:40:11 +05302200 cmd->buf_len = param->tmpl_len;
2201 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2202
2203 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2204 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2205 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2206 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2207 bcn_prb_info->caps = 0;
2208 bcn_prb_info->erp = 0;
2209 buf_ptr += sizeof(wmi_bcn_prb_info);
2210
2211 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2212 buf_ptr += WMI_TLV_HDR_SIZE;
2213 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2214
2215 ret = wmi_unified_cmd_send(wmi_handle,
2216 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2217 if (ret) {
2218 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2219 wmi_buf_free(wmi_buf);
2220 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302221
Govind Singh87542482016-06-08 19:40:11 +05302222 return 0;
2223}
Govind Singh5eb51532016-03-09 11:34:12 +05302224
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302225#ifdef CONFIG_MCL
2226static inline void copy_peer_flags_tlv(
2227 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2228 struct peer_assoc_params *param)
2229{
2230 cmd->peer_flags = param->peer_flags;
2231}
2232#else
2233static inline void copy_peer_flags_tlv(
2234 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2235 struct peer_assoc_params *param)
2236{
2237 /*
2238 * The target only needs a subset of the flags maintained in the host.
2239 * Just populate those flags and send it down
2240 */
2241 cmd->peer_flags = 0;
2242
2243 /*
2244 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2245 */
2246 if (param->is_wme_set) {
2247
2248 if (param->qos_flag)
2249 cmd->peer_flags |= WMI_PEER_QOS;
2250 if (param->apsd_flag)
2251 cmd->peer_flags |= WMI_PEER_APSD;
2252 if (param->ht_flag)
2253 cmd->peer_flags |= WMI_PEER_HT;
2254 if (param->bw_40)
2255 cmd->peer_flags |= WMI_PEER_40MHZ;
2256 if (param->bw_80)
2257 cmd->peer_flags |= WMI_PEER_80MHZ;
2258 if (param->bw_160)
2259 cmd->peer_flags |= WMI_PEER_160MHZ;
2260
2261 /* Typically if STBC is enabled for VHT it should be enabled
2262 * for HT as well
2263 **/
2264 if (param->stbc_flag)
2265 cmd->peer_flags |= WMI_PEER_STBC;
2266
2267 /* Typically if LDPC is enabled for VHT it should be enabled
2268 * for HT as well
2269 **/
2270 if (param->ldpc_flag)
2271 cmd->peer_flags |= WMI_PEER_LDPC;
2272
2273 if (param->static_mimops_flag)
2274 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2275 if (param->dynamic_mimops_flag)
2276 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2277 if (param->spatial_mux_flag)
2278 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2279 if (param->vht_flag)
2280 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002281 if (param->he_flag)
2282 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302283 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002284
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302285 if (param->is_pmf_enabled)
2286 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302287 /*
2288 * Suppress authorization for all AUTH modes that need 4-way handshake
2289 * (during re-association).
2290 * Authorization will be done for these modes on key installation.
2291 */
2292 if (param->auth_flag)
2293 cmd->peer_flags |= WMI_PEER_AUTH;
2294 if (param->need_ptk_4_way)
2295 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2296 else
2297 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2298 if (param->need_gtk_2_way)
2299 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2300 /* safe mode bypass the 4-way handshake */
2301 if (param->safe_mode_enabled)
2302 cmd->peer_flags &=
2303 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2304 /* Disable AMSDU for station transmit, if user configures it */
2305 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2306 * it
2307 * if (param->amsdu_disable) Add after FW support
2308 **/
2309
2310 /* Target asserts if node is marked HT and all MCS is set to 0.
2311 * Mark the node as non-HT if all the mcs rates are disabled through
2312 * iwpriv
2313 **/
2314 if (param->peer_ht_rates.num_rates == 0)
2315 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302316
2317 if (param->twt_requester)
2318 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2319
2320 if (param->twt_responder)
2321 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302322}
2323#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302324
2325#ifdef CONFIG_MCL
2326static inline void copy_peer_mac_addr_tlv(
2327 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2328 struct peer_assoc_params *param)
2329{
2330 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2331 sizeof(param->peer_macaddr));
2332}
2333#else
2334static inline void copy_peer_mac_addr_tlv(
2335 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2336 struct peer_assoc_params *param)
2337{
2338 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2339}
2340#endif
2341
Govind Singh5eb51532016-03-09 11:34:12 +05302342/**
2343 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2344 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302345 * @param param : pointer to peer assoc parameter
2346 *
2347 * Return: 0 on success and -ve on failure.
2348 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302349static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302350 struct peer_assoc_params *param)
2351{
Govind Singhd3156eb2016-02-26 17:50:39 +05302352 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2353 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002354 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302355 wmi_buf_t buf;
2356 int32_t len;
2357 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302358 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302359 uint32_t peer_legacy_rates_align;
2360 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002361 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302362
2363
2364 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2365 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302366
2367 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002368 (peer_legacy_rates_align * sizeof(uint8_t)) +
2369 WMI_TLV_HDR_SIZE +
2370 (peer_ht_rates_align * sizeof(uint8_t)) +
2371 sizeof(wmi_vht_rate_set) +
2372 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2373 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302374
2375 buf = wmi_buf_alloc(wmi_handle, len);
2376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302377 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302378 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302379 }
2380
2381 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2382 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2383 WMITLV_SET_HDR(&cmd->tlv_header,
2384 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2385 WMITLV_GET_STRUCT_TLVLEN
2386 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302387
Govind Singhd3156eb2016-02-26 17:50:39 +05302388 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302389
Govind Singhd3156eb2016-02-26 17:50:39 +05302390 cmd->peer_new_assoc = param->peer_new_assoc;
2391 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302392
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302393 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302394 copy_peer_mac_addr_tlv(cmd, param);
2395
Govind Singhd3156eb2016-02-26 17:50:39 +05302396 cmd->peer_rate_caps = param->peer_rate_caps;
2397 cmd->peer_caps = param->peer_caps;
2398 cmd->peer_listen_intval = param->peer_listen_intval;
2399 cmd->peer_ht_caps = param->peer_ht_caps;
2400 cmd->peer_max_mpdu = param->peer_max_mpdu;
2401 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302402 cmd->peer_vht_caps = param->peer_vht_caps;
2403 cmd->peer_phymode = param->peer_phymode;
2404
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002405 /* Update 11ax capabilities */
2406 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2407 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002408 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2409 sizeof(param->peer_he_cap_phyinfo));
2410 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2411 sizeof(param->peer_ppet));
2412
Govind Singhd3156eb2016-02-26 17:50:39 +05302413 /* Update peer legacy rate information */
2414 buf_ptr += sizeof(*cmd);
2415 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302416 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302417 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302418 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302419 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302420 param->peer_legacy_rates.num_rates);
2421
2422 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002423 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302424 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302425 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302426 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302427 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302428 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302429 param->peer_ht_rates.num_rates);
2430
2431 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002432 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302433 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2434 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2435
2436 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302437
2438 /* Update bandwidth-NSS mapping */
2439 cmd->peer_bw_rxnss_override = 0;
2440 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2441
Govind Singhd3156eb2016-02-26 17:50:39 +05302442 mcs = (wmi_vht_rate_set *) buf_ptr;
2443 if (param->vht_capable) {
2444 mcs->rx_max_rate = param->rx_max_rate;
2445 mcs->rx_mcs_set = param->rx_mcs_set;
2446 mcs->tx_max_rate = param->tx_max_rate;
2447 mcs->tx_mcs_set = param->tx_mcs_set;
2448 }
2449
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002450 /* HE Rates */
2451 cmd->peer_he_mcs = param->peer_he_mcs_count;
2452 buf_ptr += sizeof(wmi_vht_rate_set);
2453 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2454 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2455 buf_ptr += WMI_TLV_HDR_SIZE;
2456
2457 /* Loop through the HE rate set */
2458 for (i = 0; i < param->peer_he_mcs_count; i++) {
2459 he_mcs = (wmi_he_rate_set *) buf_ptr;
2460 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2461 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2462
2463 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2464 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2465 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2466 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2467 buf_ptr += sizeof(wmi_he_rate_set);
2468 }
2469
2470
Govind Singhb53420c2016-03-09 14:32:57 +05302471 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302472 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2473 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002474 "cmd->peer_vht_caps %x "
2475 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302476 "HE phy %x %x %x "
2477 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302478 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2479 cmd->peer_rate_caps, cmd->peer_caps,
2480 cmd->peer_listen_intval, cmd->peer_ht_caps,
2481 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2482 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002483 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2484 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302485 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2486 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302487
2488 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2489 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302490 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302491 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302492 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302493 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302494 }
2495
2496 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302497}
2498
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302499/* copy_scan_notify_events() - Helper routine to copy scan notify events
2500 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302501static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302502 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302503 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302504{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302505
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302506 /* Scan events subscription */
2507 if (param->scan_ev_started)
2508 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2509 if (param->scan_ev_completed)
2510 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2511 if (param->scan_ev_bss_chan)
2512 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2513 if (param->scan_ev_foreign_chan)
2514 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2515 if (param->scan_ev_dequeued)
2516 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2517 if (param->scan_ev_preempted)
2518 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2519 if (param->scan_ev_start_failed)
2520 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2521 if (param->scan_ev_restarted)
2522 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2523 if (param->scan_ev_foreign_chn_exit)
2524 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2525 if (param->scan_ev_suspended)
2526 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2527 if (param->scan_ev_resumed)
2528 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302529
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302530 /** Set scan control flags */
2531 cmd->scan_ctrl_flags = 0;
2532 if (param->scan_f_passive)
2533 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2534 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302535 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302536 if (param->scan_f_promisc_mode)
2537 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2538 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302539 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302540 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302541 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302542 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302543 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302544 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302545 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302546 if (param->scan_f_ofdm_rates)
2547 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2548 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302549 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302550 if (param->scan_f_filter_prb_req)
2551 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2552 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302553 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302554 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302555 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302556 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302557 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302558 if (param->scan_f_force_active_dfs_chn)
2559 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2560 if (param->scan_f_add_tpc_ie_in_probe)
2561 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2562 if (param->scan_f_add_ds_ie_in_probe)
2563 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2564 if (param->scan_f_add_spoofed_mac_in_probe)
2565 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2566 if (param->scan_f_add_rand_seq_in_probe)
2567 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2568 if (param->scan_f_en_ie_whitelist_in_probe)
2569 cmd->scan_ctrl_flags |=
2570 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302571
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302572 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2573 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2574 param->adaptive_dwell_time_mode);
2575}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302576
2577/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302578static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302579 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302580{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302581 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302582}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302583
Govind Singh5eb51532016-03-09 11:34:12 +05302584/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302585 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2586 * @mac: random mac addr
2587 * @mask: random mac mask
2588 * @mac_addr: wmi random mac
2589 * @mac_mask: wmi random mac mask
2590 *
2591 * Return None.
2592 */
2593static inline
2594void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2595 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2596{
2597 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2598 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2599}
2600
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302601/*
2602 * wmi_fill_vendor_oui() - fill vendor OUIs
2603 * @buf_ptr: pointer to wmi tlv buffer
2604 * @num_vendor_oui: number of vendor OUIs to be filled
2605 * @param_voui: pointer to OUI buffer
2606 *
2607 * This function populates the wmi tlv buffer when vendor specific OUIs are
2608 * present.
2609 *
2610 * Return: None
2611 */
2612static inline
2613void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2614 uint32_t *pvoui)
2615{
2616 wmi_vendor_oui *voui = NULL;
2617 uint32_t i;
2618
2619 voui = (wmi_vendor_oui *)buf_ptr;
2620
2621 for (i = 0; i < num_vendor_oui; i++) {
2622 WMITLV_SET_HDR(&voui[i].tlv_header,
2623 WMITLV_TAG_STRUC_wmi_vendor_oui,
2624 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2625 voui[i].oui_type_subtype = pvoui[i];
2626 }
2627}
2628
2629/*
2630 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2631 * @ie_bitmap: output pointer to ie bit map in cmd
2632 * @num_vendor_oui: output pointer to num vendor OUIs
2633 * @ie_whitelist: input parameter
2634 *
2635 * This function populates the IE whitelist attrs of scan, pno and
2636 * scan oui commands for ie_whitelist parameter.
2637 *
2638 * Return: None
2639 */
2640static inline
2641void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2642 uint32_t *num_vendor_oui,
2643 struct probe_req_whitelist_attr *ie_whitelist)
2644{
2645 uint32_t i = 0;
2646
2647 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2648 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2649
2650 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2651}
2652
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302653/**
Govind Singh5eb51532016-03-09 11:34:12 +05302654 * send_scan_start_cmd_tlv() - WMI scan start function
2655 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302656 * @param param : pointer to hold scan start cmd parameter
2657 *
2658 * Return: 0 on success and -ve on failure.
2659 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302660static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302661 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302662{
Govind Singhd3156eb2016-02-26 17:50:39 +05302663 int32_t ret = 0;
2664 int32_t i;
2665 wmi_buf_t wmi_buf;
2666 wmi_start_scan_cmd_fixed_param *cmd;
2667 uint8_t *buf_ptr;
2668 uint32_t *tmp_ptr;
2669 wmi_ssid *ssid = NULL;
2670 wmi_mac_addr *bssid;
2671 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302672 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302673 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302674 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302675
2676 /* Length TLV placeholder for array of uint32_t */
2677 len += WMI_TLV_HDR_SIZE;
2678 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302679 if (params->chan_list.num_chan)
2680 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302681
2682 /* Length TLV placeholder for array of wmi_ssid structures */
2683 len += WMI_TLV_HDR_SIZE;
2684 if (params->num_ssids)
2685 len += params->num_ssids * sizeof(wmi_ssid);
2686
2687 /* Length TLV placeholder for array of wmi_mac_addr structures */
2688 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302689 if (params->num_bssid)
2690 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302691
2692 /* Length TLV placeholder for array of bytes */
2693 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302694 if (params->extraie.len)
2695 extraie_len_with_pad =
2696 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002697 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302698
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302699 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2700 if (ie_whitelist->num_vendor_oui)
2701 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2702
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302703 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2704 if (params->scan_f_wide_band)
2705 phymode_roundup =
2706 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2707 sizeof(uint32_t));
2708 len += phymode_roundup;
2709
Govind Singhd3156eb2016-02-26 17:50:39 +05302710 /* Allocate the memory */
2711 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2712 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302713 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302714 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302715 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302716 }
2717 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2718 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2719 WMITLV_SET_HDR(&cmd->tlv_header,
2720 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2721 WMITLV_GET_STRUCT_TLVLEN
2722 (wmi_start_scan_cmd_fixed_param));
2723
2724 cmd->scan_id = params->scan_id;
2725 cmd->scan_req_id = params->scan_req_id;
2726 cmd->vdev_id = params->vdev_id;
2727 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302728
2729 copy_scan_event_cntrl_flags(cmd, params);
2730
Govind Singhd3156eb2016-02-26 17:50:39 +05302731 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002732 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302733 cmd->dwell_time_passive = params->dwell_time_passive;
2734 cmd->min_rest_time = params->min_rest_time;
2735 cmd->max_rest_time = params->max_rest_time;
2736 cmd->repeat_probe_time = params->repeat_probe_time;
2737 cmd->probe_spacing_time = params->probe_spacing_time;
2738 cmd->idle_time = params->idle_time;
2739 cmd->max_scan_time = params->max_scan_time;
2740 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302741 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302742 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302743 cmd->num_bssid = params->num_bssid;
2744 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302745 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302746 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302747 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2748
2749 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2750
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302751 if (params->scan_random.randomize)
2752 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2753 params->scan_random.mac_mask,
2754 &cmd->mac_addr,
2755 &cmd->mac_mask);
2756
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302757 if (ie_whitelist->white_list)
2758 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2759 &cmd->num_vendor_oui,
2760 ie_whitelist);
2761
Govind Singhd3156eb2016-02-26 17:50:39 +05302762 buf_ptr += sizeof(*cmd);
2763 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302764 for (i = 0; i < params->chan_list.num_chan; ++i)
2765 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302766
2767 WMITLV_SET_HDR(buf_ptr,
2768 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302769 (params->chan_list.num_chan * sizeof(uint32_t)));
2770 buf_ptr += WMI_TLV_HDR_SIZE +
2771 (params->chan_list.num_chan * sizeof(uint32_t));
2772
Govind Singh4eacd2b2016-03-07 14:24:22 +05302773 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302774 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302775 goto error;
2776 }
2777
2778 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2779 (params->num_ssids * sizeof(wmi_ssid)));
2780
2781 if (params->num_ssids) {
2782 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2783 for (i = 0; i < params->num_ssids; ++i) {
2784 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302785 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302786 params->ssid[i].length);
2787 ssid++;
2788 }
2789 }
2790 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2791
2792 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2793 (params->num_bssid * sizeof(wmi_mac_addr)));
2794 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302795
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302796 if (params->num_bssid) {
2797 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302798 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2799 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302800 bssid++;
2801 }
2802 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302803
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302804 buf_ptr += WMI_TLV_HDR_SIZE +
2805 (params->num_bssid * sizeof(wmi_mac_addr));
2806
2807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2808 if (params->extraie.len)
2809 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2810 params);
2811
2812 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302813
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302814 /* probe req ie whitelisting */
2815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2816 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2817
2818 buf_ptr += WMI_TLV_HDR_SIZE;
2819
2820 if (cmd->num_vendor_oui) {
2821 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2822 ie_whitelist->voui);
2823 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2824 }
2825
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302826 /* Add phy mode TLV if it's a wide band scan */
2827 if (params->scan_f_wide_band) {
2828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2829 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2830 for (i = 0; i < params->chan_list.num_chan; ++i)
2831 buf_ptr[i] =
2832 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2833 buf_ptr += phymode_roundup;
2834 } else {
2835 /* Add ZERO legth phy mode TLV */
2836 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2837 }
2838
Santosh Anbu1e11b472018-03-07 15:33:27 +05302839 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002840 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302841 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302842 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302843 wmi_buf_free(wmi_buf);
2844 }
2845 return ret;
2846error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302847 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302848 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302849}
2850
2851/**
2852 * send_scan_stop_cmd_tlv() - WMI scan start function
2853 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302854 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302855 *
2856 * Return: 0 on success and -ve on failure.
2857 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302858static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302859 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302860{
Govind Singhd3156eb2016-02-26 17:50:39 +05302861 wmi_stop_scan_cmd_fixed_param *cmd;
2862 int ret;
2863 int len = sizeof(*cmd);
2864 wmi_buf_t wmi_buf;
2865
2866 /* Allocate the memory */
2867 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2868 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302869 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302870 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302871 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302872 goto error;
2873 }
2874
2875 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2876 WMITLV_SET_HDR(&cmd->tlv_header,
2877 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2878 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2879 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302880 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302881 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302882 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2883 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302884 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302885 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2886 /* Cancelling all scans */
2887 cmd->req_type = WMI_SCAN_STOP_ALL;
2888 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2889 /* Cancelling VAP scans */
2890 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2891 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2892 /* Cancelling specific scan */
2893 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302894 } else {
2895 WMI_LOGE("%s: Invalid Command : ", __func__);
2896 wmi_buf_free(wmi_buf);
2897 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302898 }
2899
Santosh Anbu1e11b472018-03-07 15:33:27 +05302900 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002901 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302902 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302903 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302904 wmi_buf_free(wmi_buf);
2905 }
2906
2907error:
2908 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302909}
2910
Govind Singh87542482016-06-08 19:40:11 +05302911#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302912/**
2913 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2914 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302915 * @param param : pointer to hold scan channel list parameter
2916 *
2917 * Return: 0 on success and -ve on failure.
2918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302919static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302920 struct scan_chan_list_params *chan_list)
2921{
2922 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302923 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302924 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302925 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302926 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302927 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302928 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2929
2930 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2931 buf = wmi_buf_alloc(wmi_handle, len);
2932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302933 WMI_LOGE("Failed to allocate memory");
2934 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302935 goto end;
2936 }
2937
2938 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2939 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2940 WMITLV_SET_HDR(&cmd->tlv_header,
2941 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2942 WMITLV_GET_STRUCT_TLVLEN
2943 (wmi_scan_chan_list_cmd_fixed_param));
2944
Govind Singhb53420c2016-03-09 14:32:57 +05302945 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302946
2947 cmd->num_scan_chans = chan_list->num_scan_chans;
2948 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2949 WMITLV_TAG_ARRAY_STRUC,
2950 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302951 chan_info = (wmi_channel_param *)
2952 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302953 tchan_info = chan_list->chan_info;
2954
2955 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2956 WMITLV_SET_HDR(&chan_info->tlv_header,
2957 WMITLV_TAG_STRUC_wmi_channel,
2958 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2959 chan_info->mhz = tchan_info->mhz;
2960 chan_info->band_center_freq1 =
2961 tchan_info->band_center_freq1;
2962 chan_info->band_center_freq2 =
2963 tchan_info->band_center_freq2;
2964 chan_info->info = tchan_info->info;
2965 chan_info->reg_info_1 = tchan_info->reg_info_1;
2966 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302967 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302968
2969 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2970 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2971 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2972 tchan_info++;
2973 chan_info++;
2974 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302975 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2976 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302977
Anish Natarajdd855152017-03-20 12:49:08 +05302978 qdf_status = wmi_unified_cmd_send(wmi_handle,
2979 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302980
Govind Singh67922e82016-04-01 16:48:57 +05302981 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302982 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302983 wmi_buf_free(buf);
2984 }
Govind Singh67922e82016-04-01 16:48:57 +05302985
Govind Singhd3156eb2016-02-26 17:50:39 +05302986end:
Govind Singhb53420c2016-03-09 14:32:57 +05302987 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302988}
Govind Singh87542482016-06-08 19:40:11 +05302989#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302990static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302991 struct scan_chan_list_params *chan_list)
2992{
2993 wmi_buf_t buf;
2994 QDF_STATUS qdf_status;
2995 wmi_scan_chan_list_cmd_fixed_param *cmd;
2996 int i;
2997 uint8_t *buf_ptr;
2998 wmi_channel *chan_info;
2999 struct channel_param *tchan_info;
3000 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05303001
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303002 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303003 buf = wmi_buf_alloc(wmi_handle, len);
3004 if (!buf) {
3005 WMI_LOGE("Failed to allocate memory");
3006 qdf_status = QDF_STATUS_E_NOMEM;
3007 goto end;
3008 }
3009
3010 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3011 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
3012 WMITLV_SET_HDR(&cmd->tlv_header,
3013 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
3014 WMITLV_GET_STRUCT_TLVLEN
3015 (wmi_scan_chan_list_cmd_fixed_param));
3016
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303017 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05303018
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05303019 if (chan_list->append)
3020 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
3021
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303022 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3023 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303024 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303025 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
3026 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303027 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05303028 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
3029 tchan_info = &(chan_list->ch_param[0]);
3030
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303031 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05303032 WMITLV_SET_HDR(&chan_info->tlv_header,
3033 WMITLV_TAG_STRUC_wmi_channel,
3034 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3035 chan_info->mhz = tchan_info->mhz;
3036 chan_info->band_center_freq1 =
3037 tchan_info->cfreq1;
3038 chan_info->band_center_freq2 =
3039 tchan_info->cfreq2;
3040
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303041 if (tchan_info->is_chan_passive)
3042 WMI_SET_CHANNEL_FLAG(chan_info,
3043 WMI_CHAN_FLAG_PASSIVE);
3044
3045 if (tchan_info->allow_vht)
3046 WMI_SET_CHANNEL_FLAG(chan_info,
3047 WMI_CHAN_FLAG_ALLOW_VHT);
3048 else if (tchan_info->allow_ht)
3049 WMI_SET_CHANNEL_FLAG(chan_info,
3050 WMI_CHAN_FLAG_ALLOW_HT);
3051 WMI_SET_CHANNEL_MODE(chan_info,
3052 tchan_info->phy_mode);
3053
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303054 if (tchan_info->half_rate)
3055 WMI_SET_CHANNEL_FLAG(chan_info,
3056 WMI_CHAN_FLAG_HALF_RATE);
3057
3058 if (tchan_info->quarter_rate)
3059 WMI_SET_CHANNEL_FLAG(chan_info,
3060 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303061
3062 /* also fill in power information */
3063 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3064 tchan_info->minpower);
3065 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3066 tchan_info->maxpower);
3067 WMI_SET_CHANNEL_REG_POWER(chan_info,
3068 tchan_info->maxregpower);
3069 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3070 tchan_info->antennamax);
3071 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3072 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003073 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3074 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303075
Govind Singh87542482016-06-08 19:40:11 +05303076 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3077
Govind Singh87542482016-06-08 19:40:11 +05303078 tchan_info++;
3079 chan_info++;
3080 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303081 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3082 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303083
Anish Natarajdd855152017-03-20 12:49:08 +05303084 qdf_status = wmi_unified_cmd_send(
3085 wmi_handle,
3086 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303087
3088 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3089 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3090 wmi_buf_free(buf);
3091 }
3092
3093end:
3094 return qdf_status;
3095}
3096#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303097
3098/**
3099 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3100 *
3101 * @bufp: Pointer to buffer
3102 * @param: Pointer to tx param
3103 *
3104 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3105 */
3106static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3107 struct tx_send_params param)
3108{
3109 wmi_tx_send_params *tx_param;
3110 QDF_STATUS status = QDF_STATUS_SUCCESS;
3111
3112 if (!bufp) {
3113 status = QDF_STATUS_E_FAILURE;
3114 return status;
3115 }
3116 tx_param = (wmi_tx_send_params *)bufp;
3117 WMITLV_SET_HDR(&tx_param->tlv_header,
3118 WMITLV_TAG_STRUC_wmi_tx_send_params,
3119 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3120 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3121 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3122 param.mcs_mask);
3123 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3124 param.nss_mask);
3125 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3126 param.retry_limit);
3127 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3128 param.chain_mask);
3129 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3130 param.bw_mask);
3131 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3132 param.preamble_type);
3133 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3134 param.frame_type);
3135
3136 return status;
3137}
3138
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303139#ifdef CONFIG_HL_SUPPORT
3140/**
3141 * send_mgmt_cmd_tlv() - WMI scan start function
3142 * @wmi_handle : handle to WMI.
3143 * @param : pointer to hold mgmt cmd parameter
3144 *
3145 * Return: 0 on success and -ve on failure.
3146 */
3147static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3148 struct wmi_mgmt_params *param)
3149{
3150 wmi_buf_t buf;
3151 uint8_t *bufp;
3152 int32_t cmd_len;
3153 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3154 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3155 mgmt_tx_dl_frm_len;
3156
3157 if (param->frm_len > mgmt_tx_dl_frm_len) {
3158 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3159 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3160 return QDF_STATUS_E_INVAL;
3161 }
3162
3163 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3164 WMI_TLV_HDR_SIZE +
3165 roundup(bufp_len, sizeof(uint32_t));
3166
3167 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3168 if (!buf) {
3169 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3170 return QDF_STATUS_E_NOMEM;
3171 }
3172
3173 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3174 bufp = (uint8_t *) cmd;
3175 WMITLV_SET_HDR(&cmd->tlv_header,
3176 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3177 WMITLV_GET_STRUCT_TLVLEN
3178 (wmi_mgmt_tx_send_cmd_fixed_param));
3179
3180 cmd->vdev_id = param->vdev_id;
3181
3182 cmd->desc_id = param->desc_id;
3183 cmd->chanfreq = param->chanfreq;
3184 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3185 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3186 sizeof(uint32_t)));
3187 bufp += WMI_TLV_HDR_SIZE;
3188 qdf_mem_copy(bufp, param->pdata, bufp_len);
3189
3190 cmd->frame_len = param->frm_len;
3191 cmd->buf_len = bufp_len;
3192 cmd->tx_params_valid = param->tx_params_valid;
3193
3194 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3195 bufp, cmd->vdev_id, cmd->chanfreq);
3196
3197 bufp += roundup(bufp_len, sizeof(uint32_t));
3198 if (param->tx_params_valid) {
3199 if (populate_tx_send_params(bufp, param->tx_param) !=
3200 QDF_STATUS_SUCCESS) {
3201 WMI_LOGE("%s: Populate TX send params failed",
3202 __func__);
3203 goto free_buf;
3204 }
3205 cmd_len += sizeof(wmi_tx_send_params);
3206 }
3207
3208 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3209 WMI_MGMT_TX_SEND_CMDID)) {
3210 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3211 goto free_buf;
3212 }
3213 return QDF_STATUS_SUCCESS;
3214
3215free_buf:
3216 wmi_buf_free(buf);
3217 return QDF_STATUS_E_FAILURE;
3218}
3219#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303220/**
3221 * send_mgmt_cmd_tlv() - WMI scan start function
3222 * @wmi_handle : handle to WMI.
3223 * @param : pointer to hold mgmt cmd parameter
3224 *
3225 * Return: 0 on success and -ve on failure.
3226 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303227static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303228 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303229{
Govind Singh427ee5a2016-02-26 18:09:36 +05303230 wmi_buf_t buf;
3231 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3232 int32_t cmd_len;
3233 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303234 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303235 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303236 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303237 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3238 mgmt_tx_dl_frm_len;
3239
3240 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303241 WMI_TLV_HDR_SIZE +
3242 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303243
Sathish Kumar5b636932017-06-28 14:40:32 +05303244 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303245 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303246 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3247 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303248 }
3249
3250 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3251 bufp = (uint8_t *) cmd;
3252 WMITLV_SET_HDR(&cmd->tlv_header,
3253 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3254 WMITLV_GET_STRUCT_TLVLEN
3255 (wmi_mgmt_tx_send_cmd_fixed_param));
3256
3257 cmd->vdev_id = param->vdev_id;
3258
Govind Singh224a7312016-06-21 14:33:26 +05303259 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303260 cmd->chanfreq = param->chanfreq;
3261 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3262 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3263 sizeof(uint32_t)));
3264 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303265 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303266
3267 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3268 QDF_DMA_TO_DEVICE);
3269 if (status != QDF_STATUS_SUCCESS) {
3270 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303271 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303272 }
3273
Govind Singhb53420c2016-03-09 14:32:57 +05303274 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303275 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003276#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303277 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3278#endif
3279 cmd->frame_len = param->frm_len;
3280 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303281 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303282
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003283 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003284 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003285
Sathish Kumar5b636932017-06-28 14:40:32 +05303286 bufp += roundup(bufp_len, sizeof(uint32_t));
3287 if (param->tx_params_valid) {
3288 status = populate_tx_send_params(bufp, param->tx_param);
3289 if (status != QDF_STATUS_SUCCESS) {
3290 WMI_LOGE("%s: Populate TX send params failed",
3291 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303292 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303293 }
3294 cmd_len += sizeof(wmi_tx_send_params);
3295 }
3296
Govind Singh427ee5a2016-02-26 18:09:36 +05303297 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3298 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303299 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303300 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303301 }
Govind Singhb53420c2016-03-09 14:32:57 +05303302 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303303
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303304unmap_tx_frame:
3305 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3306 QDF_DMA_TO_DEVICE);
3307free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303308 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303309 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303311#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303312
3313/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303314 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3315 * @wmi_handle : handle to WMI.
3316 * @param : pointer to offchan data tx cmd parameter
3317 *
3318 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3319 */
3320static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3321 struct wmi_offchan_data_tx_params *param)
3322{
3323 wmi_buf_t buf;
3324 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3325 int32_t cmd_len;
3326 uint64_t dma_addr;
3327 void *qdf_ctx = param->qdf_ctx;
3328 uint8_t *bufp;
3329 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3330 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303331 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303332
3333 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303334 WMI_TLV_HDR_SIZE +
3335 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303336
Sathish Kumar5b636932017-06-28 14:40:32 +05303337 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303338 if (!buf) {
3339 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3340 return QDF_STATUS_E_NOMEM;
3341 }
3342
3343 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3344 bufp = (uint8_t *) cmd;
3345 WMITLV_SET_HDR(&cmd->tlv_header,
3346 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3347 WMITLV_GET_STRUCT_TLVLEN
3348 (wmi_offchan_data_tx_send_cmd_fixed_param));
3349
3350 cmd->vdev_id = param->vdev_id;
3351
3352 cmd->desc_id = param->desc_id;
3353 cmd->chanfreq = param->chanfreq;
3354 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3355 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3356 sizeof(uint32_t)));
3357 bufp += WMI_TLV_HDR_SIZE;
3358 qdf_mem_copy(bufp, param->pdata, bufp_len);
3359 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3360 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3361 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3362#if defined(HTT_PADDR64)
3363 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3364#endif
3365 cmd->frame_len = param->frm_len;
3366 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303367 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303368
3369 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3370 bufp, cmd->vdev_id, cmd->chanfreq);
3371
Sathish Kumar5b636932017-06-28 14:40:32 +05303372 bufp += roundup(bufp_len, sizeof(uint32_t));
3373 if (param->tx_params_valid) {
3374 status = populate_tx_send_params(bufp, param->tx_param);
3375 if (status != QDF_STATUS_SUCCESS) {
3376 WMI_LOGE("%s: Populate TX send params failed",
3377 __func__);
3378 goto err1;
3379 }
3380 cmd_len += sizeof(wmi_tx_send_params);
3381 }
3382
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303383 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3384 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3385 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303386 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303387 }
3388
3389 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303390
3391err1:
3392 wmi_buf_free(buf);
3393 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303394}
3395
3396/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303397 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3398 * @wmi_handle: wmi handle
3399 * @param_value: parameter value
3400 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303401 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303402 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303403static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303404 uint32_t param_value)
3405{
Govind Singh67922e82016-04-01 16:48:57 +05303406 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303407 wmi_modem_power_state_cmd_param *cmd;
3408 wmi_buf_t buf;
3409 uint16_t len = sizeof(*cmd);
3410
3411 buf = wmi_buf_alloc(wmi_handle, len);
3412 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303413 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303414 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303415 }
3416 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3417 WMITLV_SET_HDR(&cmd->tlv_header,
3418 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3419 WMITLV_GET_STRUCT_TLVLEN
3420 (wmi_modem_power_state_cmd_param));
3421 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303422 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303423 param_value);
3424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3425 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303426 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303427 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303428 wmi_buf_free(buf);
3429 }
Govind Singh67922e82016-04-01 16:48:57 +05303430
Govind Singh427ee5a2016-02-26 18:09:36 +05303431 return ret;
3432}
3433
3434/**
3435 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3436 * @wmi_handle: wmi handle
3437 * @vdev_id: vdev id
3438 * @val: value
3439 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303440 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303441 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303442static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303443 uint32_t vdev_id, uint8_t val)
3444{
3445 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3446 wmi_buf_t buf;
3447 int32_t len = sizeof(*cmd);
3448
Govind Singhb53420c2016-03-09 14:32:57 +05303449 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303450
3451 buf = wmi_buf_alloc(wmi_handle, len);
3452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303453 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303454 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303455 }
3456 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3457 WMITLV_SET_HDR(&cmd->tlv_header,
3458 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3459 WMITLV_GET_STRUCT_TLVLEN
3460 (wmi_sta_powersave_mode_cmd_fixed_param));
3461 cmd->vdev_id = vdev_id;
3462 if (val)
3463 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3464 else
3465 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3466
3467 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3468 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303469 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303470 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303471 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303472 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303473 }
Govind Singh5eb51532016-03-09 11:34:12 +05303474 return 0;
3475}
3476
Govind Singh427ee5a2016-02-26 18:09:36 +05303477/**
3478 * send_set_mimops_cmd_tlv() - set MIMO powersave
3479 * @wmi_handle: wmi handle
3480 * @vdev_id: vdev id
3481 * @value: value
3482 *
Govind Singhb53420c2016-03-09 14:32:57 +05303483 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303484 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303485static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303486 uint8_t vdev_id, int value)
3487{
Govind Singh67922e82016-04-01 16:48:57 +05303488 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303489 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3490 wmi_buf_t buf;
3491 uint16_t len = sizeof(*cmd);
3492
3493 buf = wmi_buf_alloc(wmi_handle, len);
3494 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303495 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303496 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303497 }
3498 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3499 WMITLV_SET_HDR(&cmd->tlv_header,
3500 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3501 WMITLV_GET_STRUCT_TLVLEN
3502 (wmi_sta_smps_force_mode_cmd_fixed_param));
3503
3504 cmd->vdev_id = vdev_id;
3505
Houston Hoffmanb5168052016-04-14 02:18:01 -07003506 /* WMI_SMPS_FORCED_MODE values do not directly map
3507 * to SM power save values defined in the specification.
3508 * Make sure to send the right mapping.
3509 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303510 switch (value) {
3511 case 0:
3512 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3513 break;
3514 case 1:
3515 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3516 break;
3517 case 2:
3518 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3519 break;
3520 case 3:
3521 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3522 break;
3523 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303524 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303525 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303526 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303527 }
3528
Govind Singhb53420c2016-03-09 14:32:57 +05303529 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303530
3531 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3532 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303533 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303534 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303535 wmi_buf_free(buf);
3536 }
3537
3538 return ret;
3539}
3540
3541/**
3542 * send_set_smps_params_cmd_tlv() - set smps params
3543 * @wmi_handle: wmi handle
3544 * @vdev_id: vdev id
3545 * @value: value
3546 *
Govind Singhb53420c2016-03-09 14:32:57 +05303547 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303548 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303549static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303550 int value)
3551{
Govind Singh67922e82016-04-01 16:48:57 +05303552 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303553 wmi_sta_smps_param_cmd_fixed_param *cmd;
3554 wmi_buf_t buf;
3555 uint16_t len = sizeof(*cmd);
3556
3557 buf = wmi_buf_alloc(wmi_handle, len);
3558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303559 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303560 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303561 }
3562 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3563 WMITLV_SET_HDR(&cmd->tlv_header,
3564 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3565 WMITLV_GET_STRUCT_TLVLEN
3566 (wmi_sta_smps_param_cmd_fixed_param));
3567
3568 cmd->vdev_id = vdev_id;
3569 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3570 cmd->param =
3571 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3572
Govind Singhb53420c2016-03-09 14:32:57 +05303573 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303574 cmd->param);
3575
3576 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3577 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303578 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303579 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303580 wmi_buf_free(buf);
3581 }
3582
3583 return ret;
3584}
3585
3586/**
3587 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3588 * @wmi_handle: wmi handle
3589 * @noa: p2p power save parameters
3590 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303591 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303593static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303594 struct p2p_ps_params *noa)
3595{
3596 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3597 wmi_p2p_noa_descriptor *noa_discriptor;
3598 wmi_buf_t buf;
3599 uint8_t *buf_ptr;
3600 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303601 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303602 uint32_t duration;
3603
Govind Singhb53420c2016-03-09 14:32:57 +05303604 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303605 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3606 buf = wmi_buf_alloc(wmi_handle, len);
3607 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303608 WMI_LOGE("Failed to allocate memory");
3609 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303610 goto end;
3611 }
3612
3613 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3614 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3615 WMITLV_SET_HDR(&cmd->tlv_header,
3616 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3617 WMITLV_GET_STRUCT_TLVLEN
3618 (wmi_p2p_set_noa_cmd_fixed_param));
3619 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3620 cmd->vdev_id = noa->session_id;
3621 cmd->enable = (duration) ? true : false;
3622 cmd->num_noa = 1;
3623
3624 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3625 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3626 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3627 sizeof
3628 (wmi_p2p_set_noa_cmd_fixed_param)
3629 + WMI_TLV_HDR_SIZE);
3630 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3631 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3632 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3633 noa_discriptor->type_count = noa->count;
3634 noa_discriptor->duration = duration;
3635 noa_discriptor->interval = noa->interval;
3636 noa_discriptor->start_time = 0;
3637
Govind Singhb53420c2016-03-09 14:32:57 +05303638 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303639 cmd->vdev_id, noa->count, noa_discriptor->duration,
3640 noa->interval);
3641 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3642 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303643 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303644 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303645 wmi_buf_free(buf);
3646 }
3647
3648end:
Govind Singhb53420c2016-03-09 14:32:57 +05303649 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303650 return status;
3651}
3652
3653
3654/**
3655 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3656 * @wmi_handle: wmi handle
3657 * @noa: p2p opp power save parameters
3658 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303659 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303660 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303661static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303662 struct p2p_ps_params *oppps)
3663{
3664 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3665 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303666 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303667
Govind Singhb53420c2016-03-09 14:32:57 +05303668 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303669 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3670 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303671 WMI_LOGE("Failed to allocate memory");
3672 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303673 goto end;
3674 }
3675
3676 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3677 WMITLV_SET_HDR(&cmd->tlv_header,
3678 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3679 WMITLV_GET_STRUCT_TLVLEN
3680 (wmi_p2p_set_oppps_cmd_fixed_param));
3681 cmd->vdev_id = oppps->session_id;
3682 if (oppps->ctwindow)
3683 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3684
3685 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303686 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303687 cmd->vdev_id, oppps->ctwindow);
3688 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3689 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303690 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303691 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303692 wmi_buf_free(buf);
3693 }
3694
3695end:
Govind Singhb53420c2016-03-09 14:32:57 +05303696 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303697 return status;
3698}
3699
Wu Gaocd3a8512017-03-13 20:17:34 +08003700#ifdef CONVERGED_P2P_ENABLE
3701/**
3702 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3703 * @wmi_handle: wmi handle
3704 * @param: p2p listen offload start parameters
3705 *
3706 * Return: QDF status
3707 */
3708static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3709 struct p2p_lo_start *param)
3710{
3711 wmi_buf_t buf;
3712 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3713 int32_t len = sizeof(*cmd);
3714 uint8_t *buf_ptr;
3715 QDF_STATUS status;
3716 int device_types_len_aligned;
3717 int probe_resp_len_aligned;
3718
3719 if (!param) {
3720 WMI_LOGE("lo start param is null");
3721 return QDF_STATUS_E_INVAL;
3722 }
3723
3724 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3725
3726 device_types_len_aligned =
3727 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303728 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003729 probe_resp_len_aligned =
3730 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303731 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003732
3733 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3734 probe_resp_len_aligned;
3735
3736 buf = wmi_buf_alloc(wmi_handle, len);
3737 if (!buf) {
3738 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3739 __func__);
3740 return QDF_STATUS_E_NOMEM;
3741 }
3742
3743 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3744 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3745
3746 WMITLV_SET_HDR(&cmd->tlv_header,
3747 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3748 WMITLV_GET_STRUCT_TLVLEN(
3749 wmi_p2p_lo_start_cmd_fixed_param));
3750
3751 cmd->vdev_id = param->vdev_id;
3752 cmd->ctl_flags = param->ctl_flags;
3753 cmd->channel = param->freq;
3754 cmd->period = param->period;
3755 cmd->interval = param->interval;
3756 cmd->count = param->count;
3757 cmd->device_types_len = param->dev_types_len;
3758 cmd->prob_resp_len = param->probe_resp_len;
3759
3760 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3762 device_types_len_aligned);
3763 buf_ptr += WMI_TLV_HDR_SIZE;
3764 qdf_mem_copy(buf_ptr, param->device_types,
3765 param->dev_types_len);
3766
3767 buf_ptr += device_types_len_aligned;
3768 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3769 probe_resp_len_aligned);
3770 buf_ptr += WMI_TLV_HDR_SIZE;
3771 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3772 param->probe_resp_len);
3773
3774 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3775 cmd->channel, cmd->period, cmd->interval, cmd->count);
3776
3777 status = wmi_unified_cmd_send(wmi_handle,
3778 buf, len,
3779 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3780 if (status != QDF_STATUS_SUCCESS) {
3781 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3782 __func__, status);
3783 wmi_buf_free(buf);
3784 return status;
3785 }
3786
3787 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3788
3789 return QDF_STATUS_SUCCESS;
3790}
3791
3792/**
3793 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3794 * @wmi_handle: wmi handle
3795 * @param: p2p listen offload stop parameters
3796 *
3797 * Return: QDF status
3798 */
3799static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3800 uint8_t vdev_id)
3801{
3802 wmi_buf_t buf;
3803 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3804 int32_t len;
3805 QDF_STATUS status;
3806
3807 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3808
3809 len = sizeof(*cmd);
3810 buf = wmi_buf_alloc(wmi_handle, len);
3811 if (!buf) {
3812 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3813 __func__);
3814 return QDF_STATUS_E_NOMEM;
3815 }
3816 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3817
3818 WMITLV_SET_HDR(&cmd->tlv_header,
3819 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3820 WMITLV_GET_STRUCT_TLVLEN(
3821 wmi_p2p_lo_stop_cmd_fixed_param));
3822
3823 cmd->vdev_id = vdev_id;
3824
3825 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3826
3827 status = wmi_unified_cmd_send(wmi_handle,
3828 buf, len,
3829 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3830 if (status != QDF_STATUS_SUCCESS) {
3831 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3832 __func__, status);
3833 wmi_buf_free(buf);
3834 return status;
3835 }
3836
3837 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3838
3839 return QDF_STATUS_SUCCESS;
3840}
3841#endif /* End of CONVERGED_P2P_ENABLE */
3842
Govind Singh427ee5a2016-02-26 18:09:36 +05303843/**
3844 * send_get_temperature_cmd_tlv() - get pdev temperature req
3845 * @wmi_handle: wmi handle
3846 *
Govind Singhb53420c2016-03-09 14:32:57 +05303847 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303848 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303849static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303850{
3851 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3852 wmi_buf_t wmi_buf;
3853 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3854 uint8_t *buf_ptr;
3855
3856 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303857 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3858 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303859 }
3860
3861 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3862 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303863 WMI_LOGE(FL("wmi_buf_alloc failed"));
3864 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303865 }
3866
3867 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3868
3869 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3870 WMITLV_SET_HDR(&cmd->tlv_header,
3871 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3872 WMITLV_GET_STRUCT_TLVLEN
3873 (wmi_pdev_get_temperature_cmd_fixed_param));
3874
3875 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3876 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303877 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303878 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303879 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303880 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303881
Govind Singhb53420c2016-03-09 14:32:57 +05303882 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303883}
3884
3885/**
3886 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3887 * @wmi_handle: wmi handle
3888 * @vdevid: vdev id
3889 * @peer_addr: peer mac address
3890 * @auto_triggerparam: auto trigger parameters
3891 * @num_ac: number of access category
3892 *
3893 * This function sets the trigger
3894 * uapsd params such as service interval, delay interval
3895 * and suspend interval which will be used by the firmware
3896 * to send trigger frames periodically when there is no
3897 * traffic on the transmit side.
3898 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303899 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303900 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303901static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303902 struct sta_uapsd_trig_params *param)
3903{
3904 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303905 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303906 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3907 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3908 uint32_t i;
3909 wmi_buf_t buf;
3910 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003911 struct sta_uapsd_params *uapsd_param;
3912 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303913
3914 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3915 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303916 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303917 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303918 }
3919
3920 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3921 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3922 WMITLV_SET_HDR(&cmd->tlv_header,
3923 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3924 WMITLV_GET_STRUCT_TLVLEN
3925 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3926 cmd->vdev_id = param->vdevid;
3927 cmd->num_ac = param->num_ac;
3928 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3929
3930 /* TLV indicating array of structures to follow */
3931 buf_ptr += sizeof(*cmd);
3932 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3933
3934 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303935
3936 /*
3937 * Update tag and length for uapsd auto trigger params (this will take
3938 * care of updating tag and length if it is not pre-filled by caller).
3939 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003940 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3941 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303942 for (i = 0; i < param->num_ac; i++) {
3943 WMITLV_SET_HDR((buf_ptr +
3944 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3945 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3946 WMITLV_GET_STRUCT_TLVLEN
3947 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003948 trig_param->wmm_ac = uapsd_param->wmm_ac;
3949 trig_param->user_priority = uapsd_param->user_priority;
3950 trig_param->service_interval = uapsd_param->service_interval;
3951 trig_param->suspend_interval = uapsd_param->suspend_interval;
3952 trig_param->delay_interval = uapsd_param->delay_interval;
3953 trig_param++;
3954 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303955 }
3956
3957 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3958 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303959 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303960 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303961 wmi_buf_free(buf);
3962 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303963
Govind Singh427ee5a2016-02-26 18:09:36 +05303964 return ret;
3965}
3966
Zhang Qian11c0de32018-01-05 16:50:53 +08003967#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303968/**
3969 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3970 * @wmi_handle: pointer to the wmi handle
3971 * @utc: pointer to the UTC time struct
3972 *
3973 * Return: 0 on succes
3974 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303975static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303976 struct ocb_utc_param *utc)
3977{
Govind Singh67922e82016-04-01 16:48:57 +05303978 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303979 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3980 uint8_t *buf_ptr;
3981 uint32_t len, i;
3982 wmi_buf_t buf;
3983
3984 len = sizeof(*cmd);
3985 buf = wmi_buf_alloc(wmi_handle, len);
3986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303987 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303988 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303989 }
3990
3991 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3992 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3993 WMITLV_SET_HDR(&cmd->tlv_header,
3994 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3995 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3996 cmd->vdev_id = utc->vdev_id;
3997
3998 for (i = 0; i < SIZE_UTC_TIME; i++)
3999 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
4000
4001 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
4002 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
4003
4004 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4005 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304006 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304007 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304008 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304009 }
4010
Govind Singh67922e82016-04-01 16:48:57 +05304011 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304012}
4013
4014/**
4015 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
4016 * frames on a channel
4017 * @wmi_handle: pointer to the wmi handle
4018 * @timing_advert: pointer to the timing advertisement struct
4019 *
4020 * Return: 0 on succes
4021 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304022static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304023 struct ocb_timing_advert_param *timing_advert)
4024{
Govind Singh67922e82016-04-01 16:48:57 +05304025 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304026 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
4027 uint8_t *buf_ptr;
4028 uint32_t len, len_template;
4029 wmi_buf_t buf;
4030
4031 len = sizeof(*cmd) +
4032 WMI_TLV_HDR_SIZE;
4033
4034 len_template = timing_advert->template_length;
4035 /* Add padding to the template if needed */
4036 if (len_template % 4 != 0)
4037 len_template += 4 - (len_template % 4);
4038 len += len_template;
4039
4040 buf = wmi_buf_alloc(wmi_handle, len);
4041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304042 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304043 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304044 }
4045
4046 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4047 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4048 WMITLV_SET_HDR(&cmd->tlv_header,
4049 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4050 WMITLV_GET_STRUCT_TLVLEN(
4051 wmi_ocb_start_timing_advert_cmd_fixed_param));
4052 cmd->vdev_id = timing_advert->vdev_id;
4053 cmd->repeat_rate = timing_advert->repeat_rate;
4054 cmd->channel_freq = timing_advert->chan_freq;
4055 cmd->timestamp_offset = timing_advert->timestamp_offset;
4056 cmd->time_value_offset = timing_advert->time_value_offset;
4057 cmd->timing_advert_template_length = timing_advert->template_length;
4058 buf_ptr += sizeof(*cmd);
4059
4060 /* Add the timing advert template */
4061 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4062 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304063 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304064 (uint8_t *)timing_advert->template_value,
4065 timing_advert->template_length);
4066
4067 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4068 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304069 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304070 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304071 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304072 }
4073
Govind Singh67922e82016-04-01 16:48:57 +05304074 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304075}
4076
4077/**
4078 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4079 * on a channel
4080 * @wmi_handle: pointer to the wmi handle
4081 * @timing_advert: pointer to the timing advertisement struct
4082 *
4083 * Return: 0 on succes
4084 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304085static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304086 struct ocb_timing_advert_param *timing_advert)
4087{
Govind Singh67922e82016-04-01 16:48:57 +05304088 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304089 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4090 uint8_t *buf_ptr;
4091 uint32_t len;
4092 wmi_buf_t buf;
4093
4094 len = sizeof(*cmd);
4095 buf = wmi_buf_alloc(wmi_handle, len);
4096 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304097 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304098 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304099 }
4100
4101 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4102 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4103 WMITLV_SET_HDR(&cmd->tlv_header,
4104 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4105 WMITLV_GET_STRUCT_TLVLEN(
4106 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4107 cmd->vdev_id = timing_advert->vdev_id;
4108 cmd->channel_freq = timing_advert->chan_freq;
4109
4110 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4111 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304112 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304113 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304114 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304115 }
4116
Govind Singh67922e82016-04-01 16:48:57 +05304117 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304118}
4119
4120/**
4121 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4122 * @wmi_handle: pointer to the wmi handle
4123 * @request: pointer to the request
4124 *
4125 * Return: 0 on succes
4126 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304127static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304128 uint8_t vdev_id)
4129{
Govind Singhb53420c2016-03-09 14:32:57 +05304130 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304131 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4132 uint8_t *buf_ptr;
4133 wmi_buf_t buf;
4134 int32_t len;
4135
4136 len = sizeof(*cmd);
4137 buf = wmi_buf_alloc(wmi_handle, len);
4138 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304139 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304140 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304141 }
4142 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4143
4144 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304145 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304146 WMITLV_SET_HDR(&cmd->tlv_header,
4147 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4148 WMITLV_GET_STRUCT_TLVLEN(
4149 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4150 cmd->vdev_id = vdev_id;
4151
4152 /* Send the WMI command */
4153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4154 WMI_OCB_GET_TSF_TIMER_CMDID);
4155 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304156 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304158 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304159 }
4160
Govind Singh67922e82016-04-01 16:48:57 +05304161 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304162}
4163
4164/**
4165 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4166 * @wmi_handle: pointer to the wmi handle
4167 * @get_stats_param: pointer to the dcc stats
4168 *
4169 * Return: 0 on succes
4170 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304171static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004172 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304173{
Govind Singh67922e82016-04-01 16:48:57 +05304174 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304175 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4176 wmi_dcc_channel_stats_request *channel_stats_array;
4177 wmi_buf_t buf;
4178 uint8_t *buf_ptr;
4179 uint32_t len;
4180 uint32_t i;
4181
4182 /* Validate the input */
4183 if (get_stats_param->request_array_len !=
4184 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304185 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304186 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304187 }
4188
4189 /* Allocate memory for the WMI command */
4190 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4191 get_stats_param->request_array_len;
4192
4193 buf = wmi_buf_alloc(wmi_handle, len);
4194 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304195 WMI_LOGE(FL("wmi_buf_alloc failed"));
4196 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304197 }
4198
4199 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304200 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304201
4202 /* Populate the WMI command */
4203 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4204 buf_ptr += sizeof(*cmd);
4205
4206 WMITLV_SET_HDR(&cmd->tlv_header,
4207 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4208 WMITLV_GET_STRUCT_TLVLEN(
4209 wmi_dcc_get_stats_cmd_fixed_param));
4210 cmd->vdev_id = get_stats_param->vdev_id;
4211 cmd->num_channels = get_stats_param->channel_count;
4212
4213 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4214 get_stats_param->request_array_len);
4215 buf_ptr += WMI_TLV_HDR_SIZE;
4216
4217 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304218 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304219 get_stats_param->request_array_len);
4220 for (i = 0; i < cmd->num_channels; i++)
4221 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4222 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4223 WMITLV_GET_STRUCT_TLVLEN(
4224 wmi_dcc_channel_stats_request));
4225
4226 /* Send the WMI command */
4227 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4228 WMI_DCC_GET_STATS_CMDID);
4229
Govind Singh67922e82016-04-01 16:48:57 +05304230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304231 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304232 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304233 }
4234
Govind Singh67922e82016-04-01 16:48:57 +05304235 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304236}
4237
4238/**
4239 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4240 * @wmi_handle: pointer to the wmi handle
4241 * @vdev_id: vdev id
4242 * @dcc_stats_bitmap: dcc status bitmap
4243 *
4244 * Return: 0 on succes
4245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304246static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304247 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4248{
Govind Singh67922e82016-04-01 16:48:57 +05304249 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304250 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4251 wmi_buf_t buf;
4252 uint8_t *buf_ptr;
4253 uint32_t len;
4254
4255 /* Allocate memory for the WMI command */
4256 len = sizeof(*cmd);
4257
4258 buf = wmi_buf_alloc(wmi_handle, len);
4259 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304260 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304261 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304262 }
4263
4264 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304265 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304266
4267 /* Populate the WMI command */
4268 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4269
4270 WMITLV_SET_HDR(&cmd->tlv_header,
4271 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4272 WMITLV_GET_STRUCT_TLVLEN(
4273 wmi_dcc_clear_stats_cmd_fixed_param));
4274 cmd->vdev_id = vdev_id;
4275 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4276
4277 /* Send the WMI command */
4278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4279 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304280 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304281 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304282 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304283 }
4284
Govind Singh67922e82016-04-01 16:48:57 +05304285 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304286}
4287
4288/**
4289 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4290 * @wmi_handle: pointer to the wmi handle
4291 * @update_ndl_param: pointer to the request parameters
4292 *
4293 * Return: 0 on success
4294 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304295static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004296 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304297{
Govind Singhb53420c2016-03-09 14:32:57 +05304298 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304299 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4300 wmi_dcc_ndl_chan *ndl_chan_array;
4301 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4302 uint32_t active_state_count;
4303 wmi_buf_t buf;
4304 uint8_t *buf_ptr;
4305 uint32_t len;
4306 uint32_t i;
4307
4308 /* validate the input */
4309 if (update_ndl_param->dcc_ndl_chan_list_len !=
4310 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304311 WMI_LOGE(FL("Invalid parameter"));
4312 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304313 }
4314 active_state_count = 0;
4315 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4316 for (i = 0; i < update_ndl_param->channel_count; i++)
4317 active_state_count +=
4318 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4319 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4320 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304321 WMI_LOGE(FL("Invalid parameter"));
4322 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304323 }
4324
4325 /* Allocate memory for the WMI command */
4326 len = sizeof(*cmd) +
4327 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4328 WMI_TLV_HDR_SIZE +
4329 update_ndl_param->dcc_ndl_active_state_list_len;
4330
4331 buf = wmi_buf_alloc(wmi_handle, len);
4332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304333 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304334 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304335 }
4336
4337 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304338 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304339
4340 /* Populate the WMI command */
4341 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4342 buf_ptr += sizeof(*cmd);
4343
4344 WMITLV_SET_HDR(&cmd->tlv_header,
4345 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4346 WMITLV_GET_STRUCT_TLVLEN(
4347 wmi_dcc_update_ndl_cmd_fixed_param));
4348 cmd->vdev_id = update_ndl_param->vdev_id;
4349 cmd->num_channel = update_ndl_param->channel_count;
4350
4351 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4352 update_ndl_param->dcc_ndl_chan_list_len);
4353 buf_ptr += WMI_TLV_HDR_SIZE;
4354
4355 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304356 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304357 update_ndl_param->dcc_ndl_chan_list_len);
4358 for (i = 0; i < cmd->num_channel; i++)
4359 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4360 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4361 WMITLV_GET_STRUCT_TLVLEN(
4362 wmi_dcc_ndl_chan));
4363 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4364
4365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4366 update_ndl_param->dcc_ndl_active_state_list_len);
4367 buf_ptr += WMI_TLV_HDR_SIZE;
4368
4369 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304370 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304371 update_ndl_param->dcc_ndl_active_state_list,
4372 update_ndl_param->dcc_ndl_active_state_list_len);
4373 for (i = 0; i < active_state_count; i++) {
4374 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4375 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4376 WMITLV_GET_STRUCT_TLVLEN(
4377 wmi_dcc_ndl_active_state_config));
4378 }
4379 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4380
4381 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304382 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304383 WMI_DCC_UPDATE_NDL_CMDID);
4384 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304385 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304386 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304387 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304388 }
4389
Govind Singh67922e82016-04-01 16:48:57 +05304390 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304391}
4392
4393/**
4394 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4395 * @wmi_handle: pointer to the wmi handle
4396 * @config: the OCB configuration
4397 *
4398 * Return: 0 on success
4399 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304400static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004401 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304402{
Govind Singh67922e82016-04-01 16:48:57 +05304403 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304404 wmi_ocb_set_config_cmd_fixed_param *cmd;
4405 wmi_channel *chan;
4406 wmi_ocb_channel *ocb_chan;
4407 wmi_qos_parameter *qos_param;
4408 wmi_dcc_ndl_chan *ndl_chan;
4409 wmi_dcc_ndl_active_state_config *ndl_active_config;
4410 wmi_ocb_schedule_element *sched_elem;
4411 uint8_t *buf_ptr;
4412 wmi_buf_t buf;
4413 int32_t len;
4414 int32_t i, j, active_state_count;
4415
4416 /*
4417 * Validate the dcc_ndl_chan_list_len and count the number of active
4418 * states. Validate dcc_ndl_active_state_list_len.
4419 */
4420 active_state_count = 0;
4421 if (config->dcc_ndl_chan_list_len) {
4422 if (!config->dcc_ndl_chan_list ||
4423 config->dcc_ndl_chan_list_len !=
4424 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304425 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304426 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304427 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304428 }
4429
4430 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4431 i < config->channel_count; ++i, ++ndl_chan)
4432 active_state_count +=
4433 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4434
4435 if (active_state_count) {
4436 if (!config->dcc_ndl_active_state_list ||
4437 config->dcc_ndl_active_state_list_len !=
4438 active_state_count *
4439 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304440 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304441 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304442 }
4443 }
4444 }
4445
4446 len = sizeof(*cmd) +
4447 WMI_TLV_HDR_SIZE + config->channel_count *
4448 sizeof(wmi_channel) +
4449 WMI_TLV_HDR_SIZE + config->channel_count *
4450 sizeof(wmi_ocb_channel) +
4451 WMI_TLV_HDR_SIZE + config->channel_count *
4452 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4453 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4454 WMI_TLV_HDR_SIZE + active_state_count *
4455 sizeof(wmi_dcc_ndl_active_state_config) +
4456 WMI_TLV_HDR_SIZE + config->schedule_size *
4457 sizeof(wmi_ocb_schedule_element);
4458 buf = wmi_buf_alloc(wmi_handle, len);
4459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304460 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304461 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304462 }
4463
4464 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4465 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004469 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304470 cmd->channel_count = config->channel_count;
4471 cmd->schedule_size = config->schedule_size;
4472 cmd->flags = config->flags;
4473 buf_ptr += sizeof(*cmd);
4474
4475 /* Add the wmi_channel info */
4476 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4477 config->channel_count*sizeof(wmi_channel));
4478 buf_ptr += WMI_TLV_HDR_SIZE;
4479 for (i = 0; i < config->channel_count; i++) {
4480 chan = (wmi_channel *)buf_ptr;
4481 WMITLV_SET_HDR(&chan->tlv_header,
4482 WMITLV_TAG_STRUC_wmi_channel,
4483 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4484 chan->mhz = config->channels[i].chan_freq;
4485 chan->band_center_freq1 = config->channels[i].chan_freq;
4486 chan->band_center_freq2 = 0;
4487 chan->info = 0;
4488
Zhang Qian11c0de32018-01-05 16:50:53 +08004489 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304490 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4491 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4492 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4493 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4494 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4495 config->channels[i].antenna_max);
4496
4497 if (config->channels[i].bandwidth < 10)
4498 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4499 else if (config->channels[i].bandwidth < 20)
4500 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4501 buf_ptr += sizeof(*chan);
4502 }
4503
4504 /* Add the wmi_ocb_channel info */
4505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4506 config->channel_count*sizeof(wmi_ocb_channel));
4507 buf_ptr += WMI_TLV_HDR_SIZE;
4508 for (i = 0; i < config->channel_count; i++) {
4509 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4510 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4511 WMITLV_TAG_STRUC_wmi_ocb_channel,
4512 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4513 ocb_chan->bandwidth = config->channels[i].bandwidth;
4514 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4515 config->channels[i].mac_address.bytes,
4516 &ocb_chan->mac_address);
4517 buf_ptr += sizeof(*ocb_chan);
4518 }
4519
4520 /* Add the wmi_qos_parameter info */
4521 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4522 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4523 buf_ptr += WMI_TLV_HDR_SIZE;
4524 /* WMI_MAX_NUM_AC parameters for each channel */
4525 for (i = 0; i < config->channel_count; i++) {
4526 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4527 qos_param = (wmi_qos_parameter *)buf_ptr;
4528 WMITLV_SET_HDR(&qos_param->tlv_header,
4529 WMITLV_TAG_STRUC_wmi_qos_parameter,
4530 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4531 qos_param->aifsn =
4532 config->channels[i].qos_params[j].aifsn;
4533 qos_param->cwmin =
4534 config->channels[i].qos_params[j].cwmin;
4535 qos_param->cwmax =
4536 config->channels[i].qos_params[j].cwmax;
4537 buf_ptr += sizeof(*qos_param);
4538 }
4539 }
4540
4541 /* Add the wmi_dcc_ndl_chan (per channel) */
4542 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4543 config->dcc_ndl_chan_list_len);
4544 buf_ptr += WMI_TLV_HDR_SIZE;
4545 if (config->dcc_ndl_chan_list_len) {
4546 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304547 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304548 config->dcc_ndl_chan_list_len);
4549 for (i = 0; i < config->channel_count; i++)
4550 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4551 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4552 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4553 buf_ptr += config->dcc_ndl_chan_list_len;
4554 }
4555
4556 /* Add the wmi_dcc_ndl_active_state_config */
4557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4558 sizeof(wmi_dcc_ndl_active_state_config));
4559 buf_ptr += WMI_TLV_HDR_SIZE;
4560 if (active_state_count) {
4561 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304562 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304563 config->dcc_ndl_active_state_list,
4564 active_state_count * sizeof(*ndl_active_config));
4565 for (i = 0; i < active_state_count; ++i)
4566 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4567 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4568 WMITLV_GET_STRUCT_TLVLEN(
4569 wmi_dcc_ndl_active_state_config));
4570 buf_ptr += active_state_count *
4571 sizeof(*ndl_active_config);
4572 }
4573
4574 /* Add the wmi_ocb_schedule_element info */
4575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4576 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4577 buf_ptr += WMI_TLV_HDR_SIZE;
4578 for (i = 0; i < config->schedule_size; i++) {
4579 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4580 WMITLV_SET_HDR(&sched_elem->tlv_header,
4581 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4582 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4583 sched_elem->channel_freq = config->schedule[i].chan_freq;
4584 sched_elem->total_duration = config->schedule[i].total_duration;
4585 sched_elem->guard_interval = config->schedule[i].guard_interval;
4586 buf_ptr += sizeof(*sched_elem);
4587 }
4588
4589
4590 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4591 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304592 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304593 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304594 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304595 }
4596
Govind Singh67922e82016-04-01 16:48:57 +05304597 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304598}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304599
4600/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004601 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4602 * @wmi_handle: wmi handle
4603 * @evt_buf: wmi event buffer
4604 * @status: status buffer
4605 *
4606 * Return: QDF_STATUS_SUCCESS on success
4607 */
4608static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4609 void *evt_buf,
4610 uint32_t *status)
4611{
4612 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4613 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4614
4615 param_tlvs = evt_buf;
4616 fix_param = param_tlvs->fixed_param;
4617
4618 *status = fix_param->status;
4619 return QDF_STATUS_SUCCESS;
4620}
4621
4622/**
4623 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4624 * @wmi_handle: wmi handle
4625 * @evt_buf: wmi event buffer
4626 * @resp: response buffer
4627 *
4628 * Return: QDF_STATUS_SUCCESS on success
4629 */
4630static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4631 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4632{
4633 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4634 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4635
4636 param_tlvs = evt_buf;
4637 fix_param = param_tlvs->fixed_param;
4638 resp->vdev_id = fix_param->vdev_id;
4639 resp->timer_high = fix_param->tsf_timer_high;
4640 resp->timer_low = fix_param->tsf_timer_low;
4641
4642 return QDF_STATUS_SUCCESS;
4643}
4644
4645/**
4646 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4647 * @wmi_handle: wmi handle
4648 * @evt_buf: wmi event buffer
4649 * @resp: response buffer
4650 *
4651 * Return: QDF_STATUS_SUCCESS on success
4652 */
4653static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4654 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4655{
4656 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4657 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4658
4659 param_tlvs = evt_buf;
4660 fix_param = param_tlvs->fixed_param;
4661 resp->vdev_id = fix_param->vdev_id;
4662 resp->status = fix_param->status;
4663 return QDF_STATUS_SUCCESS;
4664}
4665
4666/**
4667 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4668 * @wmi_handle: wmi handle
4669 * @evt_buf: wmi event buffer
4670 * @resp: response buffer
4671 *
4672 * Since length of stats is variable, buffer for DCC stats will be allocated
4673 * in this function. The caller must free the buffer.
4674 *
4675 * Return: QDF_STATUS_SUCCESS on success
4676 */
4677static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4678 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4679{
4680 struct ocb_dcc_get_stats_response *response;
4681 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4682 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4683
4684 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4685 fix_param = param_tlvs->fixed_param;
4686
4687 /* Allocate and populate the response */
4688 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4689 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4690 WMI_LOGE("%s: too many channels:%d", __func__,
4691 fix_param->num_channels);
4692 QDF_ASSERT(0);
4693 *resp = NULL;
4694 return QDF_STATUS_E_INVAL;
4695 }
4696 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4697 sizeof(wmi_dcc_ndl_stats_per_channel));
4698 *resp = response;
4699 if (!response)
4700 return QDF_STATUS_E_NOMEM;
4701
4702 response->vdev_id = fix_param->vdev_id;
4703 response->num_channels = fix_param->num_channels;
4704 response->channel_stats_array_len =
4705 fix_param->num_channels *
4706 sizeof(wmi_dcc_ndl_stats_per_channel);
4707 response->channel_stats_array = ((uint8_t *)response) +
4708 sizeof(*response);
4709 qdf_mem_copy(response->channel_stats_array,
4710 param_tlvs->stats_per_channel_list,
4711 response->channel_stats_array_len);
4712
4713 return QDF_STATUS_SUCCESS;
4714}
4715#endif
4716
4717/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304718 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4719 * @wmi_handle: wmi handle
4720 * @mcc_adaptive_scheduler: enable/disable
4721 *
4722 * This function enable/disable mcc adaptive scheduler in fw.
4723 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004724 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304725 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304726static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004727 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4728 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304729{
Govind Singh67922e82016-04-01 16:48:57 +05304730 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304731 wmi_buf_t buf = 0;
4732 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4733 uint16_t len =
4734 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4735
4736 buf = wmi_buf_alloc(wmi_handle, len);
4737 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304738 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4739 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304740 }
4741 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4742 wmi_buf_data(buf);
4743
4744 WMITLV_SET_HDR(&cmd->tlv_header,
4745 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4746 WMITLV_GET_STRUCT_TLVLEN
4747 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4748 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304749 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304750
4751 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4752 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304753 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304754 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304755 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304756 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304757 }
Govind Singh67922e82016-04-01 16:48:57 +05304758
4759 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304760}
4761
4762/**
4763 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4764 * @wmi: wmi handle
4765 * @mcc_channel: mcc channel
4766 * @mcc_channel_time_latency: MCC channel time latency.
4767 *
4768 * Currently used to set time latency for an MCC vdev/adapter using operating
4769 * channel of it and channel number. The info is provided run time using
4770 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4771 *
4772 * Return: CDF status
4773 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304774static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304775 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4776{
Govind Singh67922e82016-04-01 16:48:57 +05304777 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304778 wmi_buf_t buf = 0;
4779 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4780 uint16_t len = 0;
4781 uint8_t *buf_ptr = NULL;
4782 wmi_resmgr_chan_latency chan_latency;
4783 /* Note: we only support MCC time latency for a single channel */
4784 uint32_t num_channels = 1;
4785 uint32_t chan1_freq = mcc_channel_freq;
4786 uint32_t latency_chan1 = mcc_channel_time_latency;
4787
4788
4789 /* If 0ms latency is provided, then FW will set to a default.
4790 * Otherwise, latency must be at least 30ms.
4791 */
4792 if ((latency_chan1 > 0) &&
4793 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304794 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304795 "Minimum is 30ms (or 0 to use default value by "
4796 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304797 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304798 }
4799
4800 /* Set WMI CMD for channel time latency here */
4801 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4802 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4803 num_channels * sizeof(wmi_resmgr_chan_latency);
4804 buf = wmi_buf_alloc(wmi_handle, len);
4805 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304806 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4807 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304808 }
4809 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4810 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4811 wmi_buf_data(buf);
4812 WMITLV_SET_HDR(&cmdTL->tlv_header,
4813 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4814 WMITLV_GET_STRUCT_TLVLEN
4815 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4816 cmdTL->num_chans = num_channels;
4817 /* Update channel time latency information for home channel(s) */
4818 buf_ptr += sizeof(*cmdTL);
4819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4820 num_channels * sizeof(wmi_resmgr_chan_latency));
4821 buf_ptr += WMI_TLV_HDR_SIZE;
4822 chan_latency.chan_mhz = chan1_freq;
4823 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304824 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304825 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4826 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304827 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304828 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304829 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304830 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304831 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304832 }
Govind Singh67922e82016-04-01 16:48:57 +05304833
4834 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304835}
4836
4837/**
4838 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4839 * @wmi: wmi handle
4840 * @adapter_1_chan_number: adapter 1 channel number
4841 * @adapter_1_quota: adapter 1 quota
4842 * @adapter_2_chan_number: adapter 2 channel number
4843 *
4844 * Return: CDF status
4845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304846static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304847 uint32_t adapter_1_chan_freq,
4848 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4849{
Govind Singh67922e82016-04-01 16:48:57 +05304850 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304851 wmi_buf_t buf = 0;
4852 uint16_t len = 0;
4853 uint8_t *buf_ptr = NULL;
4854 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4855 wmi_resmgr_chan_time_quota chan_quota;
4856 uint32_t quota_chan1 = adapter_1_quota;
4857 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4858 uint32_t quota_chan2 = 100 - quota_chan1;
4859 /* Note: setting time quota for MCC requires info for 2 channels */
4860 uint32_t num_channels = 2;
4861 uint32_t chan1_freq = adapter_1_chan_freq;
4862 uint32_t chan2_freq = adapter_2_chan_freq;
4863
Govind Singhb53420c2016-03-09 14:32:57 +05304864 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304865 "freq2:%dMHz, Quota2:%dms", __func__,
4866 chan1_freq, quota_chan1, chan2_freq,
4867 quota_chan2);
4868
4869 /*
4870 * Perform sanity check on time quota values provided.
4871 */
4872 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4873 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304874 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304875 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304876 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304877 }
4878 /* Set WMI CMD for channel time quota here */
4879 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4880 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4881 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4882 buf = wmi_buf_alloc(wmi_handle, len);
4883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304884 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4885 QDF_ASSERT(0);
4886 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304887 }
4888 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4889 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4890 wmi_buf_data(buf);
4891 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4892 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4893 WMITLV_GET_STRUCT_TLVLEN
4894 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4895 cmdTQ->num_chans = num_channels;
4896
4897 /* Update channel time quota information for home channel(s) */
4898 buf_ptr += sizeof(*cmdTQ);
4899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4900 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4901 buf_ptr += WMI_TLV_HDR_SIZE;
4902 chan_quota.chan_mhz = chan1_freq;
4903 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304904 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304905 /* Construct channel and quota record for the 2nd MCC mode. */
4906 buf_ptr += sizeof(chan_quota);
4907 chan_quota.chan_mhz = chan2_freq;
4908 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304909 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304910
4911 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4912 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304913 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304914 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304915 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304916 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304917 }
Govind Singh67922e82016-04-01 16:48:57 +05304918
4919 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304920}
4921
4922/**
4923 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4924 * @wmi_handle: Pointer to wmi handle
4925 * @thermal_info: Thermal command information
4926 *
4927 * This function sends the thermal management command
4928 * to the firmware
4929 *
Govind Singhb53420c2016-03-09 14:32:57 +05304930 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304931 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304932static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304933 struct thermal_cmd_params *thermal_info)
4934{
4935 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4936 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304937 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304938 uint32_t len = 0;
4939
4940 len = sizeof(*cmd);
4941
4942 buf = wmi_buf_alloc(wmi_handle, len);
4943 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304944 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4945 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304946 }
4947
4948 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4949
4950 WMITLV_SET_HDR(&cmd->tlv_header,
4951 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4952 WMITLV_GET_STRUCT_TLVLEN
4953 (wmi_thermal_mgmt_cmd_fixed_param));
4954
4955 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4956 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4957 cmd->enable = thermal_info->thermal_enable;
4958
Govind Singhb53420c2016-03-09 14:32:57 +05304959 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304960 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4961
4962 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4963 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304964 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304965 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304966 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304967 }
4968
Govind Singh67922e82016-04-01 16:48:57 +05304969 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304970}
4971
4972
4973/**
4974 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304975 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304976 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4977 *
4978 * This function sends down the LRO configuration parameters to
4979 * the firmware to enable LRO, sets the TCP flags and sets the
4980 * seed values for the toeplitz hash generation
4981 *
Govind Singhb53420c2016-03-09 14:32:57 +05304982 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304983 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304984static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304985 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4986{
4987 wmi_lro_info_cmd_fixed_param *cmd;
4988 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304989 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304990
4991
4992 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304994 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4995 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304996 }
4997
4998 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4999
5000 WMITLV_SET_HDR(&cmd->tlv_header,
5001 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
5002 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
5003
5004 cmd->lro_enable = wmi_lro_cmd->lro_enable;
5005 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
5006 wmi_lro_cmd->tcp_flag);
5007 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
5008 wmi_lro_cmd->tcp_flag_mask);
5009 cmd->toeplitz_hash_ipv4_0_3 =
5010 wmi_lro_cmd->toeplitz_hash_ipv4[0];
5011 cmd->toeplitz_hash_ipv4_4_7 =
5012 wmi_lro_cmd->toeplitz_hash_ipv4[1];
5013 cmd->toeplitz_hash_ipv4_8_11 =
5014 wmi_lro_cmd->toeplitz_hash_ipv4[2];
5015 cmd->toeplitz_hash_ipv4_12_15 =
5016 wmi_lro_cmd->toeplitz_hash_ipv4[3];
5017 cmd->toeplitz_hash_ipv4_16 =
5018 wmi_lro_cmd->toeplitz_hash_ipv4[4];
5019
5020 cmd->toeplitz_hash_ipv6_0_3 =
5021 wmi_lro_cmd->toeplitz_hash_ipv6[0];
5022 cmd->toeplitz_hash_ipv6_4_7 =
5023 wmi_lro_cmd->toeplitz_hash_ipv6[1];
5024 cmd->toeplitz_hash_ipv6_8_11 =
5025 wmi_lro_cmd->toeplitz_hash_ipv6[2];
5026 cmd->toeplitz_hash_ipv6_12_15 =
5027 wmi_lro_cmd->toeplitz_hash_ipv6[3];
5028 cmd->toeplitz_hash_ipv6_16_19 =
5029 wmi_lro_cmd->toeplitz_hash_ipv6[4];
5030 cmd->toeplitz_hash_ipv6_20_23 =
5031 wmi_lro_cmd->toeplitz_hash_ipv6[5];
5032 cmd->toeplitz_hash_ipv6_24_27 =
5033 wmi_lro_cmd->toeplitz_hash_ipv6[6];
5034 cmd->toeplitz_hash_ipv6_28_31 =
5035 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5036 cmd->toeplitz_hash_ipv6_32_35 =
5037 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5038 cmd->toeplitz_hash_ipv6_36_39 =
5039 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5040 cmd->toeplitz_hash_ipv6_40 =
5041 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5042
Govind Singhb53420c2016-03-09 14:32:57 +05305043 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305044 cmd->lro_enable, cmd->tcp_flag_u32);
5045
5046 status = wmi_unified_cmd_send(wmi_handle, buf,
5047 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305048 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305049 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305050 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305051 }
5052
Govind Singh67922e82016-04-01 16:48:57 +05305053 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305054}
5055
Govind Singh4eacd2b2016-03-07 14:24:22 +05305056/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305057 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5058 * @wmi_handle: Pointer to wmi handle
5059 * @rate_report_params: Pointer to peer rate report parameters
5060 *
5061 *
5062 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5063 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305064static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305065 struct wmi_peer_rate_report_params *rate_report_params)
5066{
5067 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5068 wmi_buf_t buf = NULL;
5069 QDF_STATUS status = 0;
5070 uint32_t len = 0;
5071 uint32_t i, j;
5072
5073 len = sizeof(*cmd);
5074
5075 buf = wmi_buf_alloc(wmi_handle, len);
5076 if (!buf) {
5077 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5078 return QDF_STATUS_E_FAILURE;
5079 }
5080
5081 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5082 wmi_buf_data(buf);
5083
5084 WMITLV_SET_HDR(
5085 &cmd->tlv_header,
5086 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5087 WMITLV_GET_STRUCT_TLVLEN(
5088 wmi_peer_set_rate_report_condition_fixed_param));
5089
5090 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5091 cmd->report_backoff_time = rate_report_params->backoff_time;
5092 cmd->report_timer_period = rate_report_params->timer_period;
5093 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5094 cmd->cond_per_phy[i].val_cond_flags =
5095 rate_report_params->report_per_phy[i].cond_flags;
5096 cmd->cond_per_phy[i].rate_delta.min_delta =
5097 rate_report_params->report_per_phy[i].delta.delta_min;
5098 cmd->cond_per_phy[i].rate_delta.percentage =
5099 rate_report_params->report_per_phy[i].delta.percent;
5100 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5101 cmd->cond_per_phy[i].rate_threshold[j] =
5102 rate_report_params->report_per_phy[i].
5103 report_rate_threshold[j];
5104 }
5105 }
5106
5107 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5108 cmd->enable_rate_report,
5109 cmd->report_backoff_time, cmd->report_timer_period);
5110
5111 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5112 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5113 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305114 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305115 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5116 __func__);
5117 }
5118 return status;
5119}
5120
5121/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305122 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5123 * @wmi_handle: wmi handle
5124 * @param: bcn ll cmd parameter
5125 *
Govind Singhb53420c2016-03-09 14:32:57 +05305126 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305127 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305128static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 wmi_bcn_send_from_host_cmd_fixed_param *param)
5130{
5131 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5132 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305133 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305134
5135 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5136 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305137 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5138 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305139 }
5140
5141 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5142 WMITLV_SET_HDR(&cmd->tlv_header,
5143 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5144 WMITLV_GET_STRUCT_TLVLEN
5145 (wmi_bcn_send_from_host_cmd_fixed_param));
5146 cmd->vdev_id = param->vdev_id;
5147 cmd->data_len = param->data_len;
5148 cmd->frame_ctrl = param->frame_ctrl;
5149 cmd->frag_ptr = param->frag_ptr;
5150 cmd->dtim_flag = param->dtim_flag;
5151
5152 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5153 WMI_PDEV_SEND_BCN_CMDID);
5154
Govind Singh67922e82016-04-01 16:48:57 +05305155 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305156 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305157 wmi_buf_free(wmi_buf);
5158 }
5159
5160 return ret;
5161}
5162
5163/**
5164 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5165 * @wmi_handle: wmi handle
5166 * @vdev_id: vdev id
5167 * @max_retries: max retries
5168 * @retry_interval: retry interval
5169 * This function sets sta query related parameters in fw.
5170 *
Govind Singhb53420c2016-03-09 14:32:57 +05305171 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305172 */
5173
Sathish Kumarfd347372017-02-13 12:29:09 +05305174static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305175 uint8_t vdev_id, uint32_t max_retries,
5176 uint32_t retry_interval)
5177{
5178 wmi_buf_t buf;
5179 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5180 int len;
5181
5182 len = sizeof(*cmd);
5183 buf = wmi_buf_alloc(wmi_handle, len);
5184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305185 WMI_LOGE(FL("wmi_buf_alloc failed"));
5186 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305187 }
5188
5189 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5190 WMITLV_SET_HDR(&cmd->tlv_header,
5191 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5192 WMITLV_GET_STRUCT_TLVLEN
5193 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5194
5195
5196 cmd->vdev_id = vdev_id;
5197 cmd->sa_query_max_retry_count = max_retries;
5198 cmd->sa_query_retry_interval = retry_interval;
5199
Govind Singhb53420c2016-03-09 14:32:57 +05305200 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305201 vdev_id, retry_interval, max_retries);
5202
5203 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5204 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305205 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305206 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305207 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305208 }
5209
Govind Singhb53420c2016-03-09 14:32:57 +05305210 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305211 return 0;
5212}
5213
5214/**
5215 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5216 * @wmi_handle: wmi handle
5217 * @params: sta keep alive parameter
5218 *
5219 * This function sets keep alive related parameters in fw.
5220 *
5221 * Return: CDF status
5222 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305223static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305224 struct sta_params *params)
5225{
5226 wmi_buf_t buf;
5227 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5228 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5229 uint8_t *buf_ptr;
5230 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305231 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232
Govind Singhb53420c2016-03-09 14:32:57 +05305233 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234
Govind Singh4eacd2b2016-03-07 14:24:22 +05305235 len = sizeof(*cmd) + sizeof(*arp_rsp);
5236 buf = wmi_buf_alloc(wmi_handle, len);
5237 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305238 WMI_LOGE("wmi_buf_alloc failed");
5239 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 }
5241
5242 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5243 buf_ptr = (uint8_t *) cmd;
5244 WMITLV_SET_HDR(&cmd->tlv_header,
5245 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5246 WMITLV_GET_STRUCT_TLVLEN
5247 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5248 cmd->interval = params->timeperiod;
5249 cmd->enable = (params->timeperiod) ? 1 : 0;
5250 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305251 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305252 params->timeperiod, params->method);
5253 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5254 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5255 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5256 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5257
c_manjee2772b9c2017-01-23 15:14:13 +05305258 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5259 (params->method ==
5260 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 if ((NULL == params->hostv4addr) ||
5262 (NULL == params->destv4addr) ||
5263 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005264 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5265 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305266 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305267 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305268 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305269 }
c_manjee2772b9c2017-01-23 15:14:13 +05305270 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305271 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305272 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305273 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305274 WMI_IPV4_ADDR_LEN);
5275 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5276 } else {
5277 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5278 }
5279
Govind Singh67922e82016-04-01 16:48:57 +05305280 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5281 WMI_STA_KEEPALIVE_CMDID);
5282 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305283 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305284 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305285 }
5286
Govind Singhb53420c2016-03-09 14:32:57 +05305287 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305288 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305289}
5290
5291/**
5292 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5293 * @wmi_handle: wmi handle
5294 * @if_id: vdev id
5295 * @gtx_info: GTX config params
5296 *
5297 * This function set GTX related params in firmware.
5298 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305299 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305300 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305301static 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 +05305302 struct wmi_gtx_config *gtx_info)
5303{
5304 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5305 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305306 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305308
Govind Singh4eacd2b2016-03-07 14:24:22 +05305309 buf = wmi_buf_alloc(wmi_handle, len);
5310 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305311 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305312 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305313 }
5314 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5315 WMITLV_SET_HDR(&cmd->tlv_header,
5316 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5317 WMITLV_GET_STRUCT_TLVLEN
5318 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5319 cmd->vdev_id = if_id;
5320
5321 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5322 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5323 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5324 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5325 cmd->gtxPERMargin = gtx_info->gtx_margin;
5326 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5327 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5328 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5329
Govind Singhb53420c2016-03-09 14:32:57 +05305330 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305331 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5332 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5333 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5334 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5335
Abhishek Singh716c46c2016-05-04 16:24:07 +05305336 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305337 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305338 if (QDF_IS_STATUS_ERROR(ret)) {
5339 WMI_LOGE("Failed to set GTX PARAMS");
5340 wmi_buf_free(buf);
5341 }
5342 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305343}
5344
5345/**
5346 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5347 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305348 * @vdev_id: vdev id.
5349 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305350 *
5351 * This function updates EDCA parameters to the target
5352 *
5353 * Return: CDF Status
5354 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305355static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005356 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305357 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305358{
5359 uint8_t *buf_ptr;
5360 wmi_buf_t buf;
5361 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305362 wmi_wmm_vparams *wmm_param;
5363 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305364 int len = sizeof(*cmd);
5365 int ac;
5366
5367 buf = wmi_buf_alloc(wmi_handle, len);
5368
5369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305370 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5371 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305372 }
5373
5374 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5375 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5376 WMITLV_SET_HDR(&cmd->tlv_header,
5377 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5378 WMITLV_GET_STRUCT_TLVLEN
5379 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5380 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005381 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305382
5383 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5384 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305385 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305386 WMITLV_SET_HDR(&wmm_param->tlv_header,
5387 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5388 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5389 wmm_param->cwmin = twmm_param->cwmin;
5390 wmm_param->cwmax = twmm_param->cwmax;
5391 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005392 if (mu_edca_param)
5393 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5394 else
5395 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305396 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305397 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305398 }
5399
5400 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5401 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5402 goto fail;
5403
Govind Singhb53420c2016-03-09 14:32:57 +05305404 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305405
5406fail:
5407 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305408 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5409 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305410}
5411
5412/**
5413 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5414 * @wmi_handle: wmi handle
5415 * @vdev_id: vdev id
5416 * @probe_rsp_info: probe response info
5417 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305418 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305419 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305420static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305421 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005422 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305423{
5424 wmi_prb_tmpl_cmd_fixed_param *cmd;
5425 wmi_bcn_prb_info *bcn_prb_info;
5426 wmi_buf_t wmi_buf;
5427 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5428 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305429 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305430
Govind Singhb53420c2016-03-09 14:32:57 +05305431 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305432
Krunal Soni89426862017-11-14 15:42:48 -08005433 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305434 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305435
5436 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5437 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5438 tmpl_len_aligned;
5439
5440 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305441 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305442 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305443 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305444 }
5445
5446 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5447 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305448 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305449 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305450 }
5451
5452 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5453
5454 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5455 WMITLV_SET_HDR(&cmd->tlv_header,
5456 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5457 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5458 cmd->vdev_id = vdev_id;
5459 cmd->buf_len = tmpl_len;
5460 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5461
5462 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5463 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5464 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5465 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5466 bcn_prb_info->caps = 0;
5467 bcn_prb_info->erp = 0;
5468 buf_ptr += sizeof(wmi_bcn_prb_info);
5469
5470 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5471 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005472 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305473
5474 ret = wmi_unified_cmd_send(wmi_handle,
5475 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305476 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305477 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305478 wmi_buf_free(wmi_buf);
5479 }
5480
5481 return ret;
5482}
5483
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305484#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305485#define WPI_IV_LEN 16
5486
5487/**
5488 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5489 *
5490 * @dest_tx: destination address of tsc key counter
5491 * @src_tx: source address of tsc key counter
5492 * @dest_rx: destination address of rsc key counter
5493 * @src_rx: source address of rsc key counter
5494 *
5495 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5496 *
5497 * Return: None
5498 *
5499 */
5500static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5501 uint8_t *dest_rx, uint8_t *src_rx)
5502{
5503 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5504 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5505}
5506#else
5507static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5508 uint8_t *dest_rx, uint8_t *src_rx)
5509{
5510 return;
5511}
5512#endif
5513
5514/**
5515 * send_setup_install_key_cmd_tlv() - set key parameters
5516 * @wmi_handle: wmi handle
5517 * @key_params: key parameters
5518 *
5519 * This function fills structure from information
5520 * passed in key_params.
5521 *
5522 * Return: QDF_STATUS_SUCCESS - success
5523 * QDF_STATUS_E_FAILURE - failure
5524 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5525 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305526static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305527 struct set_key_params *key_params)
5528{
5529 wmi_vdev_install_key_cmd_fixed_param *cmd;
5530 wmi_buf_t buf;
5531 uint8_t *buf_ptr;
5532 uint32_t len;
5533 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305534 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305535
5536 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5537 WMI_TLV_HDR_SIZE;
5538
5539 buf = wmi_buf_alloc(wmi_handle, len);
5540 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305541 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305542 return QDF_STATUS_E_NOMEM;
5543 }
5544
5545 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5546 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5547 WMITLV_SET_HDR(&cmd->tlv_header,
5548 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5549 WMITLV_GET_STRUCT_TLVLEN
5550 (wmi_vdev_install_key_cmd_fixed_param));
5551 cmd->vdev_id = key_params->vdev_id;
5552 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305553
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305554
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305555 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5556 cmd->key_flags |= key_params->key_flags;
5557 cmd->key_cipher = key_params->key_cipher;
5558 if ((key_params->key_txmic_len) &&
5559 (key_params->key_rxmic_len)) {
5560 cmd->key_txmic_len = key_params->key_txmic_len;
5561 cmd->key_rxmic_len = key_params->key_rxmic_len;
5562 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305563#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305564 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5565 key_params->tx_iv,
5566 cmd->wpi_key_rsc_counter,
5567 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305568#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305569 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5570 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5571 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305572 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305573 qdf_mem_copy((void *)key_data,
5574 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005575 if (key_params->key_rsc_counter)
5576 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5577 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305578 cmd->key_len = key_params->key_len;
5579
5580 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5581 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305582 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305583 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305584
Govind Singh67922e82016-04-01 16:48:57 +05305585 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305586}
5587
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305588/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005589 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5590 * @wmi_handle: wmi handle
5591 * @params: sar limit params
5592 *
5593 * Return: QDF_STATUS_SUCCESS for success or error code
5594 */
5595static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5596 struct sar_limit_cmd_params *sar_limit_params)
5597{
5598 wmi_buf_t buf;
5599 QDF_STATUS qdf_status;
5600 wmi_sar_limits_cmd_fixed_param *cmd;
5601 int i;
5602 uint8_t *buf_ptr;
5603 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5604 struct sar_limit_cmd_row *sar_rows_list;
5605 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5606
5607 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5608 buf = wmi_buf_alloc(wmi_handle, len);
5609 if (!buf) {
5610 WMI_LOGE("Failed to allocate memory");
5611 qdf_status = QDF_STATUS_E_NOMEM;
5612 goto end;
5613 }
5614
5615 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5616 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5617 WMITLV_SET_HDR(&cmd->tlv_header,
5618 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5619 WMITLV_GET_STRUCT_TLVLEN
5620 (wmi_sar_limits_cmd_fixed_param));
5621 cmd->sar_enable = sar_limit_params->sar_enable;
5622 cmd->commit_limits = sar_limit_params->commit_limits;
5623 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5624
5625 WMI_LOGD("no of sar rows = %d, len = %d",
5626 sar_limit_params->num_limit_rows, len);
5627 buf_ptr += sizeof(*cmd);
5628 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5629 sizeof(wmi_sar_limit_cmd_row) *
5630 sar_limit_params->num_limit_rows);
5631 if (cmd->num_limit_rows == 0)
5632 goto send_sar_limits;
5633
5634 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5635 (buf_ptr + WMI_TLV_HDR_SIZE);
5636 sar_rows_list = sar_limit_params->sar_limit_row_list;
5637
5638 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5639 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5640 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5641 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5642 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5643 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5644 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5645 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5646 wmi_sar_rows_list->validity_bitmap =
5647 sar_rows_list->validity_bitmap;
5648 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5649 i, wmi_sar_rows_list->band_id,
5650 wmi_sar_rows_list->chain_id,
5651 wmi_sar_rows_list->mod_id,
5652 wmi_sar_rows_list->limit_value,
5653 wmi_sar_rows_list->validity_bitmap);
5654 sar_rows_list++;
5655 wmi_sar_rows_list++;
5656 }
5657send_sar_limits:
5658 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5659 WMI_SAR_LIMITS_CMDID);
5660
5661 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5662 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5663 wmi_buf_free(buf);
5664 }
5665
5666end:
5667 return qdf_status;
5668}
5669
Jeff Johnson4783f902017-12-14 15:50:16 -08005670static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5671{
5672 wmi_sar_get_limits_cmd_fixed_param *cmd;
5673 wmi_buf_t wmi_buf;
5674 uint32_t len;
5675 QDF_STATUS status;
5676
5677 WMI_LOGD(FL("Enter"));
5678
5679 len = sizeof(*cmd);
5680 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5681 if (!wmi_buf) {
5682 WMI_LOGP(FL("failed to allocate memory for msg"));
5683 return QDF_STATUS_E_NOMEM;
5684 }
5685
5686 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5687
5688 WMITLV_SET_HDR(&cmd->tlv_header,
5689 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5690 WMITLV_GET_STRUCT_TLVLEN
5691 (wmi_sar_get_limits_cmd_fixed_param));
5692
5693 cmd->reserved = 0;
5694
5695 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5696 WMI_SAR_GET_LIMITS_CMDID);
5697 if (QDF_IS_STATUS_ERROR(status)) {
5698 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5699 wmi_buf_free(wmi_buf);
5700 }
5701
5702 WMI_LOGD(FL("Exit"));
5703
5704 return status;
5705}
5706
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005707/**
5708 * wmi_sar2_result_string() - return string conversion of sar2 result
5709 * @result: sar2 result value
5710 *
5711 * This utility function helps log string conversion of sar2 result.
5712 *
5713 * Return: string conversion of sar 2 result, if match found;
5714 * "Unknown response" otherwise.
5715 */
5716static const char *wmi_sar2_result_string(uint32_t result)
5717{
5718 switch (result) {
5719 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5720 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5721 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5722 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5723 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5724 default:
5725 return "Unknown response";
5726 }
5727}
5728
5729/**
5730 * extract_sar2_result_event_tlv() - process sar response event from FW.
5731 * @handle: wma handle
5732 * @event: event buffer
5733 * @len: buffer length
5734 *
5735 * Return: 0 for success or error code
5736 */
5737static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5738 uint8_t *event,
5739 uint32_t len)
5740{
5741 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5742
5743 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5744 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5745
5746 if (!param_buf) {
5747 WMI_LOGI("Invalid sar2 result event buffer");
5748 return QDF_STATUS_E_INVAL;
5749 }
5750
5751 sar2_fixed_param = param_buf->fixed_param;
5752 if (!sar2_fixed_param) {
5753 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5754 return QDF_STATUS_E_INVAL;
5755 }
5756
5757 WMI_LOGI("SAR2 result: %s",
5758 wmi_sar2_result_string(sar2_fixed_param->result));
5759
5760 return QDF_STATUS_SUCCESS;
5761}
5762
Jeff Johnson4783f902017-12-14 15:50:16 -08005763static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5764 uint8_t *evt_buf,
5765 struct sar_limit_event *event)
5766{
5767 wmi_sar_get_limits_event_fixed_param *fixed_param;
5768 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5769 wmi_sar_get_limit_event_row *row_in;
5770 struct sar_limit_event_row *row_out;
5771 uint32_t row;
5772
5773 if (!evt_buf) {
5774 WMI_LOGE(FL("input event is NULL"));
5775 return QDF_STATUS_E_INVAL;
5776 }
5777 if (!event) {
5778 WMI_LOGE(FL("output event is NULL"));
5779 return QDF_STATUS_E_INVAL;
5780 }
5781
5782 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5783
5784 fixed_param = param_buf->fixed_param;
5785 if (!fixed_param) {
5786 WMI_LOGE(FL("Invalid fixed param"));
5787 return QDF_STATUS_E_INVAL;
5788 }
5789
5790 event->sar_enable = fixed_param->sar_enable;
5791 event->num_limit_rows = fixed_param->num_limit_rows;
5792
5793 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5794 QDF_ASSERT(0);
5795 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5796 event->num_limit_rows,
5797 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5798 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5799 }
5800
5801 row_in = param_buf->sar_get_limits;
5802 row_out = &event->sar_limit_row[0];
5803 for (row = 0; row < event->num_limit_rows; row++) {
5804 row_out->band_id = row_in->band_id;
5805 row_out->chain_id = row_in->chain_id;
5806 row_out->mod_id = row_in->mod_id;
5807 row_out->limit_value = row_in->limit_value;
5808 row_out++;
5809 row_in++;
5810 }
5811
5812 return QDF_STATUS_SUCCESS;
5813}
5814
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305815#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005816/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305817 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5818 * @wmi_handle: wmi handle
5819 * @params: encrypt/decrypt params
5820 *
5821 * Return: QDF_STATUS_SUCCESS for success or error code
5822 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005823static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305824QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305825 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305826{
5827 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5828 wmi_buf_t wmi_buf;
5829 uint8_t *buf_ptr;
5830 QDF_STATUS ret;
5831 uint32_t len;
5832
5833 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5834
5835 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305836 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305837 WMI_TLV_HDR_SIZE;
5838 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5839 if (!wmi_buf) {
5840 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5841 __func__);
5842 return QDF_STATUS_E_NOMEM;
5843 }
5844
5845 buf_ptr = wmi_buf_data(wmi_buf);
5846 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5847
5848 WMITLV_SET_HDR(&cmd->tlv_header,
5849 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5850 WMITLV_GET_STRUCT_TLVLEN(
5851 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5852
5853 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5854 cmd->key_flag = encrypt_decrypt_params->key_flag;
5855 cmd->key_idx = encrypt_decrypt_params->key_idx;
5856 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5857 cmd->key_len = encrypt_decrypt_params->key_len;
5858 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5859 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5860
5861 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5862 encrypt_decrypt_params->key_len);
5863
5864 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5865 MAX_MAC_HEADER_LEN);
5866
5867 cmd->data_len = encrypt_decrypt_params->data_len;
5868
5869 if (cmd->data_len) {
5870 buf_ptr += sizeof(*cmd);
5871 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5872 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305873 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305874 buf_ptr += WMI_TLV_HDR_SIZE;
5875 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5876 encrypt_decrypt_params->data_len);
5877 }
5878
5879 /* This conversion is to facilitate data to FW in little endian */
5880 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5881 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5882 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5883 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5884 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5885 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5886
5887 ret = wmi_unified_cmd_send(wmi_handle,
5888 wmi_buf, len,
5889 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5890 if (QDF_IS_STATUS_ERROR(ret)) {
5891 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5892 wmi_buf_free(wmi_buf);
5893 }
5894
5895 return ret;
5896}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305897
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305898/**
5899 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5900 * params from event
5901 * @wmi_handle: wmi handle
5902 * @evt_buf: pointer to event buffer
5903 * @resp: Pointer to hold resp parameters
5904 *
5905 * Return: QDF_STATUS_SUCCESS for success or error code
5906 */
5907static
5908QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5909 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5910{
5911 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5912 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5913
5914 param_buf = evt_buf;
5915 if (!param_buf) {
5916 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5917 return QDF_STATUS_E_INVAL;
5918 }
5919
5920 data_event = param_buf->fixed_param;
5921
5922 resp->vdev_id = data_event->vdev_id;
5923 resp->status = data_event->status;
5924
Yeshwanth Sriram Guntukaa79e7f22018-06-22 18:25:45 +05305925 if ((data_event->data_length > param_buf->num_enc80211_frame) ||
5926 (data_event->data_length > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE -
5927 sizeof(*data_event))) {
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305928 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5929 data_event->data_length,
5930 param_buf->num_enc80211_frame);
5931 return QDF_STATUS_E_INVAL;
5932 }
5933
5934 resp->data_len = data_event->data_length;
5935
5936 if (resp->data_len)
5937 resp->data = (uint8_t *)param_buf->enc80211_frame;
5938
5939 return QDF_STATUS_SUCCESS;
5940}
5941#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305942
Govind Singh4eacd2b2016-03-07 14:24:22 +05305943/**
5944 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5945 * @wmi_handle: wmi handle
5946 * @vdev_id: vdev id
5947 * @p2p_ie: p2p IE
5948 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305949 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305951static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305952 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305953{
Govind Singh67922e82016-04-01 16:48:57 +05305954 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305955 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5956 wmi_buf_t wmi_buf;
5957 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5958 uint8_t *buf_ptr;
5959
5960 ie_len = (uint32_t) (p2p_ie[1] + 2);
5961
5962 /* More than one P2P IE may be included in a single frame.
5963 If multiple P2P IEs are present, the complete P2P attribute
5964 data consists of the concatenation of the P2P Attribute
5965 fields of the P2P IEs. The P2P Attributes field of each
5966 P2P IE may be any length up to the maximum (251 octets).
5967 In this case host sends one P2P IE to firmware so the length
5968 should not exceed more than 251 bytes
5969 */
5970 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305971 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305972 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305973 }
5974
Vivekc5823092018-03-22 23:27:21 +05305975 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305976
5977 wmi_buf_len =
5978 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5979 WMI_TLV_HDR_SIZE;
5980
5981 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5982 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305983 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305984 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305985 }
5986
5987 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5988
5989 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5990 WMITLV_SET_HDR(&cmd->tlv_header,
5991 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5992 WMITLV_GET_STRUCT_TLVLEN
5993 (wmi_p2p_go_set_beacon_ie_fixed_param));
5994 cmd->vdev_id = vdev_id;
5995 cmd->ie_buf_len = ie_len;
5996
5997 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5999 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05306000 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306001
Govind Singhb53420c2016-03-09 14:32:57 +05306002 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306003
6004 ret = wmi_unified_cmd_send(wmi_handle,
6005 wmi_buf, wmi_buf_len,
6006 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05306007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306008 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306009 wmi_buf_free(wmi_buf);
6010 }
6011
Govind Singhb53420c2016-03-09 14:32:57 +05306012 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 return ret;
6014}
6015
6016/**
6017 * send_set_gateway_params_cmd_tlv() - set gateway parameters
6018 * @wmi_handle: wmi handle
6019 * @req: gateway parameter update request structure
6020 *
6021 * This function reads the incoming @req and fill in the destination
6022 * WMI structure and sends down the gateway configs down to the firmware
6023 *
Govind Singhb53420c2016-03-09 14:32:57 +05306024 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05306025 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306026static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306027 struct gateway_update_req_param *req)
6028{
6029 wmi_roam_subnet_change_config_fixed_param *cmd;
6030 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306031 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306032 int len = sizeof(*cmd);
6033
6034 buf = wmi_buf_alloc(wmi_handle, len);
6035 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306036 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6037 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306038 }
6039
6040 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6041 WMITLV_SET_HDR(&cmd->tlv_header,
6042 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6043 WMITLV_GET_STRUCT_TLVLEN(
6044 wmi_roam_subnet_change_config_fixed_param));
6045
6046 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306047 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6048 QDF_IPV4_ADDR_SIZE);
6049 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6050 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306051 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6052 &cmd->inet_gw_mac_addr);
6053 cmd->max_retries = req->max_retries;
6054 cmd->timeout = req->timeout;
6055 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6056 cmd->flag = 0;
6057 if (req->ipv4_addr_type)
6058 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6059
6060 if (req->ipv6_addr_type)
6061 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6062
6063 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6064 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306065 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306066 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306067 ret);
6068 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306069 }
6070
Govind Singh67922e82016-04-01 16:48:57 +05306071 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306072}
6073
6074/**
6075 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6076 * @wmi_handle: wmi handle
6077 * @req: rssi monitoring request structure
6078 *
6079 * This function reads the incoming @req and fill in the destination
6080 * WMI structure and send down the rssi monitoring configs down to the firmware
6081 *
6082 * Return: 0 on success; error number otherwise
6083 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306084static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306085 struct rssi_monitor_param *req)
6086{
6087 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6088 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306089 QDF_STATUS ret;
6090 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306091
6092 buf = wmi_buf_alloc(wmi_handle, len);
6093 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306094 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6095 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306096 }
6097
6098 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6099 WMITLV_SET_HDR(&cmd->tlv_header,
6100 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6101 WMITLV_GET_STRUCT_TLVLEN(
6102 wmi_rssi_breach_monitor_config_fixed_param));
6103
6104 cmd->vdev_id = req->session_id;
6105 cmd->request_id = req->request_id;
6106 cmd->lo_rssi_reenable_hysteresis = 0;
6107 cmd->hi_rssi_reenable_histeresis = 0;
6108 cmd->min_report_interval = 0;
6109 cmd->max_num_report = 1;
6110 if (req->control) {
6111 /* enable one threshold for each min/max */
6112 cmd->enabled_bitmap = 0x09;
6113 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6114 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6115 } else {
6116 cmd->enabled_bitmap = 0;
6117 cmd->low_rssi_breach_threshold[0] = 0;
6118 cmd->hi_rssi_breach_threshold[0] = 0;
6119 }
6120
6121 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6122 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306123 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306124 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306125 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306126 }
6127
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006128 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6129
Govind Singh67922e82016-04-01 16:48:57 +05306130 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306131}
6132
6133/**
6134 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6135 * @wmi_handle: wmi handle
6136 * @psetoui: OUI parameters
6137 *
6138 * set scan probe OUI parameters in firmware
6139 *
6140 * Return: CDF status
6141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306142static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306143 struct scan_mac_oui *psetoui)
6144{
6145 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6146 wmi_buf_t wmi_buf;
6147 uint32_t len;
6148 uint8_t *buf_ptr;
6149 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306150 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306151
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306152 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6153 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6154
Govind Singh4eacd2b2016-03-07 14:24:22 +05306155 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6156 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306157 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6158 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306159 }
6160 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6161 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6162 WMITLV_SET_HDR(&cmd->tlv_header,
6163 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6164 WMITLV_GET_STRUCT_TLVLEN
6165 (wmi_scan_prob_req_oui_cmd_fixed_param));
6166
6167 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306168 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306169 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6170 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306171 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306172 cmd->prob_req_oui);
6173
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306174 cmd->vdev_id = psetoui->vdev_id;
6175 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6176 if (psetoui->enb_probe_req_sno_randomization)
6177 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6178
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306179 if (ie_whitelist->white_list) {
6180 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6181 &cmd->num_vendor_oui,
6182 ie_whitelist);
6183 cmd->flags |=
6184 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6185 }
6186
6187 buf_ptr += sizeof(*cmd);
6188 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6189 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6190 buf_ptr += WMI_TLV_HDR_SIZE;
6191
6192 if (cmd->num_vendor_oui != 0) {
6193 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6194 ie_whitelist->voui);
6195 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6196 }
6197
Govind Singh4eacd2b2016-03-07 14:24:22 +05306198 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6199 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306200 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306201 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306202 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306203 }
Govind Singhb53420c2016-03-09 14:32:57 +05306204 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306205}
6206
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306207#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306208/**
6209 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6210 * @wmi_handle: wmi handle
6211 * @roam_req: Roam scan offload params
6212 * @buf_ptr: command buffer to send
6213 * @fils_tlv_len: fils tlv length
6214 *
6215 * Return: Updated buffer pointer
6216 */
6217static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6218 struct roam_offload_scan_params *roam_req,
6219 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6220{
6221 wmi_roam_fils_offload_tlv_param *fils_tlv;
6222 wmi_erp_info *erp_info;
6223 struct roam_fils_params *roam_fils_params;
6224
6225 if (!roam_req->add_fils_tlv)
6226 return buf_ptr;
6227
6228 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6229 sizeof(*fils_tlv));
6230 buf_ptr += WMI_TLV_HDR_SIZE;
6231
6232 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6233 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6234 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6235 WMITLV_GET_STRUCT_TLVLEN
6236 (wmi_roam_fils_offload_tlv_param));
6237
6238 roam_fils_params = &roam_req->roam_fils_params;
6239 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6240
6241 erp_info->username_length = roam_fils_params->username_length;
6242 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6243 erp_info->username_length);
6244
6245 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6246
6247 erp_info->rRk_length = roam_fils_params->rrk_length;
6248 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6249 erp_info->rRk_length);
6250
6251 erp_info->rIk_length = roam_fils_params->rik_length;
6252 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6253 erp_info->rIk_length);
6254
6255 erp_info->realm_len = roam_fils_params->realm_len;
6256 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6257 erp_info->realm_len);
6258
6259 buf_ptr += sizeof(*fils_tlv);
6260 return buf_ptr;
6261}
6262#else
6263static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6264 struct roam_offload_scan_params *roam_req,
6265 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6266{
6267 return buf_ptr;
6268}
6269#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306270/**
6271 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6272 * @wmi_handle: wmi handle
6273 * @scan_cmd_fp: start scan command ptr
6274 * @roam_req: roam request param
6275 *
6276 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6277 * of WMI_ROAM_SCAN_MODE.
6278 *
6279 * Return: QDF status
6280 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306281static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306282 wmi_start_scan_cmd_fixed_param *
6283 scan_cmd_fp,
6284 struct roam_offload_scan_params *roam_req)
6285{
6286 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306287 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306288 int len;
6289 uint8_t *buf_ptr;
6290 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306291
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306292#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6293 int auth_mode = roam_req->auth_mode;
6294 wmi_roam_offload_tlv_param *roam_offload_params;
6295 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6296 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6297 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306298 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306299 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306300#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6301 /* Need to create a buf with roam_scan command at
6302 * front and piggyback with scan command */
6303 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6304#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6305 (2 * WMI_TLV_HDR_SIZE) +
6306#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6307 sizeof(wmi_start_scan_cmd_fixed_param);
6308#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006309 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306310 if (roam_req->is_roam_req_valid &&
6311 roam_req->roam_offload_enabled) {
6312 len += sizeof(wmi_roam_offload_tlv_param);
6313 len += WMI_TLV_HDR_SIZE;
6314 if ((auth_mode != WMI_AUTH_NONE) &&
6315 ((auth_mode != WMI_AUTH_OPEN) ||
6316 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306317 roam_req->mdid.mdie_present &&
6318 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306319 roam_req->is_ese_assoc)) {
6320 len += WMI_TLV_HDR_SIZE;
6321 if (roam_req->is_ese_assoc)
6322 len +=
6323 sizeof(wmi_roam_ese_offload_tlv_param);
6324 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6325 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6326 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306327 roam_req->mdid.mdie_present &&
6328 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306329 len +=
6330 sizeof(wmi_roam_11r_offload_tlv_param);
6331 else
6332 len +=
6333 sizeof(wmi_roam_11i_offload_tlv_param);
6334 } else {
6335 len += WMI_TLV_HDR_SIZE;
6336 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306337
6338 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6339 + roundup(roam_req->assoc_ie_length,
6340 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306341
6342 if (roam_req->add_fils_tlv) {
6343 fils_tlv_len = sizeof(
6344 wmi_roam_fils_offload_tlv_param);
6345 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6346 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306347 } else {
6348 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306349 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306350 __func__, roam_req->roam_offload_enabled);
6351 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306352 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306353 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306354 }
6355 if (roam_req->is_roam_req_valid &&
6356 roam_req->roam_offload_enabled) {
6357 roam_req->mode = roam_req->mode |
6358 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6359 }
6360#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6361
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306362 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6363 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6364 len = sizeof(wmi_roam_scan_mode_fixed_param);
6365
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306366 buf = wmi_buf_alloc(wmi_handle, len);
6367 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306368 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306369 return QDF_STATUS_E_NOMEM;
6370 }
6371
6372 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6373 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6374 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6375 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6376 WMITLV_GET_STRUCT_TLVLEN
6377 (wmi_roam_scan_mode_fixed_param));
6378
Abhinav Kumar334355f2018-04-06 17:18:52 +05306379 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6380 roam_req->roam_trigger_reason_bitmask;
6381 roam_scan_mode_fp->min_delay_btw_scans =
6382 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306383 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6384 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306385 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6386 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6387 roam_scan_mode_fp->flags |=
6388 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306389 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306390 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306391
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306392 /* Fill in scan parameters suitable for roaming scan */
6393 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306394
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306395 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6396 sizeof(wmi_start_scan_cmd_fixed_param));
6397 /* Ensure there is no additional IEs */
6398 scan_cmd_fp->ie_len = 0;
6399 WMITLV_SET_HDR(buf_ptr,
6400 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6401 WMITLV_GET_STRUCT_TLVLEN
6402 (wmi_start_scan_cmd_fixed_param));
6403#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6404 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6405 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6406 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6407 sizeof(wmi_roam_offload_tlv_param));
6408 buf_ptr += WMI_TLV_HDR_SIZE;
6409 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6410 WMITLV_SET_HDR(buf_ptr,
6411 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6412 WMITLV_GET_STRUCT_TLVLEN
6413 (wmi_roam_offload_tlv_param));
6414 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6415 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6416 roam_offload_params->select_5g_margin =
6417 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306418 roam_offload_params->handoff_delay_for_rx =
6419 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306420 roam_offload_params->reassoc_failure_timeout =
6421 roam_req->reassoc_failure_timeout;
6422
6423 /* Fill the capabilities */
6424 roam_offload_params->capability =
6425 roam_req->roam_offload_params.capability;
6426 roam_offload_params->ht_caps_info =
6427 roam_req->roam_offload_params.ht_caps_info;
6428 roam_offload_params->ampdu_param =
6429 roam_req->roam_offload_params.ampdu_param;
6430 roam_offload_params->ht_ext_cap =
6431 roam_req->roam_offload_params.ht_ext_cap;
6432 roam_offload_params->ht_txbf =
6433 roam_req->roam_offload_params.ht_txbf;
6434 roam_offload_params->asel_cap =
6435 roam_req->roam_offload_params.asel_cap;
6436 roam_offload_params->qos_caps =
6437 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006438 roam_offload_params->qos_enabled =
6439 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306440 roam_offload_params->wmm_caps =
6441 roam_req->roam_offload_params.wmm_caps;
6442 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6443 (uint8_t *)roam_req->roam_offload_params.mcsset,
6444 ROAM_OFFLOAD_NUM_MCS_SET);
6445
6446 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6447 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6448 * they are filled in the same order.Depending on the
6449 * authentication type, the other mode TLV's are nullified
6450 * and only headers are filled.*/
6451 if ((auth_mode != WMI_AUTH_NONE) &&
6452 ((auth_mode != WMI_AUTH_OPEN) ||
6453 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306454 && roam_req->mdid.mdie_present &&
6455 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306456 roam_req->is_ese_assoc)) {
6457 if (roam_req->is_ese_assoc) {
6458 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6459 WMITLV_GET_STRUCT_TLVLEN(0));
6460 buf_ptr += WMI_TLV_HDR_SIZE;
6461 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6462 WMITLV_GET_STRUCT_TLVLEN(0));
6463 buf_ptr += WMI_TLV_HDR_SIZE;
6464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6465 sizeof(wmi_roam_ese_offload_tlv_param));
6466 buf_ptr += WMI_TLV_HDR_SIZE;
6467 roam_offload_ese =
6468 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6469 qdf_mem_copy(roam_offload_ese->krk,
6470 roam_req->krk,
6471 sizeof(roam_req->krk));
6472 qdf_mem_copy(roam_offload_ese->btk,
6473 roam_req->btk,
6474 sizeof(roam_req->btk));
6475 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6476 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6477 WMITLV_GET_STRUCT_TLVLEN
6478 (wmi_roam_ese_offload_tlv_param));
6479 buf_ptr +=
6480 sizeof(wmi_roam_ese_offload_tlv_param);
6481 } else if (auth_mode == WMI_AUTH_FT_RSNA
6482 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6483 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306484 && roam_req->mdid.mdie_present &&
6485 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306486 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6487 0);
6488 buf_ptr += WMI_TLV_HDR_SIZE;
6489 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6490 sizeof(wmi_roam_11r_offload_tlv_param));
6491 buf_ptr += WMI_TLV_HDR_SIZE;
6492 roam_offload_11r =
6493 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6494 roam_offload_11r->r0kh_id_len =
6495 roam_req->rokh_id_length;
6496 qdf_mem_copy(roam_offload_11r->r0kh_id,
6497 roam_req->rokh_id,
6498 roam_offload_11r->r0kh_id_len);
6499 qdf_mem_copy(roam_offload_11r->psk_msk,
6500 roam_req->psk_pmk,
6501 sizeof(roam_req->psk_pmk));
6502 roam_offload_11r->psk_msk_len =
6503 roam_req->pmk_len;
6504 roam_offload_11r->mdie_present =
6505 roam_req->mdid.mdie_present;
6506 roam_offload_11r->mdid =
6507 roam_req->mdid.mobility_domain;
6508 if (auth_mode == WMI_AUTH_OPEN) {
6509 /* If FT-Open ensure pmk length
6510 and r0khid len are zero */
6511 roam_offload_11r->r0kh_id_len = 0;
6512 roam_offload_11r->psk_msk_len = 0;
6513 }
6514 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6515 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6516 WMITLV_GET_STRUCT_TLVLEN
6517 (wmi_roam_11r_offload_tlv_param));
6518 buf_ptr +=
6519 sizeof(wmi_roam_11r_offload_tlv_param);
6520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6521 WMITLV_GET_STRUCT_TLVLEN(0));
6522 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006523 WMI_LOGD("psk_msk_len = %d",
6524 roam_offload_11r->psk_msk_len);
6525 if (roam_offload_11r->psk_msk_len)
6526 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6527 QDF_TRACE_LEVEL_DEBUG,
6528 roam_offload_11r->psk_msk,
6529 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306530 } else {
6531 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6532 sizeof(wmi_roam_11i_offload_tlv_param));
6533 buf_ptr += WMI_TLV_HDR_SIZE;
6534 roam_offload_11i =
6535 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006536
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006537 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006538 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306539 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6540 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006541 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306542 } else {
6543 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6544 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006545 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006546 }
6547 if (roam_req->roam_key_mgmt_offload_enabled &&
6548 roam_req->fw_pmksa_cache) {
6549 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6550 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006551 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006552 } else {
6553 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6554 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006555 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306556 }
6557
6558 qdf_mem_copy(roam_offload_11i->pmk,
6559 roam_req->psk_pmk,
6560 sizeof(roam_req->psk_pmk));
6561 roam_offload_11i->pmk_len = roam_req->pmk_len;
6562 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6563 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6564 WMITLV_GET_STRUCT_TLVLEN
6565 (wmi_roam_11i_offload_tlv_param));
6566 buf_ptr +=
6567 sizeof(wmi_roam_11i_offload_tlv_param);
6568 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6569 0);
6570 buf_ptr += WMI_TLV_HDR_SIZE;
6571 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6572 0);
6573 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006574 WMI_LOGD("pmk_len = %d",
6575 roam_offload_11i->pmk_len);
6576 if (roam_offload_11i->pmk_len)
6577 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6578 QDF_TRACE_LEVEL_DEBUG,
6579 roam_offload_11i->pmk,
6580 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306581 }
6582 } else {
6583 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6584 WMITLV_GET_STRUCT_TLVLEN(0));
6585 buf_ptr += WMI_TLV_HDR_SIZE;
6586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6587 WMITLV_GET_STRUCT_TLVLEN(0));
6588 buf_ptr += WMI_TLV_HDR_SIZE;
6589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6590 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306591 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306592 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306593
6594 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6595 sizeof(*assoc_ies));
6596 buf_ptr += WMI_TLV_HDR_SIZE;
6597
6598 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6599 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6600 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6601 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6602 assoc_ies->buf_len = roam_req->assoc_ie_length;
6603
6604 buf_ptr += sizeof(*assoc_ies);
6605
6606 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6607 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6608 buf_ptr += WMI_TLV_HDR_SIZE;
6609
6610 if (assoc_ies->buf_len != 0) {
6611 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6612 assoc_ies->buf_len);
6613 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306614 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6615 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6616 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306617 } else {
6618 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6619 WMITLV_GET_STRUCT_TLVLEN(0));
6620 buf_ptr += WMI_TLV_HDR_SIZE;
6621 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6622 WMITLV_GET_STRUCT_TLVLEN(0));
6623 buf_ptr += WMI_TLV_HDR_SIZE;
6624 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6625 WMITLV_GET_STRUCT_TLVLEN(0));
6626 buf_ptr += WMI_TLV_HDR_SIZE;
6627 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6628 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306629 buf_ptr += WMI_TLV_HDR_SIZE;
6630 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6631 WMITLV_GET_STRUCT_TLVLEN(0));
6632 buf_ptr += WMI_TLV_HDR_SIZE;
6633 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6634 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306635 }
6636#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306637
6638send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306639 status = wmi_unified_cmd_send(wmi_handle, buf,
6640 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306641 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306642 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306643 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6644 status);
6645 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306646 }
6647
Govind Singh67922e82016-04-01 16:48:57 +05306648 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306649}
6650
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006651static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6652 struct wmi_mawc_roam_params *params)
6653{
6654 wmi_buf_t buf = NULL;
6655 QDF_STATUS status;
6656 int len;
6657 uint8_t *buf_ptr;
6658 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6659
6660 len = sizeof(*wmi_roam_mawc_params);
6661 buf = wmi_buf_alloc(wmi_handle, len);
6662 if (!buf) {
6663 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6664 return QDF_STATUS_E_NOMEM;
6665 }
6666
6667 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6668 wmi_roam_mawc_params =
6669 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6670 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6671 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6672 WMITLV_GET_STRUCT_TLVLEN
6673 (wmi_roam_configure_mawc_cmd_fixed_param));
6674 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6675 if (params->enable)
6676 wmi_roam_mawc_params->enable = 1;
6677 else
6678 wmi_roam_mawc_params->enable = 0;
6679 wmi_roam_mawc_params->traffic_load_threshold =
6680 params->traffic_load_threshold;
6681 wmi_roam_mawc_params->best_ap_rssi_threshold =
6682 params->best_ap_rssi_threshold;
6683 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6684 params->rssi_stationary_high_adjust;
6685 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6686 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006687 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6688 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6689 wmi_roam_mawc_params->traffic_load_threshold,
6690 wmi_roam_mawc_params->best_ap_rssi_threshold,
6691 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6692 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006693
6694 status = wmi_unified_cmd_send(wmi_handle, buf,
6695 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6696 if (QDF_IS_STATUS_ERROR(status)) {
6697 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6698 status);
6699 wmi_buf_free(buf);
6700 return status;
6701 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006702
6703 return QDF_STATUS_SUCCESS;
6704}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306705
6706/**
6707 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6708 * rssi threashold
6709 * @wmi_handle: wmi handle
6710 * @roam_req: Roaming request buffer
6711 *
6712 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6713 *
6714 * Return: QDF status
6715 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306716static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306717 struct roam_offload_scan_rssi_params *roam_req)
6718{
6719 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306720 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306721 int len;
6722 uint8_t *buf_ptr;
6723 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6724 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6725 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306726 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006727 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306728
6729 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6730 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6731 len += sizeof(wmi_roam_scan_extended_threshold_param);
6732 len += WMI_TLV_HDR_SIZE;
6733 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306734 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6735 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006736 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6737 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306738 buf = wmi_buf_alloc(wmi_handle, len);
6739 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306740 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306741 return QDF_STATUS_E_NOMEM;
6742 }
6743
6744 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6745 rssi_threshold_fp =
6746 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6747 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6748 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6749 WMITLV_GET_STRUCT_TLVLEN
6750 (wmi_roam_scan_rssi_threshold_fixed_param));
6751 /* fill in threshold values */
6752 rssi_threshold_fp->vdev_id = roam_req->session_id;
6753 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6754 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6755 rssi_threshold_fp->hirssi_scan_max_count =
6756 roam_req->hi_rssi_scan_max_count;
6757 rssi_threshold_fp->hirssi_scan_delta =
6758 roam_req->hi_rssi_scan_rssi_delta;
6759 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006760 rssi_threshold_fp->rssi_thresh_offset_5g =
6761 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306762
6763 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6764 WMITLV_SET_HDR(buf_ptr,
6765 WMITLV_TAG_ARRAY_STRUC,
6766 sizeof(wmi_roam_scan_extended_threshold_param));
6767 buf_ptr += WMI_TLV_HDR_SIZE;
6768 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6769
6770 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6771 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6772 ext_thresholds->boost_threshold_5g =
6773 roam_req->boost_threshold_5g;
6774
6775 ext_thresholds->boost_algorithm_5g =
6776 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6777 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6778 ext_thresholds->penalty_algorithm_5g =
6779 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6780 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6781 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6782 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6783 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6784
6785 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6786 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6787 WMITLV_GET_STRUCT_TLVLEN
6788 (wmi_roam_scan_extended_threshold_param));
6789 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6790 WMITLV_SET_HDR(buf_ptr,
6791 WMITLV_TAG_ARRAY_STRUC,
6792 sizeof(wmi_roam_earlystop_rssi_thres_param));
6793 buf_ptr += WMI_TLV_HDR_SIZE;
6794 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6795 early_stop_thresholds->roam_earlystop_thres_min =
6796 roam_req->roam_earlystop_thres_min;
6797 early_stop_thresholds->roam_earlystop_thres_max =
6798 roam_req->roam_earlystop_thres_max;
6799 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6800 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6801 WMITLV_GET_STRUCT_TLVLEN
6802 (wmi_roam_earlystop_rssi_thres_param));
6803
Gupta, Kapil7e652922016-04-12 15:02:00 +05306804 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6805 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6806 sizeof(wmi_roam_dense_thres_param));
6807 buf_ptr += WMI_TLV_HDR_SIZE;
6808 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6809 dense_thresholds->roam_dense_rssi_thres_offset =
6810 roam_req->dense_rssi_thresh_offset;
6811 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6812 dense_thresholds->roam_dense_traffic_thres =
6813 roam_req->traffic_threshold;
6814 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6815 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6816 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6817 WMITLV_GET_STRUCT_TLVLEN
6818 (wmi_roam_dense_thres_param));
6819
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006820 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6822 sizeof(wmi_roam_bg_scan_roaming_param));
6823 buf_ptr += WMI_TLV_HDR_SIZE;
6824 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6825 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6826 roam_req->bg_scan_bad_rssi_thresh;
6827 bg_scan_params->roam_bg_scan_client_bitmap =
6828 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306829 bg_scan_params->bad_rssi_thresh_offset_2g =
6830 roam_req->roam_bad_rssi_thresh_offset_2g;
6831 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006832 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6833 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6834 WMITLV_GET_STRUCT_TLVLEN
6835 (wmi_roam_bg_scan_roaming_param));
6836
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306837 status = wmi_unified_cmd_send(wmi_handle, buf,
6838 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306839 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306840 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306841 status);
6842 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306843 }
6844
Govind Singh67922e82016-04-01 16:48:57 +05306845 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306846}
6847
6848/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306849 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6850 * configuration params
6851 * @wma_handle: wma handler
6852 * @dwelltime_params: pointer to dwelltime_params
6853 *
6854 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6855 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006856static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306857QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6858 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6859{
6860 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6861 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6862 wmi_buf_t buf;
6863 uint8_t *buf_ptr;
6864 int32_t err;
6865 int len;
6866
6867 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6868 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6869 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6870 buf = wmi_buf_alloc(wmi_handle, len);
6871 if (!buf) {
6872 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6873 __func__);
6874 return QDF_STATUS_E_NOMEM;
6875 }
6876 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6877 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6878 WMITLV_SET_HDR(&dwell_param->tlv_header,
6879 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6880 WMITLV_GET_STRUCT_TLVLEN
6881 (wmi_scan_adaptive_dwell_config_fixed_param));
6882
6883 dwell_param->enable = dwelltime_params->is_enabled;
6884 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6885 WMITLV_SET_HDR(buf_ptr,
6886 WMITLV_TAG_ARRAY_STRUC,
6887 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6888 buf_ptr += WMI_TLV_HDR_SIZE;
6889
6890 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6891 WMITLV_SET_HDR(&cmd->tlv_header,
6892 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6893 WMITLV_GET_STRUCT_TLVLEN(
6894 wmi_scan_adaptive_dwell_parameters_tlv));
6895
6896 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6897 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6898 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6899 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6900 err = wmi_unified_cmd_send(wmi_handle, buf,
6901 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6902 if (err) {
6903 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6904 wmi_buf_free(buf);
6905 return QDF_STATUS_E_FAILURE;
6906 }
6907
6908 return QDF_STATUS_SUCCESS;
6909}
6910
Nitesh Shah52323d02017-05-22 15:49:00 +05306911/**
6912 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6913 * configuration params
6914 * @wmi_handle: wmi handler
6915 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6916 *
6917 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6918 */
6919static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6920 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6921{
6922 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6923 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6924 wmi_buf_t buf;
6925 uint8_t *buf_ptr;
6926 QDF_STATUS err;
6927 uint32_t i;
6928 int len;
6929
6930 len = sizeof(*dbs_scan_param);
6931 len += WMI_TLV_HDR_SIZE;
6932 len += dbs_scan_params->num_clients * sizeof(*cmd);
6933
6934 buf = wmi_buf_alloc(wmi_handle, len);
6935 if (!buf) {
6936 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6937 return QDF_STATUS_E_NOMEM;
6938 }
6939
6940 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6941 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6942 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6943 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6944 WMITLV_GET_STRUCT_TLVLEN
6945 (wmi_scan_dbs_duty_cycle_fixed_param));
6946
6947 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6948 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6949 buf_ptr += sizeof(*dbs_scan_param);
6950 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6951 (sizeof(*cmd) * dbs_scan_params->num_clients));
6952 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6953
6954 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6955 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6956 WMITLV_SET_HDR(&cmd->tlv_header,
6957 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6958 WMITLV_GET_STRUCT_TLVLEN(
6959 wmi_scan_dbs_duty_cycle_tlv_param));
6960 cmd->module_id = dbs_scan_params->module_id[i];
6961 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6962 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6963 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6964 }
6965
6966 err = wmi_unified_cmd_send(wmi_handle, buf,
6967 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6968 if (QDF_IS_STATUS_ERROR(err)) {
6969 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6970 wmi_buf_free(buf);
6971 return QDF_STATUS_E_FAILURE;
6972 }
6973
6974 return QDF_STATUS_SUCCESS;
6975}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306976
6977/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306978 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6979 * @wmi_handle: wmi handle
6980 * @roam_req: Request which contains the filters
6981 *
6982 * There are filters such as whitelist, blacklist and preferred
6983 * list that need to be applied to the scan results to form the
6984 * probable candidates for roaming.
6985 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006986 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306987 * parameters to the firmware, otherwise failure.
6988 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306989static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306990 struct roam_scan_filter_params *roam_req)
6991{
6992 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306993 QDF_STATUS status;
6994 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306995 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306996 uint8_t *buf_ptr;
6997 wmi_roam_filter_fixed_param *roam_filter;
6998 uint8_t *bssid_src_ptr = NULL;
6999 wmi_mac_addr *bssid_dst_ptr = NULL;
7000 wmi_ssid *ssid_ptr = NULL;
7001 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307002 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307003 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307004
7005 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307006
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307007 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05307008 if (roam_req->num_bssid_black_list)
7009 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
7010 len += WMI_TLV_HDR_SIZE;
7011 if (roam_req->num_ssid_white_list)
7012 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
7013 len += 2 * WMI_TLV_HDR_SIZE;
7014 if (roam_req->num_bssid_preferred_list) {
7015 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05307016 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307017 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307018 len += WMI_TLV_HDR_SIZE;
7019 if (roam_req->lca_disallow_config_present) {
7020 len += sizeof(*blist_param);
7021 blist_len = sizeof(*blist_param);
7022 }
7023
7024 len += WMI_TLV_HDR_SIZE;
7025 if (roam_req->num_rssi_rejection_ap)
7026 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307027
7028 buf = wmi_buf_alloc(wmi_handle, len);
7029 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307030 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307031 return QDF_STATUS_E_NOMEM;
7032 }
7033
7034 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7035 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
7036 WMITLV_SET_HDR(&roam_filter->tlv_header,
7037 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7038 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7039 /* fill in fixed values */
7040 roam_filter->vdev_id = roam_req->session_id;
7041 roam_filter->flags = 0;
7042 roam_filter->op_bitmap = roam_req->op_bitmap;
7043 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7044 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7045 roam_filter->num_bssid_preferred_list =
7046 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307047 roam_filter->num_rssi_rejection_ap =
7048 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307049 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7050
7051 WMITLV_SET_HDR((buf_ptr),
7052 WMITLV_TAG_ARRAY_FIXED_STRUC,
7053 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7054 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7055 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7056 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7057 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7058 bssid_src_ptr += ATH_MAC_LEN;
7059 bssid_dst_ptr++;
7060 }
7061 buf_ptr += WMI_TLV_HDR_SIZE +
7062 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7063 WMITLV_SET_HDR((buf_ptr),
7064 WMITLV_TAG_ARRAY_FIXED_STRUC,
7065 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7066 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7067 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7068 qdf_mem_copy(&ssid_ptr->ssid,
7069 &roam_req->ssid_allowed_list[i].mac_ssid,
7070 roam_req->ssid_allowed_list[i].length);
7071 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7072 ssid_ptr++;
7073 }
7074 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7075 sizeof(wmi_ssid));
7076 WMITLV_SET_HDR((buf_ptr),
7077 WMITLV_TAG_ARRAY_FIXED_STRUC,
7078 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7079 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7080 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7081 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7082 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7083 (wmi_mac_addr *)bssid_dst_ptr);
7084 bssid_src_ptr += ATH_MAC_LEN;
7085 bssid_dst_ptr++;
7086 }
7087 buf_ptr += WMI_TLV_HDR_SIZE +
7088 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7089 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7090 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7091 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7092 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7093 *bssid_preferred_factor_ptr =
7094 roam_req->bssid_favored_factor[i];
7095 bssid_preferred_factor_ptr++;
7096 }
7097 buf_ptr += WMI_TLV_HDR_SIZE +
7098 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7099
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307100 WMITLV_SET_HDR(buf_ptr,
7101 WMITLV_TAG_ARRAY_STRUC, blist_len);
7102 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307103 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307104 blist_param =
7105 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7106 WMITLV_SET_HDR(&blist_param->tlv_header,
7107 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7108 WMITLV_GET_STRUCT_TLVLEN(
7109 wmi_roam_lca_disallow_config_tlv_param));
7110
7111 blist_param->disallow_duration = roam_req->disallow_duration;
7112 blist_param->rssi_channel_penalization =
7113 roam_req->rssi_channel_penalization;
7114 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307115 blist_param->disallow_lca_enable_source_bitmap =
7116 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7117 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307118 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7119 }
7120
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307121 WMITLV_SET_HDR(buf_ptr,
7122 WMITLV_TAG_ARRAY_STRUC,
7123 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7124 buf_ptr += WMI_TLV_HDR_SIZE;
7125 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7126 rssi_rej =
7127 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7128 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7129 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7130 WMITLV_GET_STRUCT_TLVLEN(
7131 wmi_roam_rssi_rejection_oce_config_param));
7132 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7133 roam_req->rssi_rejection_ap[i].bssid.bytes,
7134 &rssi_rej->bssid);
7135 rssi_rej->remaining_disallow_duration =
7136 roam_req->rssi_rejection_ap[i].remaining_duration;
7137 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307138 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307139 buf_ptr +=
7140 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7141 }
7142
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307143 status = wmi_unified_cmd_send(wmi_handle, buf,
7144 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307145 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307146 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307147 status);
7148 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307149 }
Govind Singh67922e82016-04-01 16:48:57 +05307150
7151 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307152}
7153
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307154#if defined(WLAN_FEATURE_FILS_SK)
7155static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7156 struct hlp_params *params)
7157{
7158 uint32_t len;
7159 uint8_t *buf_ptr;
7160 wmi_buf_t buf = NULL;
7161 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7162
7163 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7164 len += WMI_TLV_HDR_SIZE;
7165 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7166
7167 buf = wmi_buf_alloc(wmi_handle, len);
7168 if (!buf) {
7169 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7170 return QDF_STATUS_E_NOMEM;
7171 }
7172
7173 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7174 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7175 WMITLV_SET_HDR(&hlp_params->tlv_header,
7176 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7177 WMITLV_GET_STRUCT_TLVLEN(
7178 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7179
7180 hlp_params->vdev_id = params->vdev_id;
7181 hlp_params->size = params->hlp_ie_len;
7182 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7183
7184 buf_ptr += sizeof(*hlp_params);
7185
7186 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7187 round_up(params->hlp_ie_len,
7188 sizeof(uint32_t)));
7189 buf_ptr += WMI_TLV_HDR_SIZE;
7190 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7191
7192 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7193 hlp_params->vdev_id, hlp_params->size);
7194 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7195 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7196 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7197 wmi_buf_free(buf);
7198 return QDF_STATUS_E_FAILURE;
7199 }
7200
7201 return QDF_STATUS_SUCCESS;
7202}
7203#endif
7204
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307205#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307206/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7207 * @wmi_handle: wmi handle
7208 * @ipa_offload: ipa offload control parameter
7209 *
7210 * Returns: 0 on success, error number otherwise
7211 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307212static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307213 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307214{
7215 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7216 wmi_buf_t wmi_buf;
7217 uint32_t len;
7218 u_int8_t *buf_ptr;
7219
7220 len = sizeof(*cmd);
7221 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7222 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307223 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7224 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307225 }
7226
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007227 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307228 ipa_offload->offload_type, ipa_offload->enable);
7229
7230 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7231
7232 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7233 WMITLV_SET_HDR(&cmd->tlv_header,
7234 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7235 WMITLV_GET_STRUCT_TLVLEN(
7236 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7237
7238 cmd->offload_type = ipa_offload->offload_type;
7239 cmd->vdev_id = ipa_offload->vdev_id;
7240 cmd->enable = ipa_offload->enable;
7241
7242 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7243 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307244 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307246 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307247 }
7248
Govind Singhb53420c2016-03-09 14:32:57 +05307249 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307250}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307251#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307252
7253/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307254 * send_plm_stop_cmd_tlv() - plm stop request
7255 * @wmi_handle: wmi handle
7256 * @plm: plm request parameters
7257 *
7258 * This function request FW to stop PLM.
7259 *
7260 * Return: CDF status
7261 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307262static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263 const struct plm_req_params *plm)
7264{
7265 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7266 int32_t len;
7267 wmi_buf_t buf;
7268 uint8_t *buf_ptr;
7269 int ret;
7270
7271 len = sizeof(*cmd);
7272 buf = wmi_buf_alloc(wmi_handle, len);
7273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307274 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7275 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307276 }
7277
7278 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7279
7280 buf_ptr = (uint8_t *) cmd;
7281
7282 WMITLV_SET_HDR(&cmd->tlv_header,
7283 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7284 WMITLV_GET_STRUCT_TLVLEN
7285 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7286
7287 cmd->vdev_id = plm->session_id;
7288
7289 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307290 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307291
7292 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7293 WMI_VDEV_PLMREQ_STOP_CMDID);
7294 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307295 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307296 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307297 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307298 }
7299
Govind Singhb53420c2016-03-09 14:32:57 +05307300 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307301}
7302
7303/**
7304 * send_plm_start_cmd_tlv() - plm start request
7305 * @wmi_handle: wmi handle
7306 * @plm: plm request parameters
7307 *
7308 * This function request FW to start PLM.
7309 *
7310 * Return: CDF status
7311 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307312static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307313 const struct plm_req_params *plm,
7314 uint32_t *gchannel_list)
7315{
7316 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7317 uint32_t *channel_list;
7318 int32_t len;
7319 wmi_buf_t buf;
7320 uint8_t *buf_ptr;
7321 uint8_t count;
7322 int ret;
7323
7324 /* TLV place holder for channel_list */
7325 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7326 len += sizeof(uint32_t) * plm->plm_num_ch;
7327
7328 buf = wmi_buf_alloc(wmi_handle, len);
7329 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307330 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7331 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307332 }
7333 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7334
7335 buf_ptr = (uint8_t *) cmd;
7336
7337 WMITLV_SET_HDR(&cmd->tlv_header,
7338 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7339 WMITLV_GET_STRUCT_TLVLEN
7340 (wmi_vdev_plmreq_start_cmd_fixed_param));
7341
7342 cmd->vdev_id = plm->session_id;
7343
7344 cmd->meas_token = plm->meas_token;
7345 cmd->dialog_token = plm->diag_token;
7346 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307347 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307348 cmd->off_duration = plm->meas_duration;
7349 cmd->burst_cycle = plm->burst_len;
7350 cmd->tx_power = plm->desired_tx_pwr;
7351 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7352 cmd->num_chans = plm->plm_num_ch;
7353
7354 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7355
Govind Singhb53420c2016-03-09 14:32:57 +05307356 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7357 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7358 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7359 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7360 WMI_LOGD("off_duration: %d", cmd->off_duration);
7361 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7362 WMI_LOGD("tx_power: %d", cmd->tx_power);
7363 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307364
7365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7366 (cmd->num_chans * sizeof(uint32_t)));
7367
7368 buf_ptr += WMI_TLV_HDR_SIZE;
7369 if (cmd->num_chans) {
7370 channel_list = (uint32_t *) buf_ptr;
7371 for (count = 0; count < cmd->num_chans; count++) {
7372 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307373 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307374 channel_list[count] =
7375 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307376 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307377 }
7378 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7379 }
7380
7381 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7382 WMI_VDEV_PLMREQ_START_CMDID);
7383 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307384 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307385 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307386 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307387 }
7388
Govind Singhb53420c2016-03-09 14:32:57 +05307389 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307390}
7391
7392/**
7393 * send_pno_stop_cmd_tlv() - PNO stop request
7394 * @wmi_handle: wmi handle
7395 * @vdev_id: vdev id
7396 *
7397 * This function request FW to stop ongoing PNO operation.
7398 *
7399 * Return: CDF status
7400 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307401static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307402{
7403 wmi_nlo_config_cmd_fixed_param *cmd;
7404 int32_t len = sizeof(*cmd);
7405 wmi_buf_t buf;
7406 uint8_t *buf_ptr;
7407 int ret;
7408
7409 /*
7410 * TLV place holder for array of structures nlo_configured_parameters
7411 * TLV place holder for array of uint32_t channel_list
7412 * TLV place holder for chnl prediction cfg
7413 */
7414 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7415 buf = wmi_buf_alloc(wmi_handle, len);
7416 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307417 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7418 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307419 }
7420
7421 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7422 buf_ptr = (uint8_t *) cmd;
7423
7424 WMITLV_SET_HDR(&cmd->tlv_header,
7425 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7426 WMITLV_GET_STRUCT_TLVLEN
7427 (wmi_nlo_config_cmd_fixed_param));
7428
7429 cmd->vdev_id = vdev_id;
7430 cmd->flags = WMI_NLO_CONFIG_STOP;
7431 buf_ptr += sizeof(*cmd);
7432
7433 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7434 buf_ptr += WMI_TLV_HDR_SIZE;
7435
7436 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7437 buf_ptr += WMI_TLV_HDR_SIZE;
7438
7439 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7440 buf_ptr += WMI_TLV_HDR_SIZE;
7441
7442
7443 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7444 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7445 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307446 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307447 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307448 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307449 }
7450
Govind Singhb53420c2016-03-09 14:32:57 +05307451 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307452}
7453
7454/**
Govind Singhccb0c272016-04-01 16:30:08 +05307455 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7456 * @buf_ptr: Buffer passed by upper layers
7457 * @pno: Buffer to be sent to the firmware
7458 *
7459 * Copy the PNO Channel prediction configuration parameters
7460 * passed by the upper layers to a WMI format TLV and send it
7461 * down to the firmware.
7462 *
7463 * Return: None
7464 */
7465static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7466 struct pno_scan_req_params *pno)
7467{
7468 nlo_channel_prediction_cfg *channel_prediction_cfg =
7469 (nlo_channel_prediction_cfg *) buf_ptr;
7470 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7471 WMITLV_TAG_ARRAY_BYTE,
7472 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307473#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307474 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7475 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7476 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7477 channel_prediction_cfg->full_scan_period_ms =
7478 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307479#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307480 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7481 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7482 channel_prediction_cfg->enable,
7483 channel_prediction_cfg->top_k_num,
7484 channel_prediction_cfg->stationary_threshold,
7485 channel_prediction_cfg->full_scan_period_ms);
7486}
7487
7488/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007489 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7490 * @wmi_handle: wmi handle
7491 * @params: configuration parameters
7492 *
7493 * Return: QDF_STATUS
7494 */
7495static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7496 struct nlo_mawc_params *params)
7497{
7498 wmi_buf_t buf = NULL;
7499 QDF_STATUS status;
7500 int len;
7501 uint8_t *buf_ptr;
7502 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7503
7504 len = sizeof(*wmi_nlo_mawc_params);
7505 buf = wmi_buf_alloc(wmi_handle, len);
7506 if (!buf) {
7507 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7508 return QDF_STATUS_E_NOMEM;
7509 }
7510
7511 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7512 wmi_nlo_mawc_params =
7513 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7514 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7515 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7516 WMITLV_GET_STRUCT_TLVLEN
7517 (wmi_nlo_configure_mawc_cmd_fixed_param));
7518 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7519 if (params->enable)
7520 wmi_nlo_mawc_params->enable = 1;
7521 else
7522 wmi_nlo_mawc_params->enable = 0;
7523 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7524 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7525 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007526 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7527 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7528 wmi_nlo_mawc_params->exp_backoff_ratio,
7529 wmi_nlo_mawc_params->init_scan_interval,
7530 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007531
7532 status = wmi_unified_cmd_send(wmi_handle, buf,
7533 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7534 if (QDF_IS_STATUS_ERROR(status)) {
7535 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7536 status);
7537 wmi_buf_free(buf);
7538 return QDF_STATUS_E_FAILURE;
7539 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007540
7541 return QDF_STATUS_SUCCESS;
7542}
7543
7544/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307545 * send_pno_start_cmd_tlv() - PNO start request
7546 * @wmi_handle: wmi handle
7547 * @pno: PNO request
7548 *
7549 * This function request FW to start PNO request.
7550 * Request: CDF status
7551 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307552static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307553 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307554{
7555 wmi_nlo_config_cmd_fixed_param *cmd;
7556 nlo_configured_parameters *nlo_list;
7557 uint32_t *channel_list;
7558 int32_t len;
7559 wmi_buf_t buf;
7560 uint8_t *buf_ptr;
7561 uint8_t i;
7562 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307563 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307564 connected_nlo_rssi_params *nlo_relative_rssi;
7565 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307566
7567 /*
7568 * TLV place holder for array nlo_configured_parameters(nlo_list)
7569 * TLV place holder for array of uint32_t channel_list
7570 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307571 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307572 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307573 */
7574 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307575 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307576 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307577
Abhishek Singh5987b632017-03-03 22:09:07 +05307578 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307579 WMI_NLO_MAX_CHAN);
7580 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307581 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307582 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307583 len += sizeof(enlo_candidate_score_params);
7584 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307585 len += sizeof(connected_nlo_rssi_params);
7586 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307587
7588 buf = wmi_buf_alloc(wmi_handle, len);
7589 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307590 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7591 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307592 }
7593
7594 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7595
7596 buf_ptr = (uint8_t *) cmd;
7597 WMITLV_SET_HDR(&cmd->tlv_header,
7598 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7599 WMITLV_GET_STRUCT_TLVLEN
7600 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307601 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307602 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7603
Govind Singh87542482016-06-08 19:40:11 +05307604#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307605 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307606 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307607#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307608 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307609 cmd->active_dwell_time = pno->active_dwell_time;
7610 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307611
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307612 if (pno->do_passive_scan)
7613 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307614 /* Copy scan interval */
7615 cmd->fast_scan_period = pno->fast_scan_period;
7616 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007617 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007619 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307620 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307621 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307622 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307623
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307624 /* mac randomization attributes */
7625 if (pno->scan_random.randomize) {
7626 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7627 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7628 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7629 pno->scan_random.mac_mask,
7630 &cmd->mac_addr,
7631 &cmd->mac_mask);
7632 }
7633
Govind Singh4eacd2b2016-03-07 14:24:22 +05307634 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7635
Abhishek Singh5987b632017-03-03 22:09:07 +05307636 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307637 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307638 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7639 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7640 buf_ptr += WMI_TLV_HDR_SIZE;
7641
7642 nlo_list = (nlo_configured_parameters *) buf_ptr;
7643 for (i = 0; i < cmd->no_of_ssids; i++) {
7644 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7645 WMITLV_TAG_ARRAY_BYTE,
7646 WMITLV_GET_STRUCT_TLVLEN
7647 (nlo_configured_parameters));
7648 /* Copy ssid and it's length */
7649 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307650 nlo_list[i].ssid.ssid.ssid_len =
7651 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307652 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307653 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307654 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307655 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307656 nlo_list[i].ssid.ssid.ssid_len,
7657 (char *)nlo_list[i].ssid.ssid.ssid,
7658 nlo_list[i].ssid.ssid.ssid_len);
7659
7660 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307661 if (pno->networks_list[i].rssi_thresh &&
7662 pno->networks_list[i].rssi_thresh >
7663 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307664 nlo_list[i].rssi_cond.valid = true;
7665 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307666 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307667 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307668 nlo_list[i].rssi_cond.rssi);
7669 }
7670 nlo_list[i].bcast_nw_type.valid = true;
7671 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307672 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007673 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307674 nlo_list[i].bcast_nw_type.bcast_nw_type);
7675 }
7676 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7677
7678 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307679 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307680 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307681 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7683 (cmd->num_of_channels * sizeof(uint32_t)));
7684 buf_ptr += WMI_TLV_HDR_SIZE;
7685
7686 channel_list = (uint32_t *) buf_ptr;
7687 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307688 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307689
7690 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307691 channel_list[i] =
7692 wlan_chan_to_freq(pno->
7693 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307694
Govind Singhb53420c2016-03-09 14:32:57 +05307695 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307696 }
7697 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7698 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7699 sizeof(nlo_channel_prediction_cfg));
7700 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307701 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307702 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307703 /** TODO: Discrete firmware doesn't have command/option to configure
7704 * App IE which comes from wpa_supplicant as of part PNO start request.
7705 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7707 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7708 buf_ptr += sizeof(enlo_candidate_score_params);
7709
7710 if (ie_whitelist->white_list) {
7711 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7712 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7713 &cmd->num_vendor_oui,
7714 ie_whitelist);
7715 }
7716
7717 /* ie white list */
7718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7719 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7720 buf_ptr += WMI_TLV_HDR_SIZE;
7721 if (cmd->num_vendor_oui != 0) {
7722 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7723 ie_whitelist->voui);
7724 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7725 }
7726
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307727 if (pno->relative_rssi_set)
7728 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7729
7730 /*
7731 * Firmware calculation using connected PNO params:
7732 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7733 * deduction of rssi_pref for chosen band_pref and
7734 * addition of rssi_pref for remaining bands (other than chosen band).
7735 */
7736 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7737 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7738 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7739 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7740 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7741 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7742 buf_ptr += sizeof(*nlo_relative_rssi);
7743
7744 /*
7745 * As of now Kernel and Host supports one band and rssi preference.
7746 * Firmware supports array of band and rssi preferences
7747 */
7748 cmd->num_cnlo_band_pref = 1;
7749 WMITLV_SET_HDR(buf_ptr,
7750 WMITLV_TAG_ARRAY_STRUC,
7751 cmd->num_cnlo_band_pref *
7752 sizeof(connected_nlo_bss_band_rssi_pref));
7753 buf_ptr += WMI_TLV_HDR_SIZE;
7754
7755 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7756 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7757 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7758 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7759 WMITLV_GET_STRUCT_TLVLEN(
7760 connected_nlo_bss_band_rssi_pref));
7761 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7762 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7763 WMI_LOGI("band_pref %d, rssi_pref %d",
7764 nlo_band_rssi[i].band,
7765 nlo_band_rssi[i].rssi_pref);
7766 }
7767 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7768
Govind Singh4eacd2b2016-03-07 14:24:22 +05307769 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7770 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7771 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307772 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307773 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307774 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307775 }
7776
Govind Singhb53420c2016-03-09 14:32:57 +05307777 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307778}
7779
7780/* send_set_ric_req_cmd_tlv() - set ric request element
7781 * @wmi_handle: wmi handle
7782 * @msg: message
7783 * @is_add_ts: is addts required
7784 *
7785 * This function sets ric request element for 11r roaming.
7786 *
7787 * Return: CDF status
7788 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307789static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307790 void *msg, uint8_t is_add_ts)
7791{
7792 wmi_ric_request_fixed_param *cmd;
7793 wmi_ric_tspec *tspec_param;
7794 wmi_buf_t buf;
7795 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307796 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307797 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7798 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7799
7800 buf = wmi_buf_alloc(wmi_handle, len);
7801 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307802 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7803 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307804 }
7805
7806 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7807
7808 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7809 WMITLV_SET_HDR(&cmd->tlv_header,
7810 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7811 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7812 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007813 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307814 else
7815 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7816 cmd->num_ric_request = 1;
7817 cmd->is_add_ric = is_add_ts;
7818
7819 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7820 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7821
7822 buf_ptr += WMI_TLV_HDR_SIZE;
7823 tspec_param = (wmi_ric_tspec *) buf_ptr;
7824 WMITLV_SET_HDR(&tspec_param->tlv_header,
7825 WMITLV_TAG_STRUC_wmi_ric_tspec,
7826 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7827
7828 if (is_add_ts)
7829 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307830#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307831 else
7832 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307833#endif
7834 if (ptspecIE) {
7835 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307836#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307837 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7838 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839#else
Govind Singh87542482016-06-08 19:40:11 +05307840 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7841 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307842#endif /* ANI_LITTLE_BIT_ENDIAN */
7843
Govind Singh87542482016-06-08 19:40:11 +05307844 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7845 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7846 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7847 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7848 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7849 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7850 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7851 tspec_param->min_data_rate = ptspecIE->minDataRate;
7852 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7853 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7854 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7855 tspec_param->delay_bound = ptspecIE->delayBound;
7856 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7857 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7858 tspec_param->medium_time = 0;
7859 }
Govind Singhb53420c2016-03-09 14:32:57 +05307860 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307861
7862 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7863 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307864 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307865 __func__);
7866 if (is_add_ts)
7867 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307868 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307869 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307870 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307871 }
7872
Govind Singhb53420c2016-03-09 14:32:57 +05307873 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307874}
7875
Qiwei Cai1ccba222018-05-21 16:49:39 +08007876#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307877/**
7878 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7879 * @wmi_handle: wmi handle
7880 * @clear_req: ll stats clear request command params
7881 *
Govind Singhb53420c2016-03-09 14:32:57 +05307882 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307884static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307885 const struct ll_stats_clear_params *clear_req,
7886 uint8_t addr[IEEE80211_ADDR_LEN])
7887{
7888 wmi_clear_link_stats_cmd_fixed_param *cmd;
7889 int32_t len;
7890 wmi_buf_t buf;
7891 uint8_t *buf_ptr;
7892 int ret;
7893
7894 len = sizeof(*cmd);
7895 buf = wmi_buf_alloc(wmi_handle, len);
7896
7897 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307898 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7899 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307900 }
7901
7902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307903 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307904 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7905
7906 WMITLV_SET_HDR(&cmd->tlv_header,
7907 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7908 WMITLV_GET_STRUCT_TLVLEN
7909 (wmi_clear_link_stats_cmd_fixed_param));
7910
7911 cmd->stop_stats_collection_req = clear_req->stop_req;
7912 cmd->vdev_id = clear_req->sta_id;
7913 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7914
7915 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7916 &cmd->peer_macaddr);
7917
Govind Singhb53420c2016-03-09 14:32:57 +05307918 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7919 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7920 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7921 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7922 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307923 cmd->peer_macaddr); */
7924
7925 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7926 WMI_CLEAR_LINK_STATS_CMDID);
7927 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307928 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307929 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307930 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307931 }
7932
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7934 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307935}
7936
7937/**
7938 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7939 * @wmi_handle: wmi handle
7940 * @setReq: ll stats set request command params
7941 *
Govind Singhb53420c2016-03-09 14:32:57 +05307942 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307943 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307944static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307945 const struct ll_stats_set_params *set_req)
7946{
7947 wmi_start_link_stats_cmd_fixed_param *cmd;
7948 int32_t len;
7949 wmi_buf_t buf;
7950 uint8_t *buf_ptr;
7951 int ret;
7952
7953 len = sizeof(*cmd);
7954 buf = wmi_buf_alloc(wmi_handle, len);
7955
7956 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307957 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7958 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307959 }
7960
7961 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307962 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307963 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7964
7965 WMITLV_SET_HDR(&cmd->tlv_header,
7966 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7967 WMITLV_GET_STRUCT_TLVLEN
7968 (wmi_start_link_stats_cmd_fixed_param));
7969
7970 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7971 cmd->aggressive_statistics_gathering =
7972 set_req->aggressive_statistics_gathering;
7973
Govind Singhb53420c2016-03-09 14:32:57 +05307974 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7975 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7976 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307977
7978 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7979 WMI_START_LINK_STATS_CMDID);
7980 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307981 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307982 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307983 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307984 }
7985
Govind Singhb53420c2016-03-09 14:32:57 +05307986 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307987}
7988
7989/**
7990 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7991 * @wmi_handle:wmi handle
7992 * @get_req:ll stats get request command params
7993 * @addr: mac address
7994 *
Govind Singhb53420c2016-03-09 14:32:57 +05307995 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307996 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307997static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307998 const struct ll_stats_get_params *get_req,
7999 uint8_t addr[IEEE80211_ADDR_LEN])
8000{
8001 wmi_request_link_stats_cmd_fixed_param *cmd;
8002 int32_t len;
8003 wmi_buf_t buf;
8004 uint8_t *buf_ptr;
8005 int ret;
8006
8007 len = sizeof(*cmd);
8008 buf = wmi_buf_alloc(wmi_handle, len);
8009
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308010 if (!buf) {
8011 WMI_LOGE("%s: buf allocation failed", __func__);
8012 return QDF_STATUS_E_NOMEM;
8013 }
8014
Govind Singh4eacd2b2016-03-07 14:24:22 +05308015 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308016 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308017 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8018
8019 WMITLV_SET_HDR(&cmd->tlv_header,
8020 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8021 WMITLV_GET_STRUCT_TLVLEN
8022 (wmi_request_link_stats_cmd_fixed_param));
8023
8024 cmd->request_id = get_req->req_id;
8025 cmd->stats_type = get_req->param_id_mask;
8026 cmd->vdev_id = get_req->sta_id;
8027
8028 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8029 &cmd->peer_macaddr);
8030
Govind Singhb53420c2016-03-09 14:32:57 +05308031 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008032 WMI_LOGD("Request ID : %u", cmd->request_id);
8033 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308034 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8035 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308036
8037 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8038 WMI_REQUEST_LINK_STATS_CMDID);
8039 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308040 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308041 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308042 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308043 }
8044
Govind Singhb53420c2016-03-09 14:32:57 +05308045 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308046}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008047#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308048
Govind Singh20c5dac2016-03-07 15:33:31 +05308049/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308050 * send_congestion_cmd_tlv() - send request to fw to get CCA
8051 * @wmi_handle: wmi handle
8052 * @vdev_id: vdev id
8053 *
8054 * Return: CDF status
8055 */
8056static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308057 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308058{
8059 wmi_buf_t buf;
8060 wmi_request_stats_cmd_fixed_param *cmd;
8061 uint8_t len;
8062 uint8_t *buf_ptr;
8063
8064 len = sizeof(*cmd);
8065 buf = wmi_buf_alloc(wmi_handle, len);
8066 if (!buf) {
8067 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8068 return QDF_STATUS_E_FAILURE;
8069 }
8070
8071 buf_ptr = wmi_buf_data(buf);
8072 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8073 WMITLV_SET_HDR(&cmd->tlv_header,
8074 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8075 WMITLV_GET_STRUCT_TLVLEN
8076 (wmi_request_stats_cmd_fixed_param));
8077
8078 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8079 cmd->vdev_id = vdev_id;
8080 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8081 cmd->vdev_id, cmd->stats_id);
8082
8083 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8084 WMI_REQUEST_STATS_CMDID)) {
8085 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8086 __func__);
8087 wmi_buf_free(buf);
8088 return QDF_STATUS_E_FAILURE;
8089 }
8090
8091 return QDF_STATUS_SUCCESS;
8092}
8093
8094/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8096 * @wmi_handle: wmi handle
8097 * @rssi_req: get RSSI request
8098 *
8099 * Return: CDF status
8100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308101static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308102{
8103 wmi_buf_t buf;
8104 wmi_request_stats_cmd_fixed_param *cmd;
8105 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8106
8107 buf = wmi_buf_alloc(wmi_handle, len);
8108 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308109 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8110 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308111 }
8112
8113 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8114 WMITLV_SET_HDR(&cmd->tlv_header,
8115 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8116 WMITLV_GET_STRUCT_TLVLEN
8117 (wmi_request_stats_cmd_fixed_param));
8118 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8119 if (wmi_unified_cmd_send
8120 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308121 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308122 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308123 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308124 }
8125
Govind Singhb53420c2016-03-09 14:32:57 +05308126 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308127}
8128
8129/**
8130 * send_snr_cmd_tlv() - get RSSI from fw
8131 * @wmi_handle: wmi handle
8132 * @vdev_id: vdev id
8133 *
8134 * Return: CDF status
8135 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308136static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308137{
8138 wmi_buf_t buf;
8139 wmi_request_stats_cmd_fixed_param *cmd;
8140 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8141
8142 buf = wmi_buf_alloc(wmi_handle, len);
8143 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308144 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8145 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308146 }
8147
8148 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8149 cmd->vdev_id = vdev_id;
8150
8151 WMITLV_SET_HDR(&cmd->tlv_header,
8152 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8153 WMITLV_GET_STRUCT_TLVLEN
8154 (wmi_request_stats_cmd_fixed_param));
8155 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8156 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8157 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308158 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308159 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308160 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308161 }
8162
Govind Singhb53420c2016-03-09 14:32:57 +05308163 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308164}
8165
8166/**
8167 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8168 * @wmi_handle: wmi handle
8169 * @link_status: get link params
8170 *
8171 * Return: CDF status
8172 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308173static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308174 struct link_status_params *link_status)
8175{
8176 wmi_buf_t buf;
8177 wmi_request_stats_cmd_fixed_param *cmd;
8178 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8179
8180 buf = wmi_buf_alloc(wmi_handle, len);
8181 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308182 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8183 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308184 }
8185
8186 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8187 WMITLV_SET_HDR(&cmd->tlv_header,
8188 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8189 WMITLV_GET_STRUCT_TLVLEN
8190 (wmi_request_stats_cmd_fixed_param));
8191 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8192 cmd->vdev_id = link_status->session_id;
8193 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8194 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308195 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308196 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308197 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308198 }
8199
Govind Singhb53420c2016-03-09 14:32:57 +05308200 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308201}
8202
Govind Singh20c5dac2016-03-07 15:33:31 +05308203/**
8204 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8205 * @wmi_handle: wmi handle
8206 * @ta_dhcp_ind: DHCP indication parameter
8207 *
8208 * Return: CDF Status
8209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308210static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308211 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8212{
Govind Singh67922e82016-04-01 16:48:57 +05308213 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308214 wmi_buf_t buf = NULL;
8215 uint8_t *buf_ptr;
8216 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8217 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8218
8219
8220 buf = wmi_buf_alloc(wmi_handle, len);
8221 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308222 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8223 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308224 }
8225
8226 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8227 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8228 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8229 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8230 WMITLV_GET_STRUCT_TLVLEN
8231 (wmi_peer_set_param_cmd_fixed_param));
8232
8233 /* fill in values */
8234 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8235 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8236 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308237 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308238 &ta_dhcp_ind->peer_macaddr,
8239 sizeof(ta_dhcp_ind->peer_macaddr));
8240
8241 status = wmi_unified_cmd_send(wmi_handle, buf,
8242 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308243 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308244 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308245 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308246 wmi_buf_free(buf);
8247 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308248
Govind Singh67922e82016-04-01 16:48:57 +05308249 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308250}
8251
8252/**
8253 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8254 * @wmi_handle: wmi handle
8255 * @pLinkSpeed: link speed info
8256 *
8257 * Return: CDF status
8258 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308259static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308260 wmi_mac_addr peer_macaddr)
8261{
8262 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8263 wmi_buf_t wmi_buf;
8264 uint32_t len;
8265 uint8_t *buf_ptr;
8266
8267 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8268 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8269 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308270 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8271 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308272 }
8273 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8274
8275 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8276 WMITLV_SET_HDR(&cmd->tlv_header,
8277 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8278 WMITLV_GET_STRUCT_TLVLEN
8279 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8280
8281 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308282 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308283 &peer_macaddr,
8284 sizeof(peer_macaddr));
8285
8286
8287 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8288 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308289 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308290 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308291 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 }
Govind Singhb53420c2016-03-09 14:32:57 +05308293 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308294}
8295
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308296#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308297/**
8298 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8299 * @wmi_handle: wmi handler
8300 * @egap_params: pointer to egap_params
8301 *
8302 * Return: 0 for success, otherwise appropriate error code
8303 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308304static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308305 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308306{
8307 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8308 wmi_buf_t buf;
8309 int32_t err;
8310
8311 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8312 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308313 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8314 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308315 }
8316 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8317 WMITLV_SET_HDR(&cmd->tlv_header,
8318 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8319 WMITLV_GET_STRUCT_TLVLEN(
8320 wmi_ap_ps_egap_param_cmd_fixed_param));
8321
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308322 cmd->enable = egap_params->host_enable_egap;
8323 cmd->inactivity_time = egap_params->egap_inactivity_time;
8324 cmd->wait_time = egap_params->egap_wait_time;
8325 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 err = wmi_unified_cmd_send(wmi_handle, buf,
8327 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8328 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308329 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308330 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308331 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308332 }
8333
Govind Singhb53420c2016-03-09 14:32:57 +05308334 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308335}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308336#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308337
8338/**
8339 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8340 * @wmi_handl: wmi handle
8341 * @cmd: Profiling command index
8342 * @value1: parameter1 value
8343 * @value2: parameter2 value
8344 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308345 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308346 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308347static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 uint32_t cmd, uint32_t value1, uint32_t value2)
8349{
8350 wmi_buf_t buf;
8351 int32_t len = 0;
8352 int ret;
8353 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8354 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8355 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8356 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8357
8358 switch (cmd) {
8359 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8360 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8361 buf = wmi_buf_alloc(wmi_handle, len);
8362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308364 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308365 }
8366 prof_trig_cmd =
8367 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8368 wmi_buf_data(buf);
8369 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8370 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8371 WMITLV_GET_STRUCT_TLVLEN
8372 (wmi_wlan_profile_trigger_cmd_fixed_param));
8373 prof_trig_cmd->enable = value1;
8374 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8375 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8376 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308377 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308378 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308379 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308380 return ret;
8381 }
8382 break;
8383
8384 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8385 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8386 buf = wmi_buf_alloc(wmi_handle, len);
8387 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308388 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308389 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 }
8391 profile_getdata_cmd =
8392 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8393 wmi_buf_data(buf);
8394 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8395 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8396 WMITLV_GET_STRUCT_TLVLEN
8397 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8398 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8399 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8400 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308401 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308402 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308403 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308404 return ret;
8405 }
8406 break;
8407
8408 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8409 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8410 buf = wmi_buf_alloc(wmi_handle, len);
8411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308412 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308413 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308414 }
8415 hist_intvl_cmd =
8416 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8417 wmi_buf_data(buf);
8418 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8419 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8420 WMITLV_GET_STRUCT_TLVLEN
8421 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8422 hist_intvl_cmd->profile_id = value1;
8423 hist_intvl_cmd->value = value2;
8424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8425 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8426 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308427 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308428 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308429 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308430 return ret;
8431 }
8432 break;
8433
8434 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8435 len =
8436 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8437 buf = wmi_buf_alloc(wmi_handle, len);
8438 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308439 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308440 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308441 }
8442 profile_enable_cmd =
8443 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8444 wmi_buf_data(buf);
8445 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8446 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8447 WMITLV_GET_STRUCT_TLVLEN
8448 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8449 profile_enable_cmd->profile_id = value1;
8450 profile_enable_cmd->enable = value2;
8451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8452 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8453 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308454 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308455 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308456 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308457 return ret;
8458 }
8459 break;
8460
8461 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308462 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308463 break;
8464 }
8465
8466 return 0;
8467}
8468
Paul Zhang92ab8d32017-12-08 16:08:00 +08008469static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8470 struct wlm_latency_level_param *params)
8471{
8472 wmi_wlm_config_cmd_fixed_param *cmd;
8473 wmi_buf_t buf;
8474 uint32_t len = sizeof(*cmd);
8475 static uint32_t ll[4] = {100, 60, 40, 20};
8476
8477 buf = wmi_buf_alloc(wmi_handle, len);
8478 if (!buf) {
8479 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8480 return QDF_STATUS_E_NOMEM;
8481 }
8482 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8483 WMITLV_SET_HDR(&cmd->tlv_header,
8484 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8485 WMITLV_GET_STRUCT_TLVLEN
8486 (wmi_wlm_config_cmd_fixed_param));
8487 cmd->vdev_id = params->vdev_id;
8488 cmd->latency_level = params->wlm_latency_level;
8489 cmd->ul_latency = ll[params->wlm_latency_level];
8490 cmd->dl_latency = ll[params->wlm_latency_level];
8491 cmd->flags = params->wlm_latency_flags;
8492 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8493 WMI_WLM_CONFIG_CMDID)) {
8494 WMI_LOGE("%s: Failed to send setting latency config command",
8495 __func__);
8496 wmi_buf_free(buf);
8497 return QDF_STATUS_E_FAILURE;
8498 }
8499
8500 return 0;
8501}
Govind Singh20c5dac2016-03-07 15:33:31 +05308502/**
8503 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8504 * @wmi_handle: wmi handle
8505 * @vdev_id: vdev id
8506 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308507 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308508 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308509static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308510{
8511 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8512 wmi_buf_t buf;
8513 int32_t len = sizeof(*cmd);
8514
Govind Singhb53420c2016-03-09 14:32:57 +05308515 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308516 buf = wmi_buf_alloc(wmi_handle, len);
8517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308518 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308519 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308520 }
8521 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8522 wmi_buf_data(buf);
8523 WMITLV_SET_HDR(&cmd->tlv_header,
8524 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8525 WMITLV_GET_STRUCT_TLVLEN
8526 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8527 cmd->vdev_id = vdev_id;
8528 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8529 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8530 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308531 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 __func__);
8533 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308534 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308535 }
8536
8537 return 0;
8538}
8539
8540/**
8541 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8542 * @wmi_handle: wmi handle
8543 * @vdev_id: vdev id
8544 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308545 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308546 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308547static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308548 uint8_t vdev_id)
8549{
8550 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8551 wmi_buf_t buf;
8552 int32_t len = sizeof(*cmd);
8553
Govind Singhb53420c2016-03-09 14:32:57 +05308554 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308555 buf = wmi_buf_alloc(wmi_handle, len);
8556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308557 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308558 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308559 }
8560 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8561 WMITLV_SET_HDR(&cmd->tlv_header,
8562 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8563 WMITLV_GET_STRUCT_TLVLEN
8564 (wmi_csa_offload_enable_cmd_fixed_param));
8565 cmd->vdev_id = vdev_id;
8566 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8567 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8568 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308569 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308570 __func__);
8571 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308572 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308573 }
8574
8575 return 0;
8576}
8577
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008578#ifdef WLAN_FEATURE_CIF_CFR
8579/**
8580 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8581 * @wmi_handle: wmi handle
8582 * @data_len: len of dma cfg req
8583 * @data: dma cfg req
8584 *
8585 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8586 */
8587static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8588 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8589{
8590 wmi_buf_t buf;
8591 uint8_t *cmd;
8592 QDF_STATUS ret;
8593
8594 WMITLV_SET_HDR(cfg,
8595 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8596 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8597
8598 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8599 if (!buf) {
8600 WMI_LOGE(FL("wmi_buf_alloc failed"));
8601 return QDF_STATUS_E_FAILURE;
8602 }
8603
8604 cmd = (uint8_t *) wmi_buf_data(buf);
8605 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8606 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8607 sizeof(*cfg));
8608 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8609 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8610 if (QDF_IS_STATUS_ERROR(ret)) {
8611 WMI_LOGE(FL(":wmi cmd send failed"));
8612 wmi_buf_free(buf);
8613 }
8614
8615 return ret;
8616}
8617#endif
8618
Govind Singh20c5dac2016-03-07 15:33:31 +05308619/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308620 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8621 * @wmi_handle: wmi handle
8622 * @data_len: len of dma cfg req
8623 * @data: dma cfg req
8624 *
8625 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8626 */
8627static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8628 struct direct_buf_rx_cfg_req *cfg)
8629{
8630 wmi_buf_t buf;
8631 wmi_dma_ring_cfg_req_fixed_param *cmd;
8632 QDF_STATUS ret;
8633 int32_t len = sizeof(*cmd);
8634
8635 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8636 if (!buf) {
8637 WMI_LOGE(FL("wmi_buf_alloc failed"));
8638 return QDF_STATUS_E_FAILURE;
8639 }
8640
8641 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8642
8643 WMITLV_SET_HDR(&cmd->tlv_header,
8644 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8645 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8646
8647 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8648 cfg->pdev_id);
8649 cmd->mod_id = cfg->mod_id;
8650 cmd->base_paddr_lo = cfg->base_paddr_lo;
8651 cmd->base_paddr_hi = cfg->base_paddr_hi;
8652 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8653 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8654 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8655 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8656 cmd->num_elems = cfg->num_elems;
8657 cmd->buf_size = cfg->buf_size;
8658 cmd->num_resp_per_event = cfg->num_resp_per_event;
8659 cmd->event_timeout_ms = cfg->event_timeout_ms;
8660
8661 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8662 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8663 "head idx paddr hi %x tail idx paddr lo %x"
8664 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8665 "event timeout %d\n", __func__, cmd->pdev_id,
8666 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8667 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8668 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8669 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8670 cmd->event_timeout_ms);
8671 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8672 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8673 if (QDF_IS_STATUS_ERROR(ret)) {
8674 WMI_LOGE(FL(":wmi cmd send failed"));
8675 wmi_buf_free(buf);
8676 }
8677
8678 return ret;
8679}
8680
8681/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008682 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8683 * @wmi_handle: wmi handle
8684 * @start_11d_scan: 11d scan start request parameters
8685 *
8686 * This function request FW to start 11d scan.
8687 *
8688 * Return: QDF status
8689 */
8690static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8691 struct reg_start_11d_scan_req *start_11d_scan)
8692{
8693 wmi_11d_scan_start_cmd_fixed_param *cmd;
8694 int32_t len;
8695 wmi_buf_t buf;
8696 int ret;
8697
8698 len = sizeof(*cmd);
8699 buf = wmi_buf_alloc(wmi_handle, len);
8700 if (!buf) {
8701 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8702 return QDF_STATUS_E_NOMEM;
8703 }
8704
8705 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8706
8707 WMITLV_SET_HDR(&cmd->tlv_header,
8708 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8709 WMITLV_GET_STRUCT_TLVLEN
8710 (wmi_11d_scan_start_cmd_fixed_param));
8711
8712 cmd->vdev_id = start_11d_scan->vdev_id;
8713 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8714 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8715
8716 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8717
8718 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8719 WMI_11D_SCAN_START_CMDID);
8720 if (ret) {
8721 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8722 wmi_buf_free(buf);
8723 return QDF_STATUS_E_FAILURE;
8724 }
8725
8726 return QDF_STATUS_SUCCESS;
8727}
8728
8729/**
8730 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8731 * @wmi_handle: wmi handle
8732 * @start_11d_scan: 11d scan stop request parameters
8733 *
8734 * This function request FW to stop 11d scan.
8735 *
8736 * Return: QDF status
8737 */
8738static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8739 struct reg_stop_11d_scan_req *stop_11d_scan)
8740{
8741 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8742 int32_t len;
8743 wmi_buf_t buf;
8744 int ret;
8745
8746 len = sizeof(*cmd);
8747 buf = wmi_buf_alloc(wmi_handle, len);
8748 if (!buf) {
8749 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8750 return QDF_STATUS_E_NOMEM;
8751 }
8752
8753 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8754
8755 WMITLV_SET_HDR(&cmd->tlv_header,
8756 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8757 WMITLV_GET_STRUCT_TLVLEN
8758 (wmi_11d_scan_stop_cmd_fixed_param));
8759
8760 cmd->vdev_id = stop_11d_scan->vdev_id;
8761
8762 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8763
8764 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8765 WMI_11D_SCAN_STOP_CMDID);
8766 if (ret) {
8767 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8768 wmi_buf_free(buf);
8769 return QDF_STATUS_E_FAILURE;
8770 }
8771
8772 return QDF_STATUS_SUCCESS;
8773}
8774
8775/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308776 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8777 * @wmi_handle: wmi handle
8778 * @startOemDataReq: start request params
8779 *
8780 * Return: CDF status
8781 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308782static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008783 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308784 uint8_t *data)
8785{
8786 wmi_buf_t buf;
8787 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308788 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308789
8790 buf = wmi_buf_alloc(wmi_handle,
8791 (data_len + WMI_TLV_HDR_SIZE));
8792 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308793 WMI_LOGE(FL("wmi_buf_alloc failed"));
8794 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308795 }
8796
8797 cmd = (uint8_t *) wmi_buf_data(buf);
8798
8799 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8800 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308801 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308802 data_len);
8803
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008804 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308805 data_len);
8806
8807 ret = wmi_unified_cmd_send(wmi_handle, buf,
8808 (data_len +
8809 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8810
Govind Singh67922e82016-04-01 16:48:57 +05308811 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308812 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308813 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308814 }
8815
Govind Singh67922e82016-04-01 16:48:57 +05308816 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308817}
8818
8819/**
8820 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8821 * @wmi_handle: wmi handle
8822 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8823 *
8824 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8825 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8826 * to firmware based on phyerr filtering
8827 * offload status.
8828 *
8829 * Return: 1 success, 0 failure
8830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308831static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308832send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8833 bool dfs_phyerr_filter_offload)
8834{
8835 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8836 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8837 wmi_buf_t buf;
8838 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308839 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308840
8841
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008842 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308843 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 __func__);
8845 len = sizeof(*disable_phyerr_offload_cmd);
8846 buf = wmi_buf_alloc(wmi_handle, len);
8847 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308848 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308849 return 0;
8850 }
8851 disable_phyerr_offload_cmd =
8852 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8853 wmi_buf_data(buf);
8854
8855 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8856 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8857 WMITLV_GET_STRUCT_TLVLEN
8858 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8859
8860 /*
8861 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8862 * to the firmware to disable the phyerror
8863 * filtering offload.
8864 */
8865 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8866 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308867 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308868 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308869 __func__, ret);
8870 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308871 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 }
Govind Singhb53420c2016-03-09 14:32:57 +05308873 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308874 __func__);
8875 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308876 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308877 __func__);
8878
8879 len = sizeof(*enable_phyerr_offload_cmd);
8880 buf = wmi_buf_alloc(wmi_handle, len);
8881 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308882 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8883 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308884 }
8885
8886 enable_phyerr_offload_cmd =
8887 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8888 wmi_buf_data(buf);
8889
8890 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8891 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8892 WMITLV_GET_STRUCT_TLVLEN
8893 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8894
8895 /*
8896 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8897 * to the firmware to enable the phyerror
8898 * filtering offload.
8899 */
8900 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8901 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8902
Govind Singh67922e82016-04-01 16:48:57 +05308903 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308904 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308905 __func__, ret);
8906 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308907 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308908 }
Govind Singhb53420c2016-03-09 14:32:57 +05308909 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308910 __func__);
8911 }
8912
Govind Singhb53420c2016-03-09 14:32:57 +05308913 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308914}
8915
Naveen Rawata5817e72017-10-26 18:50:19 -07008916/**
8917 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8918 * will wake up host after specified time is elapsed
8919 * @wmi_handle: wmi handle
8920 * @vdev_id: vdev id
8921 * @cookie: value to identify reason why host set up wake call.
8922 * @time: time in ms
8923 *
8924 * Return: QDF status
8925 */
8926static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8927 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8928{
8929 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8930 wmi_buf_t buf;
8931 uint8_t *buf_ptr;
8932 int32_t len;
8933 int ret;
8934
8935 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8936 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8937 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8938 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8939 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308940 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8941 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008942
8943 buf = wmi_buf_alloc(wmi_handle, len);
8944 if (!buf) {
8945 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8946 return QDF_STATUS_E_NOMEM;
8947 }
8948
8949 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8950 buf_ptr = (uint8_t *) cmd;
8951
8952 WMITLV_SET_HDR(&cmd->tlv_header,
8953 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8954 WMITLV_GET_STRUCT_TLVLEN
8955 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8956 cmd->vdev_id = vdev_id;
8957 cmd->pattern_id = cookie,
8958 cmd->pattern_type = WOW_TIMER_PATTERN;
8959 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8960
8961 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8962 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8963 buf_ptr += WMI_TLV_HDR_SIZE;
8964
8965 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8966 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8967 buf_ptr += WMI_TLV_HDR_SIZE;
8968
8969 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8970 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8971 buf_ptr += WMI_TLV_HDR_SIZE;
8972
8973 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8974 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8975 buf_ptr += WMI_TLV_HDR_SIZE;
8976
8977 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008979 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308980 *((uint32_t *) buf_ptr) = time;
8981 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008982
8983 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008985 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308986 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008987
8988 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8989 __func__, time, vdev_id);
8990
8991 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8992 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8993 if (ret) {
8994 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
8995 __func__);
8996 wmi_buf_free(buf);
8997 return QDF_STATUS_E_FAILURE;
8998 }
8999
9000 return QDF_STATUS_SUCCESS;
9001}
9002
Govind Singh20c5dac2016-03-07 15:33:31 +05309003#if !defined(REMOVE_PKT_LOG)
9004/**
9005 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9006 * @wmi_handle: wmi handle
9007 * @pktlog_event: pktlog event
9008 * @cmd_id: pktlog cmd id
9009 *
9010 * Return: CDF status
9011 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309012static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309013 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309014 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309015{
9016 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9017 WMI_CMD_ID CMD_ID;
9018 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9019 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9020 int len = 0;
9021 wmi_buf_t buf;
9022
9023 PKTLOG_EVENT = pktlog_event;
9024 CMD_ID = cmd_id;
9025
9026 switch (CMD_ID) {
9027 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9028 len = sizeof(*cmd);
9029 buf = wmi_buf_alloc(wmi_handle, len);
9030 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309031 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9032 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 }
9034 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9035 wmi_buf_data(buf);
9036 WMITLV_SET_HDR(&cmd->tlv_header,
9037 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9038 WMITLV_GET_STRUCT_TLVLEN
9039 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9040 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309041 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9042 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309043 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9044 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309045 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9046 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309047 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309048 goto wmi_send_failed;
9049 }
9050 break;
9051 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9052 len = sizeof(*disable_cmd);
9053 buf = wmi_buf_alloc(wmi_handle, len);
9054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309055 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9056 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309057 }
9058 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9059 wmi_buf_data(buf);
9060 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9061 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9062 WMITLV_GET_STRUCT_TLVLEN
9063 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309064 disable_cmd->pdev_id =
9065 wmi_handle->ops->convert_pdev_id_host_to_target(
9066 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309067 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9068 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309069 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309070 goto wmi_send_failed;
9071 }
9072 break;
9073 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309074 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309075 break;
9076 }
9077
Govind Singhb53420c2016-03-09 14:32:57 +05309078 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309079
9080wmi_send_failed:
9081 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309082 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309083}
9084#endif /* REMOVE_PKT_LOG */
9085
9086/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309087 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9088 * @wmi_handle: wmi handle
9089 * @ptrn_id: pattern id
9090 * @vdev_id: vdev id
9091 *
9092 * Return: CDF status
9093 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309094static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9095 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309096{
9097 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9098 wmi_buf_t buf;
9099 int32_t len;
9100 int ret;
9101
9102 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9103
9104
9105 buf = wmi_buf_alloc(wmi_handle, len);
9106 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309107 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9108 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309109 }
9110
9111 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9112
9113 WMITLV_SET_HDR(&cmd->tlv_header,
9114 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9115 WMITLV_GET_STRUCT_TLVLEN(
9116 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9117 cmd->vdev_id = vdev_id;
9118 cmd->pattern_id = ptrn_id;
9119 cmd->pattern_type = WOW_BITMAP_PATTERN;
9120
Govind Singhb53420c2016-03-09 14:32:57 +05309121 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309122 cmd->pattern_id, vdev_id);
9123
9124 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9125 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9126 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309127 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309128 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309129 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309130 }
9131
Govind Singhb53420c2016-03-09 14:32:57 +05309132 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309133}
9134
9135/**
9136 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9137 * @wmi_handle: wmi handle
9138 *
9139 * Sends host wakeup indication to FW. On receiving this indication,
9140 * FW will come out of WOW.
9141 *
9142 * Return: CDF status
9143 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309144static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309145{
9146 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9147 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309148 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309149 int32_t len;
9150 int ret;
9151
9152 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9153
9154 buf = wmi_buf_alloc(wmi_handle, len);
9155 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309156 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9157 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309158 }
9159
9160 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9161 wmi_buf_data(buf);
9162 WMITLV_SET_HDR(&cmd->tlv_header,
9163 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9164 WMITLV_GET_STRUCT_TLVLEN
9165 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9166
9167
9168 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9169 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9170 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309172 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309173 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309174 }
9175
Govind Singhb53420c2016-03-09 14:32:57 +05309176 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309177}
9178
9179/**
9180 * send_del_ts_cmd_tlv() - send DELTS request to fw
9181 * @wmi_handle: wmi handle
9182 * @msg: delts params
9183 *
9184 * Return: CDF status
9185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309186static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309187 uint8_t ac)
9188{
9189 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9190 wmi_buf_t buf;
9191 int32_t len = sizeof(*cmd);
9192
9193 buf = wmi_buf_alloc(wmi_handle, len);
9194 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309195 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9196 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309197 }
9198 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9199 WMITLV_SET_HDR(&cmd->tlv_header,
9200 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9201 WMITLV_GET_STRUCT_TLVLEN
9202 (wmi_vdev_wmm_delts_cmd_fixed_param));
9203 cmd->vdev_id = vdev_id;
9204 cmd->ac = ac;
9205
Govind Singhb53420c2016-03-09 14:32:57 +05309206 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309207 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9208 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9209 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309210 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309211 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309212 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309213 }
9214
Govind Singhb53420c2016-03-09 14:32:57 +05309215 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309216}
9217
9218/**
9219 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9220 * @wmi_handle: handle to wmi
9221 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9222 *
Govind Singhb53420c2016-03-09 14:32:57 +05309223 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309224 * ADD_TS requestes to firmware in loop for all the ACs with
9225 * active flow.
9226 *
9227 * Return: CDF status
9228 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309229static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309230 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9231{
9232 int i = 0;
9233 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9234 wmi_buf_t buf;
9235 int32_t len = sizeof(*cmd);
9236
9237 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9238 /* if flow in this AC is active */
9239 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9240 /*
9241 * as per implementation of wma_add_ts_req() we
9242 * are not waiting any response from firmware so
9243 * apart from sending ADDTS to firmware just send
9244 * success to upper layers
9245 */
Govind Singhb53420c2016-03-09 14:32:57 +05309246 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309247
9248 buf = wmi_buf_alloc(wmi_handle, len);
9249 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309250 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9251 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309252 }
9253 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9254 wmi_buf_data(buf);
9255 WMITLV_SET_HDR(&cmd->tlv_header,
9256 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9257 WMITLV_GET_STRUCT_TLVLEN
9258 (wmi_vdev_wmm_addts_cmd_fixed_param));
Rajasekaran Kalidoss81f8de22018-08-04 00:17:18 +05309259 cmd->vdev_id = aggr_qos_rsp_msg->vdev_id;
Govind Singh20c5dac2016-03-07 15:33:31 +05309260 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309261 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309262 traffic.userPrio);
9263 cmd->medium_time_us =
9264 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9265 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309266 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9268 cmd->medium_time_us, cmd->downgrade_type);
9269 if (wmi_unified_cmd_send
9270 (wmi_handle, buf, len,
9271 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309272 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309273 __func__);
9274 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309275 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309276 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309277 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309278 }
9279 }
9280 }
9281
Govind Singhb53420c2016-03-09 14:32:57 +05309282 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309283}
9284
9285/**
9286 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9287 * @wmi_handle: wmi handle
9288 * @msg: ADDTS params
9289 *
9290 * Return: CDF status
9291 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309292static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309293 struct add_ts_param *msg)
9294{
9295 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9296 wmi_buf_t buf;
9297 int32_t len = sizeof(*cmd);
9298
Govind Singhb53420c2016-03-09 14:32:57 +05309299 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309300
9301 buf = wmi_buf_alloc(wmi_handle, len);
9302 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9304 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 }
9306 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9307 WMITLV_SET_HDR(&cmd->tlv_header,
9308 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9309 WMITLV_GET_STRUCT_TLVLEN
9310 (wmi_vdev_wmm_addts_cmd_fixed_param));
9311 cmd->vdev_id = msg->sme_session_id;
9312 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9313 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9314 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309315 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309316 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9317 cmd->downgrade_type, __func__, __LINE__);
9318 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9319 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309320 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9321 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309322 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309323 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309324 }
9325
Govind Singhb53420c2016-03-09 14:32:57 +05309326 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309327}
9328
9329/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309330 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9331 * @wmi_handle: wmi handle
9332 * @pAddPeriodicTxPtrnParams: tx ptrn params
9333 *
9334 * Retrun: CDF status
9335 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309336static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309337 struct periodic_tx_pattern *
9338 pAddPeriodicTxPtrnParams,
9339 uint8_t vdev_id)
9340{
9341 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9342 wmi_buf_t wmi_buf;
9343 uint32_t len;
9344 uint8_t *buf_ptr;
9345 uint32_t ptrn_len, ptrn_len_aligned;
9346 int j;
9347
9348 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9349 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9350 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9351 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9352
9353 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9354 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309355 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9356 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309357 }
9358
9359 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9360
9361 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9362 WMITLV_SET_HDR(&cmd->tlv_header,
9363 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9364 WMITLV_GET_STRUCT_TLVLEN
9365 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9366
9367 /* Pass the pattern id to delete for the corresponding vdev id */
9368 cmd->vdev_id = vdev_id;
9369 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9370 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9371 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9372
9373 /* Pattern info */
9374 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9375 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9376 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309377 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309378 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309379 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309380
Govind Singhb53420c2016-03-09 14:32:57 +05309381 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309382 __func__, cmd->pattern_id, cmd->vdev_id);
9383
9384 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9385 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309386 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309387 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309388 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309389 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 }
Govind Singhb53420c2016-03-09 14:32:57 +05309391 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309392}
9393
9394/**
9395 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9396 * @wmi_handle: wmi handle
9397 * @vdev_id: vdev id
9398 * @pattern_id: pattern id
9399 *
9400 * Retrun: CDF status
9401 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309402static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309403 uint8_t vdev_id,
9404 uint8_t pattern_id)
9405{
9406 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9407 wmi_buf_t wmi_buf;
9408 uint32_t len =
9409 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9410
9411 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9412 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309413 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9414 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309415 }
9416
9417 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9418 wmi_buf_data(wmi_buf);
9419 WMITLV_SET_HDR(&cmd->tlv_header,
9420 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9421 WMITLV_GET_STRUCT_TLVLEN
9422 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9423
9424 /* Pass the pattern id to delete for the corresponding vdev id */
9425 cmd->vdev_id = vdev_id;
9426 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309427 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309428 __func__, cmd->pattern_id, cmd->vdev_id);
9429
9430 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9431 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309432 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309433 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309434 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309435 }
Govind Singhb53420c2016-03-09 14:32:57 +05309436 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309437}
9438
9439/**
9440 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9441 * @wmi_handle: wmi handle
9442 * @preq: stats ext params
9443 *
9444 * Return: CDF status
9445 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309446static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309447 struct stats_ext_params *preq)
9448{
Govind Singh67922e82016-04-01 16:48:57 +05309449 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309450 wmi_req_stats_ext_cmd_fixed_param *cmd;
9451 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309452 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309453 uint8_t *buf_ptr;
9454
9455 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9456
9457 buf = wmi_buf_alloc(wmi_handle, len);
9458 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309459 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309460 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309461 }
9462
9463 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9464 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9465
9466 WMITLV_SET_HDR(&cmd->tlv_header,
9467 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9468 WMITLV_GET_STRUCT_TLVLEN
9469 (wmi_req_stats_ext_cmd_fixed_param));
9470 cmd->vdev_id = preq->vdev_id;
9471 cmd->data_len = preq->request_data_len;
9472
Govind Singhb53420c2016-03-09 14:32:57 +05309473 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309474 __func__, preq->request_data_len, preq->vdev_id);
9475
9476 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9477 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9478
9479 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309480 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309481
9482 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9483 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309484 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309485 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309486 ret);
9487 wmi_buf_free(buf);
9488 }
9489
9490 return ret;
9491}
9492
9493/**
9494 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9495 * @wmi_handle: wmi handle
9496 * @params: ext wow params
9497 *
9498 * Return:0 for success or error code
9499 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309500static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 struct ext_wow_params *params)
9502{
9503 wmi_extwow_enable_cmd_fixed_param *cmd;
9504 wmi_buf_t buf;
9505 int32_t len;
9506 int ret;
9507
9508 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9509 buf = wmi_buf_alloc(wmi_handle, len);
9510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309511 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9512 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309513 }
9514
9515 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9516
9517 WMITLV_SET_HDR(&cmd->tlv_header,
9518 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9519 WMITLV_GET_STRUCT_TLVLEN
9520 (wmi_extwow_enable_cmd_fixed_param));
9521
9522 cmd->vdev_id = params->vdev_id;
9523 cmd->type = params->type;
9524 cmd->wakeup_pin_num = params->wakeup_pin_num;
9525
Govind Singhb53420c2016-03-09 14:32:57 +05309526 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309527 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9528
9529 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9530 WMI_EXTWOW_ENABLE_CMDID);
9531 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309532 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309533 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309534 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309535 }
9536
Govind Singhb53420c2016-03-09 14:32:57 +05309537 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309538
9539}
9540
9541/**
9542 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9543 * @wmi_handle: wmi handle
9544 * @app_type1_params: app type1 params
9545 *
9546 * Return: CDF status
9547 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309548static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309549 struct app_type1_params *app_type1_params)
9550{
9551 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9552 wmi_buf_t buf;
9553 int32_t len;
9554 int ret;
9555
9556 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9557 buf = wmi_buf_alloc(wmi_handle, len);
9558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309559 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9560 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309561 }
9562
9563 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9564 wmi_buf_data(buf);
9565
9566 WMITLV_SET_HDR(&cmd->tlv_header,
9567 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9568 WMITLV_GET_STRUCT_TLVLEN
9569 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9570
9571 cmd->vdev_id = app_type1_params->vdev_id;
9572 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9573 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309574 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309575 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309576 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309577 cmd->passwd_len = app_type1_params->pass_length;
9578
Govind Singhb53420c2016-03-09 14:32:57 +05309579 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309580 "identification_id %.8s id_length %u "
9581 "password %.16s pass_length %u",
9582 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9583 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9584
9585 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9586 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9587 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309588 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309589 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309590 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309591 }
9592
Govind Singhb53420c2016-03-09 14:32:57 +05309593 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309594}
9595
9596/**
9597 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9598 * @wmi_handle: wmi handle
9599 * @appType2Params: app type2 params
9600 *
9601 * Return: CDF status
9602 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309603static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309604 struct app_type2_params *appType2Params)
9605{
9606 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9607 wmi_buf_t buf;
9608 int32_t len;
9609 int ret;
9610
9611 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9612 buf = wmi_buf_alloc(wmi_handle, len);
9613 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309614 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9615 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309616 }
9617
9618 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9619 wmi_buf_data(buf);
9620
9621 WMITLV_SET_HDR(&cmd->tlv_header,
9622 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9623 WMITLV_GET_STRUCT_TLVLEN
9624 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9625
9626 cmd->vdev_id = appType2Params->vdev_id;
9627
Govind Singhb53420c2016-03-09 14:32:57 +05309628 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309629 cmd->rc4_key_len = appType2Params->rc4_key_len;
9630
9631 cmd->ip_id = appType2Params->ip_id;
9632 cmd->ip_device_ip = appType2Params->ip_device_ip;
9633 cmd->ip_server_ip = appType2Params->ip_server_ip;
9634
9635 cmd->tcp_src_port = appType2Params->tcp_src_port;
9636 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9637 cmd->tcp_seq = appType2Params->tcp_seq;
9638 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9639
9640 cmd->keepalive_init = appType2Params->keepalive_init;
9641 cmd->keepalive_min = appType2Params->keepalive_min;
9642 cmd->keepalive_max = appType2Params->keepalive_max;
9643 cmd->keepalive_inc = appType2Params->keepalive_inc;
9644
9645 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9646 &cmd->gateway_mac);
9647 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9648 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9649
Govind Singhb53420c2016-03-09 14:32:57 +05309650 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309651 "rc4_key %.16s rc4_key_len %u "
9652 "ip_id %x ip_device_ip %x ip_server_ip %x "
9653 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9654 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9655 "keepalive_max %u keepalive_inc %u "
9656 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9657 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9658 cmd->rc4_key, cmd->rc4_key_len,
9659 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9660 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9661 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9662 cmd->keepalive_max, cmd->keepalive_inc,
9663 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9664
9665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9666 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9667 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309668 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309669 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309670 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309671 }
9672
Govind Singhb53420c2016-03-09 14:32:57 +05309673 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309674
9675}
9676
9677/**
9678 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9679 * @wmi_handle: wmi handle
9680 * @timer_val: auto shutdown timer value
9681 *
9682 * Return: CDF status
9683 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309684static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309685 uint32_t timer_val)
9686{
Govind Singh67922e82016-04-01 16:48:57 +05309687 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309688 wmi_buf_t buf = NULL;
9689 uint8_t *buf_ptr;
9690 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9691 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9692
Govind Singhb53420c2016-03-09 14:32:57 +05309693 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309694 __func__, timer_val);
9695
9696 buf = wmi_buf_alloc(wmi_handle, len);
9697 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309698 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9699 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309700 }
9701
9702 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9703 wmi_auto_sh_cmd =
9704 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9705 wmi_auto_sh_cmd->timer_value = timer_val;
9706
9707 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9708 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9709 WMITLV_GET_STRUCT_TLVLEN
9710 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9711
9712 status = wmi_unified_cmd_send(wmi_handle, buf,
9713 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309714 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309715 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309716 __func__, status);
9717 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309718 }
9719
Govind Singh67922e82016-04-01 16:48:57 +05309720 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309721}
9722
9723/**
9724 * send_nan_req_cmd_tlv() - to send nan request to target
9725 * @wmi_handle: wmi handle
9726 * @nan_req: request data which will be non-null
9727 *
9728 * Return: CDF status
9729 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309730static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309731 struct nan_req_params *nan_req)
9732{
Govind Singh67922e82016-04-01 16:48:57 +05309733 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309734 wmi_nan_cmd_param *cmd;
9735 wmi_buf_t buf;
9736 uint16_t len = sizeof(*cmd);
9737 uint16_t nan_data_len, nan_data_len_aligned;
9738 uint8_t *buf_ptr;
9739
9740 /*
9741 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9742 * +------------+----------+-----------------------+--------------+
9743 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9744 * +------------+----------+-----------------------+--------------+
9745 */
9746 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309747 WMI_LOGE("%s:nan req is not valid", __func__);
9748 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309749 }
9750 nan_data_len = nan_req->request_data_len;
9751 nan_data_len_aligned = roundup(nan_req->request_data_len,
9752 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009753 if (nan_data_len_aligned < nan_req->request_data_len) {
9754 WMI_LOGE("%s: integer overflow while rounding up data_len",
9755 __func__);
9756 return QDF_STATUS_E_FAILURE;
9757 }
9758
9759 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9760 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9761 __func__);
9762 return QDF_STATUS_E_FAILURE;
9763 }
9764
Govind Singh20c5dac2016-03-07 15:33:31 +05309765 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9766 buf = wmi_buf_alloc(wmi_handle, len);
9767 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309768 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9769 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309770 }
9771 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9772 cmd = (wmi_nan_cmd_param *) buf_ptr;
9773 WMITLV_SET_HDR(&cmd->tlv_header,
9774 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9775 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9776 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309777 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309778 __func__, nan_req->request_data_len);
9779 buf_ptr += sizeof(wmi_nan_cmd_param);
9780 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9781 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309782 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309783
9784 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9785 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309786 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309787 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309788 __func__, ret);
9789 wmi_buf_free(buf);
9790 }
9791
9792 return ret;
9793}
9794
9795/**
9796 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9797 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009798 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309799 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309800 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309801 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009802static QDF_STATUS
9803send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9804 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309805{
9806 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9807 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309808 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309809
9810 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9811 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309812 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309813 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309814 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309815 }
9816
9817 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309818
9819 WMITLV_SET_HDR(&cmd->tlv_header,
9820 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9821 WMITLV_GET_STRUCT_TLVLEN
9822 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009823 cmd->vdev_id = params->vdev_id;
9824 cmd->enable = params->dhcp_offload_enabled;
9825 cmd->num_client = params->dhcp_client_num;
9826 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309827 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309828 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309829 sizeof(*cmd),
9830 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309831 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309832 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309833 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309834 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309835 }
Govind Singhb53420c2016-03-09 14:32:57 +05309836 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009837 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309838
9839 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309840}
9841
9842/**
9843 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9844 * @wmi_handle: wmi handle
9845 * @flashing: flashing request
9846 *
9847 * Return: CDF status
9848 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309849static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309850 struct flashing_req_params *flashing)
9851{
9852 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309853 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309854 wmi_buf_t buf;
9855 uint8_t *buf_ptr;
9856 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9857
9858 buf = wmi_buf_alloc(wmi_handle, len);
9859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309860 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309861 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309862 }
9863 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9864 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9865 WMITLV_SET_HDR(&cmd->tlv_header,
9866 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9867 WMITLV_GET_STRUCT_TLVLEN
9868 (wmi_set_led_flashing_cmd_fixed_param));
9869 cmd->pattern_id = flashing->pattern_id;
9870 cmd->led_x0 = flashing->led_x0;
9871 cmd->led_x1 = flashing->led_x1;
9872
9873 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9874 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309875 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309876 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309877 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309878 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309879 }
Govind Singh67922e82016-04-01 16:48:57 +05309880
9881 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309882}
9883
9884/**
9885 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9886 * @wmi_handle: wmi handle
9887 * @ch_avoid_update_req: channel avoid update params
9888 *
9889 * Return: CDF status
9890 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309891static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309892{
Govind Singh67922e82016-04-01 16:48:57 +05309893 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309894 wmi_buf_t buf = NULL;
9895 uint8_t *buf_ptr;
9896 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9897 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9898
9899
9900 buf = wmi_buf_alloc(wmi_handle, len);
9901 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309902 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9903 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309904 }
9905
9906 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9907 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9908 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9909 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9910 WMITLV_GET_STRUCT_TLVLEN
9911 (wmi_chan_avoid_update_cmd_param));
9912
9913 status = wmi_unified_cmd_send(wmi_handle, buf,
9914 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309915 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309916 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309917 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9918 " returned Error %d", status);
9919 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309920 }
9921
Govind Singh67922e82016-04-01 16:48:57 +05309922 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309923}
9924
9925/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309926 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9927 * @wmi_handle: wmi handle
9928 * @param: pointer to pdev regdomain params
9929 *
9930 * Return: 0 for success or error code
9931 */
9932static QDF_STATUS
9933send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9934 struct pdev_set_regdomain_params *param)
9935{
9936 wmi_buf_t buf;
9937 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9938 int32_t len = sizeof(*cmd);
9939
9940
9941 buf = wmi_buf_alloc(wmi_handle, len);
9942 if (!buf) {
9943 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9944 return QDF_STATUS_E_NOMEM;
9945 }
9946 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9947 WMITLV_SET_HDR(&cmd->tlv_header,
9948 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9949 WMITLV_GET_STRUCT_TLVLEN
9950 (wmi_pdev_set_regdomain_cmd_fixed_param));
9951
9952 cmd->reg_domain = param->currentRDinuse;
9953 cmd->reg_domain_2G = param->currentRD2G;
9954 cmd->reg_domain_5G = param->currentRD5G;
9955 cmd->conformance_test_limit_2G = param->ctl_2G;
9956 cmd->conformance_test_limit_5G = param->ctl_5G;
9957 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309958 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9959 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309960
9961 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9962 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9963 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9964 __func__);
9965 wmi_buf_free(buf);
9966 return QDF_STATUS_E_FAILURE;
9967 }
9968
9969 return QDF_STATUS_SUCCESS;
9970}
9971
9972/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309973 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9974 * @wmi_handle: wmi handle
9975 * @reg_dmn: reg domain
9976 * @regdmn2G: 2G reg domain
9977 * @regdmn5G: 5G reg domain
9978 * @ctl2G: 2G test limit
9979 * @ctl5G: 5G test limit
9980 *
9981 * Return: none
9982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309983static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309984 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309985 uint16_t regdmn5G, uint8_t ctl2G,
9986 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309987{
9988 wmi_buf_t buf;
9989 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9990 int32_t len = sizeof(*cmd);
9991
9992
9993 buf = wmi_buf_alloc(wmi_handle, len);
9994 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309995 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9996 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309997 }
9998 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9999 WMITLV_SET_HDR(&cmd->tlv_header,
10000 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10001 WMITLV_GET_STRUCT_TLVLEN
10002 (wmi_pdev_set_regdomain_cmd_fixed_param));
10003 cmd->reg_domain = reg_dmn;
10004 cmd->reg_domain_2G = regdmn2G;
10005 cmd->reg_domain_5G = regdmn5G;
10006 cmd->conformance_test_limit_2G = ctl2G;
10007 cmd->conformance_test_limit_5G = ctl5G;
10008
10009 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10010 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010011 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010012 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010013 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010014 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010015 }
10016
Govind Singhb53420c2016-03-09 14:32:57 +053010017 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010018}
10019
10020
10021/**
10022 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10023 * @wmi_handle: wmi handle
10024 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10025 *
10026 * This function sets tdls off channel mode
10027 *
10028 * Return: 0 on success; Negative errno otherwise
10029 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010030static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010031 struct tdls_channel_switch_params *chan_switch_params)
10032{
10033 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10034 wmi_buf_t wmi_buf;
10035 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10036
10037 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10038 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010039 WMI_LOGE(FL("wmi_buf_alloc failed"));
10040 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010041 }
10042 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10043 wmi_buf_data(wmi_buf);
10044 WMITLV_SET_HDR(&cmd->tlv_header,
10045 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10046 WMITLV_GET_STRUCT_TLVLEN(
10047 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10048
10049 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10050 &cmd->peer_macaddr);
10051 cmd->vdev_id = chan_switch_params->vdev_id;
10052 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10053 cmd->is_peer_responder = chan_switch_params->is_responder;
10054 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10055 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10056 cmd->offchan_oper_class = chan_switch_params->oper_class;
10057
Govind Singhb53420c2016-03-09 14:32:57 +053010058 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010059 cmd->peer_macaddr.mac_addr31to0,
10060 cmd->peer_macaddr.mac_addr47to32);
10061
Govind Singhb53420c2016-03-09 14:32:57 +053010062 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010063 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10064 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10065 ),
10066 cmd->vdev_id,
10067 cmd->offchan_mode,
10068 cmd->offchan_num,
10069 cmd->offchan_bw_bitmap,
10070 cmd->is_peer_responder,
10071 cmd->offchan_oper_class);
10072
10073 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10074 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010075 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010076 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010077 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010078 }
10079
10080
Govind Singhb53420c2016-03-09 14:32:57 +053010081 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010082}
10083
10084/**
10085 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10086 * @wmi_handle: wmi handle
10087 * @pwmaTdlsparams: TDLS params
10088 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010089 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010090 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010091static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010092 void *tdls_param, uint8_t tdls_state)
10093{
10094 wmi_tdls_set_state_cmd_fixed_param *cmd;
10095 wmi_buf_t wmi_buf;
10096
10097 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10098 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10099
10100 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10101 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010102 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10103 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 }
10105 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10106 WMITLV_SET_HDR(&cmd->tlv_header,
10107 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10108 WMITLV_GET_STRUCT_TLVLEN
10109 (wmi_tdls_set_state_cmd_fixed_param));
10110 cmd->vdev_id = wmi_tdls->vdev_id;
10111 cmd->state = tdls_state;
10112 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10113 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10114 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10115 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10116 cmd->rssi_delta = wmi_tdls->rssi_delta;
10117 cmd->tdls_options = wmi_tdls->tdls_options;
10118 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10119 cmd->tdls_peer_traffic_response_timeout_ms =
10120 wmi_tdls->peer_traffic_response_timeout;
10121 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10122 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10123 cmd->tdls_puapsd_rx_frame_threshold =
10124 wmi_tdls->puapsd_rx_frame_threshold;
10125 cmd->teardown_notification_ms =
10126 wmi_tdls->teardown_notification_ms;
10127 cmd->tdls_peer_kickout_threshold =
10128 wmi_tdls->tdls_peer_kickout_threshold;
10129
Govind Singhb53420c2016-03-09 14:32:57 +053010130 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010131 "notification_interval_ms: %d, "
10132 "tx_discovery_threshold: %d, "
10133 "tx_teardown_threshold: %d, "
10134 "rssi_teardown_threshold: %d, "
10135 "rssi_delta: %d, "
10136 "tdls_options: 0x%x, "
10137 "tdls_peer_traffic_ind_window: %d, "
10138 "tdls_peer_traffic_response_timeout: %d, "
10139 "tdls_puapsd_mask: 0x%x, "
10140 "tdls_puapsd_inactivity_time: %d, "
10141 "tdls_puapsd_rx_frame_threshold: %d, "
10142 "teardown_notification_ms: %d, "
10143 "tdls_peer_kickout_threshold: %d",
10144 __func__, tdls_state, cmd->state,
10145 cmd->notification_interval_ms,
10146 cmd->tx_discovery_threshold,
10147 cmd->tx_teardown_threshold,
10148 cmd->rssi_teardown_threshold,
10149 cmd->rssi_delta,
10150 cmd->tdls_options,
10151 cmd->tdls_peer_traffic_ind_window,
10152 cmd->tdls_peer_traffic_response_timeout_ms,
10153 cmd->tdls_puapsd_mask,
10154 cmd->tdls_puapsd_inactivity_time_ms,
10155 cmd->tdls_puapsd_rx_frame_threshold,
10156 cmd->teardown_notification_ms,
10157 cmd->tdls_peer_kickout_threshold);
10158
10159 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10160 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010161 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010162 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010163 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010164 }
Govind Singhb53420c2016-03-09 14:32:57 +053010165 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010166
Govind Singhb53420c2016-03-09 14:32:57 +053010167 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010168}
10169
10170/**
10171 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10172 * @wmi_handle: wmi handle
10173 * @peerStateParams: TDLS peer state params
10174 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010175 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010176 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010177static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010178 struct tdls_peer_state_params *peerStateParams,
10179 uint32_t *ch_mhz)
10180{
10181 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10182 wmi_tdls_peer_capabilities *peer_cap;
10183 wmi_channel *chan_info;
10184 wmi_buf_t wmi_buf;
10185 uint8_t *buf_ptr;
10186 uint32_t i;
10187 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10188 sizeof(wmi_tdls_peer_capabilities);
10189
10190
10191 len += WMI_TLV_HDR_SIZE +
10192 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10193
10194 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10195 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010196 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10197 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010198 }
10199
10200 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10201 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10202 WMITLV_SET_HDR(&cmd->tlv_header,
10203 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10204 WMITLV_GET_STRUCT_TLVLEN
10205 (wmi_tdls_peer_update_cmd_fixed_param));
10206
10207 cmd->vdev_id = peerStateParams->vdevId;
10208 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10209 &cmd->peer_macaddr);
10210
10211
10212 cmd->peer_state = peerStateParams->peerState;
10213
Govind Singhb53420c2016-03-09 14:32:57 +053010214 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010215 "peer_macaddr.mac_addr31to0: 0x%x, "
10216 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10217 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10218 cmd->peer_macaddr.mac_addr31to0,
10219 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10220
10221 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10222 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10223 WMITLV_SET_HDR(&peer_cap->tlv_header,
10224 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10225 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10226
10227 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10228 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10229 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10230 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10231 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10232 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10233 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10234 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10235
10236 /* Ack and More Data Ack are sent as 0, so no need to set
10237 * but fill SP
10238 */
10239 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10240 peerStateParams->peerCap.peerMaxSp);
10241
10242 peer_cap->buff_sta_support =
10243 peerStateParams->peerCap.peerBuffStaSupport;
10244 peer_cap->off_chan_support =
10245 peerStateParams->peerCap.peerOffChanSupport;
10246 peer_cap->peer_curr_operclass =
10247 peerStateParams->peerCap.peerCurrOperClass;
10248 /* self curr operclass is not being used and so pass op class for
10249 * preferred off chan in it.
10250 */
10251 peer_cap->self_curr_operclass =
10252 peerStateParams->peerCap.opClassForPrefOffChan;
10253 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10254 peer_cap->peer_operclass_len =
10255 peerStateParams->peerCap.peerOperClassLen;
10256
Govind Singhb53420c2016-03-09 14:32:57 +053010257 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010258 __func__, peer_cap->peer_operclass_len);
10259 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10260 peer_cap->peer_operclass[i] =
10261 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010262 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010263 __func__, i, peer_cap->peer_operclass[i]);
10264 }
10265
10266 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10267 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10268 peer_cap->pref_offchan_bw =
10269 peerStateParams->peerCap.prefOffChanBandwidth;
10270
Govind Singhb53420c2016-03-09 14:32:57 +053010271 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010272 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10273 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10274 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10275 " %d, pref_offchan_bw: %d",
10276 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10277 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10278 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10279 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10280 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10281
10282 /* next fill variable size array of peer chan info */
10283 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10284 WMITLV_SET_HDR(buf_ptr,
10285 WMITLV_TAG_ARRAY_STRUC,
10286 sizeof(wmi_channel) *
10287 peerStateParams->peerCap.peerChanLen);
10288 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10289
10290 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10291 WMITLV_SET_HDR(&chan_info->tlv_header,
10292 WMITLV_TAG_STRUC_wmi_channel,
10293 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10294 chan_info->mhz = ch_mhz[i];
10295 chan_info->band_center_freq1 = chan_info->mhz;
10296 chan_info->band_center_freq2 = 0;
10297
Govind Singhb53420c2016-03-09 14:32:57 +053010298 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010299
10300 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10301 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010302 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010303 peerStateParams->peerCap.peerChan[i].chanId,
10304 peerStateParams->peerCap.peerChan[i].dfsSet);
10305 }
10306
10307 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10308 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10309 else
10310 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10311
10312 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10313 peerStateParams->peerCap.
10314 peerChan[i].pwr);
10315
10316 WMI_SET_CHANNEL_REG_POWER(chan_info,
10317 peerStateParams->peerCap.peerChan[i].
10318 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010319 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010320 peerStateParams->peerCap.peerChan[i].pwr);
10321
10322 chan_info++;
10323 }
10324
10325 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10326 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010327 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010328 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010329 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010330 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010331 }
10332
10333
Govind Singhb53420c2016-03-09 14:32:57 +053010334 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010335}
10336
10337/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010338 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10339 * @wmi_handle: Pointer to WMi handle
10340 * @ie_data: Pointer for ie data
10341 *
10342 * This function sends IE information to firmware
10343 *
Govind Singhb53420c2016-03-09 14:32:57 +053010344 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010345 *
10346 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010347static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010348 struct vdev_ie_info_param *ie_info)
10349{
10350 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10351 wmi_buf_t buf;
10352 uint8_t *buf_ptr;
10353 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010354 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010355
10356
10357 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10358 /* Allocate memory for the WMI command */
10359 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10360
10361 buf = wmi_buf_alloc(wmi_handle, len);
10362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010363 WMI_LOGE(FL("wmi_buf_alloc failed"));
10364 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010365 }
10366
10367 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010368 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010369
10370 /* Populate the WMI command */
10371 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10372
10373 WMITLV_SET_HDR(&cmd->tlv_header,
10374 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10375 WMITLV_GET_STRUCT_TLVLEN(
10376 wmi_vdev_set_ie_cmd_fixed_param));
10377 cmd->vdev_id = ie_info->vdev_id;
10378 cmd->ie_id = ie_info->ie_id;
10379 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010380 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010381
Govind Singhb53420c2016-03-09 14:32:57 +053010382 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010383 ie_info->length, ie_info->vdev_id);
10384
10385 buf_ptr += sizeof(*cmd);
10386 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10387 buf_ptr += WMI_TLV_HDR_SIZE;
10388
Govind Singhb53420c2016-03-09 14:32:57 +053010389 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010390
10391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10392 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010393 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010394 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010395 wmi_buf_free(buf);
10396 }
10397
10398 return ret;
10399}
10400
Sathish Kumar497bef42017-03-01 14:02:36 +053010401/**
10402 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10403 *
10404 * @param wmi_handle : handle to WMI.
10405 * @param param : pointer to antenna param
10406 *
10407 * This function sends smart antenna enable command to FW
10408 *
10409 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10410 */
10411static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10412 struct smart_ant_enable_params *param)
10413{
10414 /* Send WMI COMMAND to Enable */
10415 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10416 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10417 wmi_buf_t buf;
10418 uint8_t *buf_ptr;
10419 int len = 0;
10420 QDF_STATUS ret;
10421 int loop = 0;
10422
10423 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10424 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10425 buf = wmi_buf_alloc(wmi_handle, len);
10426
10427 if (!buf) {
10428 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10429 return QDF_STATUS_E_NOMEM;
10430 }
10431
10432 buf_ptr = wmi_buf_data(buf);
10433 qdf_mem_zero(buf_ptr, len);
10434 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10435
10436 WMITLV_SET_HDR(&cmd->tlv_header,
10437 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10438 WMITLV_GET_STRUCT_TLVLEN(
10439 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10440
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010441 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10442 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010443 cmd->enable = param->enable;
10444 cmd->mode = param->mode;
10445 cmd->rx_antenna = param->rx_antenna;
10446 cmd->tx_default_antenna = param->rx_antenna;
10447
10448 /* TLV indicating array of structures to follow */
10449 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10451 WMI_HAL_MAX_SANTENNA *
10452 sizeof(wmi_pdev_smart_ant_gpio_handle));
10453
10454 buf_ptr += WMI_TLV_HDR_SIZE;
10455 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10456
10457 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10458 WMITLV_SET_HDR(&gpio_param->tlv_header,
10459 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10460 WMITLV_GET_STRUCT_TLVLEN(
10461 wmi_pdev_smart_ant_gpio_handle));
10462 if (param->mode == SMART_ANT_MODE_SERIAL) {
10463 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10464 gpio_param->gpio_pin = param->gpio_pin[loop];
10465 gpio_param->gpio_func = param->gpio_func[loop];
10466 } else {
10467 gpio_param->gpio_pin = 0;
10468 gpio_param->gpio_func = 0;
10469 }
10470 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10471 gpio_param->gpio_pin = param->gpio_pin[loop];
10472 gpio_param->gpio_func = param->gpio_func[loop];
10473 }
10474 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010475 gpio_param->pdev_id =
10476 wmi_handle->ops->convert_pdev_id_host_to_target(
10477 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010478 gpio_param++;
10479 }
10480
10481 ret = wmi_unified_cmd_send(wmi_handle,
10482 buf,
10483 len,
10484 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10485
10486 if (ret != 0) {
10487 WMI_LOGE(" %s :WMI Failed\n", __func__);
10488 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10489 cmd->enable,
10490 cmd->mode,
10491 cmd->rx_antenna,
10492 param->gpio_pin[0], param->gpio_pin[1],
10493 param->gpio_pin[2], param->gpio_pin[3],
10494 param->gpio_func[0], param->gpio_func[1],
10495 param->gpio_func[2], param->gpio_func[3],
10496 ret);
10497 wmi_buf_free(buf);
10498 }
10499
10500 return ret;
10501}
10502
10503/**
10504 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10505 *
10506 * @param wmi_handle : handle to WMI.
10507 * @param param : pointer to rx antenna param
10508 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10509 */
10510static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10511 struct smart_ant_rx_ant_params *param)
10512{
10513 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10514 wmi_buf_t buf;
10515 uint8_t *buf_ptr;
10516 uint32_t len;
10517 QDF_STATUS ret;
10518
10519 len = sizeof(*cmd);
10520 buf = wmi_buf_alloc(wmi_handle, len);
10521 WMI_LOGD("%s:\n", __func__);
10522 if (!buf) {
10523 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10524 return QDF_STATUS_E_NOMEM;
10525 }
10526
10527 buf_ptr = wmi_buf_data(buf);
10528 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10529 WMITLV_SET_HDR(&cmd->tlv_header,
10530 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10531 WMITLV_GET_STRUCT_TLVLEN(
10532 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10533 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010534 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10535 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010536
10537 ret = wmi_unified_cmd_send(wmi_handle,
10538 buf,
10539 len,
10540 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10541
10542 if (ret != 0) {
10543 WMI_LOGE(" %s :WMI Failed\n", __func__);
10544 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10545 __func__,
10546 cmd->rx_antenna,
10547 ret);
10548 wmi_buf_free(buf);
10549 }
10550
10551 return ret;
10552}
10553
10554/**
10555 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10556 * @wmi_handle: wmi handle
10557 * @param: pointer to hold ctl table param
10558 *
10559 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10560 */
10561static QDF_STATUS
10562send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10563 struct ctl_table_params *param)
10564{
10565 uint16_t len, ctl_tlv_len;
10566 uint8_t *buf_ptr;
10567 wmi_buf_t buf;
10568 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10569 uint32_t *ctl_array;
10570
10571 if (!param->ctl_array)
10572 return QDF_STATUS_E_FAILURE;
10573
Sathish Kumar497bef42017-03-01 14:02:36 +053010574 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010575 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010576 len = sizeof(*cmd) + ctl_tlv_len;
10577
10578 buf = wmi_buf_alloc(wmi_handle, len);
10579 if (!buf) {
10580 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10581 return QDF_STATUS_E_FAILURE;
10582 }
10583
10584 buf_ptr = wmi_buf_data(buf);
10585 qdf_mem_zero(buf_ptr, len);
10586
10587 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10588
10589 WMITLV_SET_HDR(&cmd->tlv_header,
10590 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10591 WMITLV_GET_STRUCT_TLVLEN(
10592 wmi_pdev_set_ctl_table_cmd_fixed_param));
10593 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010594 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10595 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010596
10597 buf_ptr += sizeof(*cmd);
10598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10599 (cmd->ctl_len));
10600 buf_ptr += WMI_TLV_HDR_SIZE;
10601 ctl_array = (uint32_t *)buf_ptr;
10602
10603 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10604 sizeof(param->ctl_band));
10605 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10606 param->ctl_cmd_len -
10607 sizeof(param->ctl_band));
10608
10609 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10610 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10611 WMI_LOGE("%s:Failed to send command\n", __func__);
10612 wmi_buf_free(buf);
10613 return QDF_STATUS_E_FAILURE;
10614 }
10615
10616 return QDF_STATUS_SUCCESS;
10617}
10618
10619/**
10620 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10621 * @wmi_handle: wmi handle
10622 * @param: pointer to hold mimogain table param
10623 *
10624 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10625 */
10626static QDF_STATUS
10627send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10628 struct mimogain_table_params *param)
10629{
10630 uint16_t len, table_tlv_len;
10631 wmi_buf_t buf;
10632 uint8_t *buf_ptr;
10633 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10634 uint32_t *gain_table;
10635
10636 if (!param->array_gain)
10637 return QDF_STATUS_E_FAILURE;
10638
10639 /* len must be multiple of a single array gain table */
10640 if (param->tbl_len %
10641 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10642 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10643 WMI_LOGE("Array gain table len not correct\n");
10644 return QDF_STATUS_E_FAILURE;
10645 }
10646
10647 table_tlv_len = WMI_TLV_HDR_SIZE +
10648 roundup(param->tbl_len, sizeof(uint32_t));
10649 len = sizeof(*cmd) + table_tlv_len;
10650
10651 buf = wmi_buf_alloc(wmi_handle, len);
10652 if (!buf) {
10653 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10654 return QDF_STATUS_E_FAILURE;
10655 }
10656
10657 buf_ptr = wmi_buf_data(buf);
10658 qdf_mem_zero(buf_ptr, len);
10659
10660 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10661
10662 WMITLV_SET_HDR(&cmd->tlv_header,
10663 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10664 WMITLV_GET_STRUCT_TLVLEN(
10665 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10666
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010667 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10668 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010669 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10670 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10671 param->multichain_gain_bypass);
10672
10673 buf_ptr += sizeof(*cmd);
10674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10675 (param->tbl_len));
10676 buf_ptr += WMI_TLV_HDR_SIZE;
10677 gain_table = (uint32_t *)buf_ptr;
10678
10679 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10680 param->array_gain,
10681 param->tbl_len);
10682
10683 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10684 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10685 return QDF_STATUS_E_FAILURE;
10686 }
10687
10688 return QDF_STATUS_SUCCESS;
10689}
10690
10691/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010692 * enum packet_power_tlv_flags: target defined
10693 * packet power rate flags for TLV
10694 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10695 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10696 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10697 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10698 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10699 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10700 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10701 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10702 * @WMI_TLV_FLAG_STBC: STBC is set
10703 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10704 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10705 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10706 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10707 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10708 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10709 * @WMI_TLV_FLAG_LDPC: LDPC is set
10710 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10711 * @WMI_TLV_FLAG_SU: SU Data
10712 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10713 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10714 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10715 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10716 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10717 *
10718 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10719 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10720 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10721 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10722 */
10723enum packet_power_tlv_flags {
10724 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10725 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10726 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10727 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10728 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10729 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10730 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10731 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10732 WMI_TLV_FLAG_STBC = 0x00000100,
10733 WMI_TLV_FLAG_40MHZ = 0x00000200,
10734 WMI_TLV_FLAG_80MHZ = 0x00000300,
10735 WMI_TLV_FLAG_160MHZ = 0x00000400,
10736 WMI_TLV_FLAG_TXBF = 0x00000800,
10737 WMI_TLV_FLAG_RTSENA = 0x00001000,
10738 WMI_TLV_FLAG_CTSENA = 0x00002000,
10739 WMI_TLV_FLAG_LDPC = 0x00004000,
10740 WMI_TLV_FLAG_SGI = 0x00008000,
10741 WMI_TLV_FLAG_SU = 0x00100000,
10742 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10743 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10744 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10745 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10746 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10747
10748 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10749 WMI_TLV_FLAG_BW_MASK = 0x3,
10750 WMI_TLV_FLAG_BW_SHIFT = 9,
10751 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10752 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10753};
10754
10755/**
10756 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10757 * to FW understandable format
10758 * @param: pointer to hold packet power info param
10759 *
10760 * @return FW understandable 32 bit rate flags
10761 */
10762static uint32_t
10763convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10764{
10765 uint32_t rateflags = 0;
10766
10767 if (param->chainmask)
10768 rateflags |=
10769 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10770 if (param->chan_width)
10771 rateflags |=
10772 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10773 << WMI_TLV_FLAG_BW_SHIFT);
10774 if (param->su_mu_ofdma)
10775 rateflags |=
10776 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10777 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10778 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10779 rateflags |= WMI_TLV_FLAG_STBC;
10780 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10781 rateflags |= WMI_TLV_FLAG_LDPC;
10782 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10783 rateflags |= WMI_TLV_FLAG_TXBF;
10784 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10785 rateflags |= WMI_TLV_FLAG_RTSENA;
10786 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10787 rateflags |= WMI_TLV_FLAG_CTSENA;
10788 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10789 rateflags |= WMI_TLV_FLAG_SGI;
10790
10791 return rateflags;
10792}
10793
10794/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010795 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10796 * info to fw
10797 * @wmi_handle: wmi handle
10798 * @param: pointer to hold packet power info param
10799 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010800 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010801 */
10802static QDF_STATUS
10803send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10804 struct packet_power_info_params *param)
10805{
10806 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10807 wmi_buf_t wmibuf;
10808 uint8_t *buf_ptr;
10809 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10810
10811 wmibuf = wmi_buf_alloc(wmi_handle, len);
10812 if (wmibuf == NULL)
10813 return QDF_STATUS_E_NOMEM;
10814
10815 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10816
10817 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10818 WMITLV_SET_HDR(&cmd->tlv_header,
10819 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10820 WMITLV_GET_STRUCT_TLVLEN(
10821 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010822 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10823 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010824 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010825 cmd->nss = param->nss;
10826 cmd->preamble = param->preamble;
10827 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010828
10829 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10830 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10831 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10832 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10833
Sathish Kumar497bef42017-03-01 14:02:36 +053010834 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10835 WMI_PDEV_GET_TPC_CMDID)) {
10836 WMI_LOGE(FL("Failed to get tpc command\n"));
10837 wmi_buf_free(wmibuf);
10838 return QDF_STATUS_E_FAILURE;
10839 }
10840
10841 return QDF_STATUS_SUCCESS;
10842}
10843
10844/**
10845 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10846 * @wmi_handle: wmi handle
10847 * @param: pointer to hold config ratemask params
10848 *
10849 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10850 */
10851static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10852 struct config_ratemask_params *param)
10853{
10854 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10855 wmi_buf_t buf;
10856 int32_t len = sizeof(*cmd);
10857
10858 buf = wmi_buf_alloc(wmi_handle, len);
10859 if (!buf) {
10860 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10861 return QDF_STATUS_E_FAILURE;
10862 }
10863 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10864 WMITLV_SET_HDR(&cmd->tlv_header,
10865 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10866 WMITLV_GET_STRUCT_TLVLEN(
10867 wmi_vdev_config_ratemask_cmd_fixed_param));
10868 cmd->vdev_id = param->vdev_id;
10869 cmd->type = param->type;
10870 cmd->mask_lower32 = param->lower32;
10871 cmd->mask_higher32 = param->higher32;
Rhythm Patwab5ca01d2018-06-19 10:43:00 -070010872 cmd->mask_lower32_2 = param->lower32_2;
10873 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X"
10874 "mask_l32 = 0x%X mask_h32 = 0x%X mask_l32_2 = 0x%X\n",
10875 param->vdev_id, param->type, param->lower32,
10876 param->higher32, param->lower32_2);
Sathish Kumar497bef42017-03-01 14:02:36 +053010877
10878 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10879 WMI_VDEV_RATEMASK_CMDID)) {
10880 WMI_LOGE("Seting vdev ratemask failed\n");
10881 wmi_buf_free(buf);
10882 return QDF_STATUS_E_FAILURE;
10883 }
10884
10885 return QDF_STATUS_SUCCESS;
10886}
10887
10888/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010889 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10890 * @param: param sent from the host side
10891 * @cmd: param to be sent to the fw side
10892 */
10893static inline void copy_custom_aggr_bitmap(
10894 struct set_custom_aggr_size_params *param,
10895 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10896{
10897 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10898 param->ac);
10899 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10900 param->aggr_type);
10901 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10902 param->tx_aggr_size_disable);
10903 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10904 param->rx_aggr_size_disable);
10905 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10906 param->tx_ac_enable);
10907}
10908
10909/**
10910 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10911 * @wmi_handle: wmi handle
10912 * @param: pointer to hold custom aggr size params
10913 *
10914 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10915 */
10916static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10917 wmi_unified_t wmi_handle,
10918 struct set_custom_aggr_size_params *param)
10919{
10920 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10921 wmi_buf_t buf;
10922 int32_t len = sizeof(*cmd);
10923
10924 buf = wmi_buf_alloc(wmi_handle, len);
10925 if (!buf) {
10926 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10927 return QDF_STATUS_E_FAILURE;
10928 }
10929 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10930 wmi_buf_data(buf);
10931 WMITLV_SET_HDR(&cmd->tlv_header,
10932 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10933 WMITLV_GET_STRUCT_TLVLEN(
10934 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10935 cmd->vdev_id = param->vdev_id;
10936 cmd->tx_aggr_size = param->tx_aggr_size;
10937 cmd->rx_aggr_size = param->rx_aggr_size;
10938 copy_custom_aggr_bitmap(param, cmd);
10939
10940 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10941 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10942 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10943 "tx_ac_enable=0x%X\n",
10944 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10945 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10946 param->rx_aggr_size_disable, param->tx_ac_enable);
10947
10948 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10949 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10950 WMI_LOGE("Seting custom aggregation size failed\n");
10951 wmi_buf_free(buf);
10952 return QDF_STATUS_E_FAILURE;
10953 }
10954
10955 return QDF_STATUS_SUCCESS;
10956}
10957
10958/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010959 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10960 * @param wmi_handle : handle to WMI.
10961 * @param param : pointer to tx antenna param
10962 *
10963 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10964 */
10965
10966static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10967 struct set_qdepth_thresh_params *param)
10968{
10969 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10970 wmi_msduq_qdepth_thresh_update *cmd_update;
10971 wmi_buf_t buf;
10972 int32_t len = 0;
10973 int i;
10974 uint8_t *buf_ptr;
10975 QDF_STATUS ret;
10976
10977 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10978 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10979 return QDF_STATUS_E_INVAL;
10980 }
10981
10982 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10983 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10984 param->num_of_msduq_updates);
10985 buf = wmi_buf_alloc(wmi_handle, len);
10986
10987 if (!buf) {
10988 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10989 return QDF_STATUS_E_NOMEM;
10990 }
10991
10992 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10993 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
10994 buf_ptr;
10995
10996 WMITLV_SET_HDR(&cmd->tlv_header,
10997 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
10998 , WMITLV_GET_STRUCT_TLVLEN(
10999 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11000
11001 cmd->pdev_id =
11002 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11003 cmd->vdev_id = param->vdev_id;
11004 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11005 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11006
11007 buf_ptr += sizeof(
11008 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11009 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11010 param->num_of_msduq_updates *
11011 sizeof(wmi_msduq_qdepth_thresh_update));
11012 buf_ptr += WMI_TLV_HDR_SIZE;
11013 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11014
11015 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11016 WMITLV_SET_HDR(&cmd_update->tlv_header,
11017 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11018 WMITLV_GET_STRUCT_TLVLEN(
11019 wmi_msduq_qdepth_thresh_update));
11020 cmd_update->tid_num = param->update_params[i].tid_num;
11021 cmd_update->msduq_update_mask =
11022 param->update_params[i].msduq_update_mask;
11023 cmd_update->qdepth_thresh_value =
11024 param->update_params[i].qdepth_thresh_value;
11025 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11026 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11027 " update mask=0x%X thresh val=0x%X\n",
11028 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11029 cmd->peer_mac_address.mac_addr31to0,
11030 cmd->peer_mac_address.mac_addr47to32,
11031 cmd_update->msduq_update_mask,
11032 cmd_update->qdepth_thresh_value);
11033 cmd_update++;
11034 }
11035
11036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11037 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11038
11039 if (ret != 0) {
11040 WMI_LOGE(" %s :WMI Failed\n", __func__);
11041 wmi_buf_free(buf);
11042 }
11043
11044 return ret;
11045}
11046
11047/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011048 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11049 * @wmi_handle: wmi handle
11050 * @param: pointer to hold vap dscp tid map param
11051 *
11052 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11053 */
11054static QDF_STATUS
11055send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11056 struct vap_dscp_tid_map_params *param)
11057{
11058 wmi_buf_t buf;
11059 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11060 int32_t len = sizeof(*cmd);
11061
11062 buf = wmi_buf_alloc(wmi_handle, len);
11063 if (!buf) {
11064 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11065 return QDF_STATUS_E_FAILURE;
11066 }
11067
11068 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11069 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011070 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011071
11072 cmd->vdev_id = param->vdev_id;
11073 cmd->enable_override = 0;
11074
11075 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11076 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11077 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11078 WMI_LOGE("Failed to set dscp cmd\n");
11079 wmi_buf_free(buf);
11080 return QDF_STATUS_E_FAILURE;
11081 }
11082
11083 return QDF_STATUS_SUCCESS;
11084}
11085
11086/**
11087 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11088 * @wmi_handle: wmi handle
11089 * @macaddr: vdev mac address
11090 * @param: pointer to hold neigbour rx param
11091 *
11092 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11093 */
11094static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11095 uint8_t macaddr[IEEE80211_ADDR_LEN],
11096 struct set_neighbour_rx_params *param)
11097{
11098 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11099 wmi_buf_t buf;
11100 int32_t len = sizeof(*cmd);
11101
11102 buf = wmi_buf_alloc(wmi_handle, len);
11103 if (!buf) {
11104 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11105 return QDF_STATUS_E_FAILURE;
11106 }
11107 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11108 WMITLV_SET_HDR(&cmd->tlv_header,
11109 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11110 WMITLV_GET_STRUCT_TLVLEN(
11111 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11112 cmd->vdev_id = param->vdev_id;
11113 cmd->bssid_idx = param->idx;
11114 cmd->action = param->action;
11115 cmd->type = param->type;
11116 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11117 cmd->flag = 0;
11118
11119 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11120 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11121 WMI_LOGE("Failed to set neighbour rx param\n");
11122 wmi_buf_free(buf);
11123 return QDF_STATUS_E_FAILURE;
11124 }
11125
11126 return QDF_STATUS_SUCCESS;
11127}
11128
11129/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011130 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011131 * @param wmi_handle : handle to WMI.
11132 * @param macaddr : vdev mac address
11133 * @param param : pointer to tx antenna param
11134 *
11135 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11136 */
11137static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11138 uint8_t macaddr[IEEE80211_ADDR_LEN],
11139 struct smart_ant_tx_ant_params *param)
11140{
11141 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11142 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11143 wmi_buf_t buf;
11144 int32_t len = 0;
11145 int i;
11146 uint8_t *buf_ptr;
11147 QDF_STATUS ret;
11148
11149 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11150 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11151 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11152 buf = wmi_buf_alloc(wmi_handle, len);
11153
11154 if (!buf) {
11155 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11156 return QDF_STATUS_E_NOMEM;
11157 }
11158
11159 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11160 qdf_mem_zero(buf_ptr, len);
11161 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11162
11163 WMITLV_SET_HDR(&cmd->tlv_header,
11164 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11165 WMITLV_GET_STRUCT_TLVLEN(
11166 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11167
11168 cmd->vdev_id = param->vdev_id;
11169 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11170
11171 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11173 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11174 buf_ptr += WMI_TLV_HDR_SIZE;
11175 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11176
11177 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11178 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11179 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11180 WMITLV_GET_STRUCT_TLVLEN(
11181 wmi_peer_smart_ant_set_tx_antenna_series));
11182 ant_tx_series->antenna_series = param->antenna_array[i];
11183 ant_tx_series++;
11184 }
11185
11186 ret = wmi_unified_cmd_send(wmi_handle,
11187 buf,
11188 len,
11189 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11190
11191 if (ret != 0) {
11192 WMI_LOGE(" %s :WMI Failed\n", __func__);
11193 wmi_buf_free(buf);
11194 }
11195
11196 return ret;
11197}
11198
Sathish Kumar02c3b542017-02-22 17:24:45 +053011199/**
11200 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11201 * @wmi_handle: wmi handle
11202 * @param: pointer to hold ant switch tbl param
11203 *
11204 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11205 */
11206static QDF_STATUS
11207send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11208 struct ant_switch_tbl_params *param)
11209{
11210 uint8_t len;
11211 wmi_buf_t buf;
11212 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11213 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11214 uint8_t *buf_ptr;
11215
11216 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11217 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11218 buf = wmi_buf_alloc(wmi_handle, len);
11219
11220 if (!buf) {
11221 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11222 return QDF_STATUS_E_NOMEM;
11223 }
11224
11225 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11226 qdf_mem_zero(buf_ptr, len);
11227 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11228
11229 WMITLV_SET_HDR(&cmd->tlv_header,
11230 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11231 WMITLV_GET_STRUCT_TLVLEN(
11232 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11233
11234 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11235 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011236 cmd->mac_id =
11237 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011238
11239 /* TLV indicating array of structures to follow */
11240 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11242 sizeof(wmi_pdev_set_ant_ctrl_chain));
11243 buf_ptr += WMI_TLV_HDR_SIZE;
11244 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11245
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011246 ctrl_chain->pdev_id =
11247 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011248 ctrl_chain->antCtrlChain = param->antCtrlChain;
11249
11250 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11251 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11252 wmi_buf_free(buf);
11253 return QDF_STATUS_E_FAILURE;
11254 }
11255
11256 return QDF_STATUS_SUCCESS;
11257}
11258
11259/**
11260 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11261 * training information function
11262 * @param wmi_handle : handle to WMI.
11263 * @macaddr : vdev mac address
11264 * @param param : pointer to tx antenna param
11265 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11266 */
11267static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11268 wmi_unified_t wmi_handle,
11269 uint8_t macaddr[IEEE80211_ADDR_LEN],
11270 struct smart_ant_training_info_params *param)
11271{
11272 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11273 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11274 wmi_buf_t buf;
11275 uint8_t *buf_ptr;
11276 int32_t len = 0;
11277 QDF_STATUS ret;
11278 int loop;
11279
11280 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11281 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11282 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11283 buf = wmi_buf_alloc(wmi_handle, len);
11284
11285 if (!buf) {
11286 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11287 return QDF_STATUS_E_NOMEM;
11288 }
11289
11290 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11291 qdf_mem_zero(buf_ptr, len);
11292 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11293
11294 WMITLV_SET_HDR(&cmd->tlv_header,
11295 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11296 WMITLV_GET_STRUCT_TLVLEN(
11297 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11298
11299 cmd->vdev_id = param->vdev_id;
11300 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11301 cmd->num_pkts = param->numpkts;
11302
11303 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11304 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11305 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11306 WMI_SMART_ANT_MAX_RATE_SERIES);
11307
11308 buf_ptr += WMI_TLV_HDR_SIZE;
11309 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11310
11311 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11312 WMITLV_SET_HDR(&train_param->tlv_header,
11313 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11314 WMITLV_GET_STRUCT_TLVLEN(
11315 wmi_peer_smart_ant_set_train_antenna_param));
11316 train_param->train_rate_series = param->rate_array[loop];
11317 train_param->train_antenna_series = param->antenna_array[loop];
11318 train_param->rc_flags = 0;
11319 WMI_LOGI(FL("Series number:%d\n"), loop);
11320 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11321 train_param->train_rate_series,
11322 train_param->train_antenna_series);
11323 train_param++;
11324 }
11325
11326 ret = wmi_unified_cmd_send(wmi_handle,
11327 buf,
11328 len,
11329 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11330
11331 if (ret != 0) {
11332 WMI_LOGE(" %s :WMI Failed\n", __func__);
11333 wmi_buf_free(buf);
11334 return QDF_STATUS_E_FAILURE;
11335 }
11336
11337 return ret;
11338}
11339
11340/**
11341 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11342 * configuration function
11343 * @param wmi_handle : handle to WMI.
11344 * @macaddr : vdev mad address
11345 * @param param : pointer to tx antenna param
11346 *
11347 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11348 */
11349static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11350 wmi_unified_t wmi_handle,
11351 uint8_t macaddr[IEEE80211_ADDR_LEN],
11352 struct smart_ant_node_config_params *param)
11353{
11354 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11355 wmi_buf_t buf;
11356 uint8_t *buf_ptr;
11357 int32_t len = 0, args_tlv_len;
11358 int ret;
11359 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011360 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011361
Vivekc5823092018-03-22 23:27:21 +053011362 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011363 len = sizeof(*cmd) + args_tlv_len;
11364
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011365 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011366 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11367 __func__, param->args_count);
11368 return QDF_STATUS_E_FAILURE;
11369 }
11370
11371 buf = wmi_buf_alloc(wmi_handle, len);
11372 if (!buf) {
11373 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11374 return QDF_STATUS_E_NOMEM;
11375 }
11376
11377 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11378 wmi_buf_data(buf);
11379 buf_ptr = (uint8_t *)cmd;
11380 WMITLV_SET_HDR(&cmd->tlv_header,
11381 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11382 WMITLV_GET_STRUCT_TLVLEN(
11383 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11384 cmd->vdev_id = param->vdev_id;
11385 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11386 cmd->cmd_id = param->cmd_id;
11387 cmd->args_count = param->args_count;
11388 buf_ptr += sizeof(
11389 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011391 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011392 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011393 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011394
11395 for (i = 0; i < param->args_count; i++) {
11396 node_config_args[i] = param->args_arr[i];
11397 WMI_LOGI("%d", param->args_arr[i]);
11398 }
11399
11400 ret = wmi_unified_cmd_send(wmi_handle,
11401 buf,
11402 len,
11403 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11404
11405 if (ret != 0) {
11406 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11407 __func__, param->cmd_id, macaddr[0],
11408 macaddr[1], macaddr[2], macaddr[3],
11409 macaddr[4], macaddr[5], ret);
11410 wmi_buf_free(buf);
11411 }
11412
11413 return ret;
11414}
11415
Jeffin Mammen095050b2018-07-24 14:20:08 +053011416#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053011417/**
11418 * send_set_atf_cmd_tlv() - send set atf command to fw
11419 * @wmi_handle: wmi handle
11420 * @param: pointer to set atf param
11421 *
11422 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11423 */
11424static QDF_STATUS
11425send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11426 struct set_atf_params *param)
11427{
11428 wmi_atf_peer_info *peer_info;
11429 wmi_peer_atf_request_fixed_param *cmd;
11430 wmi_buf_t buf;
11431 uint8_t *buf_ptr;
11432 int i;
11433 int32_t len = 0;
11434 QDF_STATUS retval;
11435
11436 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11437 len += param->num_peers * sizeof(wmi_atf_peer_info);
11438 buf = wmi_buf_alloc(wmi_handle, len);
11439 if (!buf) {
11440 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11441 return QDF_STATUS_E_FAILURE;
11442 }
11443 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11444 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11445 WMITLV_SET_HDR(&cmd->tlv_header,
11446 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11447 WMITLV_GET_STRUCT_TLVLEN(
11448 wmi_peer_atf_request_fixed_param));
11449 cmd->num_peers = param->num_peers;
11450
11451 buf_ptr += sizeof(*cmd);
11452 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11453 sizeof(wmi_atf_peer_info) *
11454 cmd->num_peers);
11455 buf_ptr += WMI_TLV_HDR_SIZE;
11456 peer_info = (wmi_atf_peer_info *)buf_ptr;
11457
11458 for (i = 0; i < cmd->num_peers; i++) {
11459 WMITLV_SET_HDR(&peer_info->tlv_header,
11460 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11461 WMITLV_GET_STRUCT_TLVLEN(
11462 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011463 qdf_mem_copy(&(peer_info->peer_macaddr),
11464 &(param->peer_info[i].peer_macaddr),
11465 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011466 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011467 peer_info->vdev_id = param->peer_info[i].vdev_id;
11468 peer_info->pdev_id =
11469 wmi_handle->ops->convert_pdev_id_host_to_target(
11470 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011471 /*
11472 * TLV definition for peer atf request fixed param combines
11473 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11474 * stats and atf extension stats as two different
11475 * implementations.
11476 * Need to discuss with FW on this.
11477 *
11478 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11479 * peer_info->atf_units_reserved =
11480 * param->peer_ext_info[i].atf_index_reserved;
11481 */
11482 peer_info++;
11483 }
11484
11485 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11486 WMI_PEER_ATF_REQUEST_CMDID);
11487
11488 if (retval != QDF_STATUS_SUCCESS) {
11489 WMI_LOGE("%s : WMI Failed\n", __func__);
11490 wmi_buf_free(buf);
11491 }
11492
11493 return retval;
11494}
Jeffin Mammen095050b2018-07-24 14:20:08 +053011495#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053011496
11497/**
11498 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11499 * @wmi_handle: wmi handle
11500 * @param: pointer to hold fwtest param
11501 *
11502 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11503 */
11504static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11505 struct set_fwtest_params *param)
11506{
11507 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11508 wmi_buf_t buf;
11509 int32_t len = sizeof(*cmd);
11510
11511 buf = wmi_buf_alloc(wmi_handle, len);
11512
11513 if (!buf) {
11514 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11515 return QDF_STATUS_E_FAILURE;
11516 }
11517
11518 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11519 WMITLV_SET_HDR(&cmd->tlv_header,
11520 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11521 WMITLV_GET_STRUCT_TLVLEN(
11522 wmi_fwtest_set_param_cmd_fixed_param));
11523 cmd->param_id = param->arg;
11524 cmd->param_value = param->value;
11525
11526 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11527 WMI_LOGE("Setting FW test param failed\n");
11528 wmi_buf_free(buf);
11529 return QDF_STATUS_E_FAILURE;
11530 }
11531
11532 return QDF_STATUS_SUCCESS;
11533}
11534
11535/**
11536 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11537 * @wmi_handle: wmi handle
11538 * @param: pointer to qboost params
11539 * @macaddr: vdev mac address
11540 *
11541 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11542 */
11543static QDF_STATUS
11544send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11545 uint8_t macaddr[IEEE80211_ADDR_LEN],
11546 struct set_qboost_params *param)
11547{
11548 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11549 wmi_buf_t buf;
11550 int32_t len;
11551 QDF_STATUS ret;
11552
11553 len = sizeof(*cmd);
11554
11555 buf = wmi_buf_alloc(wmi_handle, len);
11556 if (!buf) {
11557 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11558 return QDF_STATUS_E_FAILURE;
11559 }
11560
11561 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11562 WMITLV_SET_HDR(&cmd->tlv_header,
11563 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11564 WMITLV_GET_STRUCT_TLVLEN(
11565 WMI_QBOOST_CFG_CMD_fixed_param));
11566 cmd->vdev_id = param->vdev_id;
11567 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11568 cmd->qb_enable = param->value;
11569
11570 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11571 WMI_QBOOST_CFG_CMDID);
11572
11573 if (ret != 0) {
11574 WMI_LOGE("Setting qboost cmd failed\n");
11575 wmi_buf_free(buf);
11576 }
11577
11578 return ret;
11579}
11580
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011581/**
11582 * send_gpio_config_cmd_tlv() - send gpio config to fw
11583 * @wmi_handle: wmi handle
11584 * @param: pointer to hold gpio config param
11585 *
11586 * Return: 0 for success or error code
11587 */
11588static QDF_STATUS
11589send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11590 struct gpio_config_params *param)
11591{
11592 wmi_gpio_config_cmd_fixed_param *cmd;
11593 wmi_buf_t buf;
11594 int32_t len;
11595 QDF_STATUS ret;
11596
11597 len = sizeof(*cmd);
11598
11599 /* Sanity Checks */
11600 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11601 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11602 return QDF_STATUS_E_FAILURE;
11603 }
11604
11605 buf = wmi_buf_alloc(wmi_handle, len);
11606 if (!buf) {
11607 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11608 return QDF_STATUS_E_FAILURE;
11609 }
11610
11611 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11612 WMITLV_SET_HDR(&cmd->tlv_header,
11613 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11614 WMITLV_GET_STRUCT_TLVLEN(
11615 wmi_gpio_config_cmd_fixed_param));
11616 cmd->gpio_num = param->gpio_num;
11617 cmd->input = param->input;
11618 cmd->pull_type = param->pull_type;
11619 cmd->intr_mode = param->intr_mode;
11620
11621 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11622 WMI_GPIO_CONFIG_CMDID);
11623
11624 if (ret != 0) {
11625 WMI_LOGE("Sending GPIO config cmd failed\n");
11626 wmi_buf_free(buf);
11627 }
11628
11629 return ret;
11630}
11631
11632/**
11633 * send_gpio_output_cmd_tlv() - send gpio output to fw
11634 * @wmi_handle: wmi handle
11635 * @param: pointer to hold gpio output param
11636 *
11637 * Return: 0 for success or error code
11638 */
11639static QDF_STATUS
11640send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11641 struct gpio_output_params *param)
11642{
11643 wmi_gpio_output_cmd_fixed_param *cmd;
11644 wmi_buf_t buf;
11645 int32_t len;
11646 QDF_STATUS ret;
11647
11648 len = sizeof(*cmd);
11649
11650 buf = wmi_buf_alloc(wmi_handle, len);
11651 if (!buf) {
11652 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11653 return QDF_STATUS_E_FAILURE;
11654 }
11655
11656 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11657 WMITLV_SET_HDR(&cmd->tlv_header,
11658 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11659 WMITLV_GET_STRUCT_TLVLEN(
11660 wmi_gpio_output_cmd_fixed_param));
11661 cmd->gpio_num = param->gpio_num;
11662 cmd->set = param->set;
11663
11664 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11665 WMI_GPIO_OUTPUT_CMDID);
11666
11667 if (ret != 0) {
11668 WMI_LOGE("Sending GPIO output cmd failed\n");
11669 wmi_buf_free(buf);
11670 }
11671
11672 return ret;
11673
11674}
11675
11676/**
11677 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11678 *
11679 * @param wmi_handle : handle to WMI.
11680 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11681 */
11682static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11683{
11684 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11685 wmi_buf_t buf;
11686 QDF_STATUS ret;
11687 int32_t len;
11688
11689 len = sizeof(*cmd);
11690
11691 buf = wmi_buf_alloc(wmi_handle, len);
11692 if (!buf) {
11693 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11694 return QDF_STATUS_E_FAILURE;
11695 }
11696
11697 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11698 WMITLV_SET_HDR(&cmd->tlv_header,
11699 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11700 WMITLV_GET_STRUCT_TLVLEN(
11701 wmi_pdev_dfs_disable_cmd_fixed_param));
11702 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011703 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11704 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011705
11706 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11707 WMI_PDEV_DFS_DISABLE_CMDID);
11708
11709 if (ret != 0) {
11710 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11711 wmi_buf_free(buf);
11712 }
11713
11714 return ret;
11715}
11716
11717/**
11718 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11719 *
11720 * @param wmi_handle : handle to WMI.
11721 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11722 */
11723static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11724{
11725 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11726 wmi_buf_t buf;
11727 QDF_STATUS ret;
11728 int32_t len;
11729
11730 len = sizeof(*cmd);
11731
11732 buf = wmi_buf_alloc(wmi_handle, len);
11733 if (!buf) {
11734 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11735 return QDF_STATUS_E_FAILURE;
11736 }
11737
11738 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11739 WMITLV_SET_HDR(&cmd->tlv_header,
11740 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11741 WMITLV_GET_STRUCT_TLVLEN(
11742 wmi_pdev_dfs_enable_cmd_fixed_param));
11743 /* Reserved for future use */
11744 cmd->reserved0 = 0;
11745
11746 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11747 WMI_PDEV_DFS_ENABLE_CMDID);
11748
11749 if (ret != 0) {
11750 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11751 wmi_buf_free(buf);
11752 }
11753
11754 return ret;
11755}
11756
11757/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011758 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11759 * to fw
11760 * @wmi_handle: wmi handle
11761 * @param: pointer to hold periodic chan stats param
11762 *
11763 * Return: 0 for success or error code
11764 */
11765static QDF_STATUS
11766send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11767 struct periodic_chan_stats_params *param)
11768{
11769 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11770 wmi_buf_t buf;
11771 QDF_STATUS ret;
11772 int32_t len;
11773
11774 len = sizeof(*cmd);
11775
11776 buf = wmi_buf_alloc(wmi_handle, len);
11777 if (!buf) {
11778 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11779 return QDF_STATUS_E_FAILURE;
11780 }
11781
11782 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11783 wmi_buf_data(buf);
11784 WMITLV_SET_HDR(&cmd->tlv_header,
11785 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11786 WMITLV_GET_STRUCT_TLVLEN(
11787 wmi_set_periodic_channel_stats_config_fixed_param));
11788 cmd->enable = param->enable;
11789 cmd->stats_period = param->stats_period;
11790 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11791 param->pdev_id);
11792
11793 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11794 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11795
11796 if (ret != 0) {
11797 WMI_LOGE("Sending periodic chan stats config failed");
11798 wmi_buf_free(buf);
11799 }
11800
11801 return ret;
11802}
11803
11804/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011805 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11806 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011807 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011808 *
11809 * Return: 0 for success or error code
11810 */
11811static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011812send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011813{
11814 wmi_buf_t buf;
11815 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011816 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11817 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011818
nobeljf74583b2018-01-25 16:35:36 -080011819 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011820 if (buf == NULL)
11821 return QDF_STATUS_E_NOMEM;
11822
nobeljf74583b2018-01-25 16:35:36 -080011823 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11824 WMITLV_SET_HDR(&cmd->tlv_header,
11825 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11826 WMITLV_GET_STRUCT_TLVLEN
11827 (wmi_pdev_get_nfcal_power_fixed_param));
11828 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11829
11830 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011831 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11832 if (ret != 0) {
11833 WMI_LOGE("Sending get nfcal power cmd failed\n");
11834 wmi_buf_free(buf);
11835 }
11836
11837 return ret;
11838}
11839
11840/**
11841 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11842 * @wmi_handle: wmi handle
11843 * @param: pointer to ht ie param
11844 *
11845 * Return: 0 for success or error code
11846 */
11847static QDF_STATUS
11848send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11849 struct ht_ie_params *param)
11850{
11851 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11852 wmi_buf_t buf;
11853 QDF_STATUS ret;
11854 int32_t len;
11855 uint8_t *buf_ptr;
11856
11857 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11858 roundup(param->ie_len, sizeof(uint32_t));
11859
11860 buf = wmi_buf_alloc(wmi_handle, len);
11861 if (!buf) {
11862 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11863 return QDF_STATUS_E_FAILURE;
11864 }
11865
11866 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11867 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11868 WMITLV_SET_HDR(&cmd->tlv_header,
11869 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11870 WMITLV_GET_STRUCT_TLVLEN(
11871 wmi_pdev_set_ht_ie_cmd_fixed_param));
11872 cmd->reserved0 = 0;
11873 cmd->ie_len = param->ie_len;
11874 cmd->tx_streams = param->tx_streams;
11875 cmd->rx_streams = param->rx_streams;
11876
11877 buf_ptr += sizeof(*cmd);
11878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11879 buf_ptr += WMI_TLV_HDR_SIZE;
11880 if (param->ie_len)
11881 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11882 cmd->ie_len);
11883
11884 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11885 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11886
11887 if (ret != 0) {
11888 WMI_LOGE("Sending set ht ie cmd failed\n");
11889 wmi_buf_free(buf);
11890 }
11891
11892 return ret;
11893}
11894
11895/**
11896 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11897 * @wmi_handle: wmi handle
11898 * @param: pointer to vht ie param
11899 *
11900 * Return: 0 for success or error code
11901 */
11902static QDF_STATUS
11903send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11904 struct vht_ie_params *param)
11905{
11906 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11907 wmi_buf_t buf;
11908 QDF_STATUS ret;
11909 int32_t len;
11910 uint8_t *buf_ptr;
11911
11912 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11913 roundup(param->ie_len, sizeof(uint32_t));
11914
11915 buf = wmi_buf_alloc(wmi_handle, len);
11916 if (!buf) {
11917 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11918 return QDF_STATUS_E_FAILURE;
11919 }
11920
11921 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11922 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11923 WMITLV_SET_HDR(&cmd->tlv_header,
11924 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11925 WMITLV_GET_STRUCT_TLVLEN(
11926 wmi_pdev_set_vht_ie_cmd_fixed_param));
11927 cmd->reserved0 = 0;
11928 cmd->ie_len = param->ie_len;
11929 cmd->tx_streams = param->tx_streams;
11930 cmd->rx_streams = param->rx_streams;
11931
11932 buf_ptr += sizeof(*cmd);
11933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11934 buf_ptr += WMI_TLV_HDR_SIZE;
11935 if (param->ie_len)
11936 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11937 cmd->ie_len);
11938
11939 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11940 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11941
11942 if (ret != 0) {
11943 WMI_LOGE("Sending set vht ie cmd failed\n");
11944 wmi_buf_free(buf);
11945 }
11946
11947 return ret;
11948}
11949
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011950/**
11951 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11952 * @wmi_handle: wmi handle
11953 * @param: pointer to quiet mode params
11954 *
11955 * Return: 0 for success or error code
11956 */
11957static QDF_STATUS
11958send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11959 struct set_quiet_mode_params *param)
11960{
11961 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11962 wmi_buf_t buf;
11963 QDF_STATUS ret;
11964 int32_t len;
11965
11966 len = sizeof(*quiet_cmd);
11967 buf = wmi_buf_alloc(wmi_handle, len);
11968 if (!buf) {
11969 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11970 return QDF_STATUS_E_FAILURE;
11971 }
11972
11973 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11974 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11975 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11976 WMITLV_GET_STRUCT_TLVLEN(
11977 wmi_pdev_set_quiet_cmd_fixed_param));
11978 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11979 quiet_cmd->enabled = param->enabled;
11980 quiet_cmd->period = (param->period)*(param->intval);
11981 quiet_cmd->duration = param->duration;
11982 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011983 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11984 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011985
11986 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11987 WMI_PDEV_SET_QUIET_MODE_CMDID);
11988
11989 if (ret != 0) {
11990 WMI_LOGE("Sending set quiet cmd failed\n");
11991 wmi_buf_free(buf);
11992 }
11993
11994 return ret;
11995}
11996
11997/**
11998 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11999 * @wmi_handle: wmi handle
12000 * @param: pointer to set bwf param
12001 *
12002 * Return: 0 for success or error code
12003 */
12004static QDF_STATUS
12005send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12006 struct set_bwf_params *param)
12007{
12008 wmi_bwf_peer_info *peer_info;
12009 wmi_peer_bwf_request_fixed_param *cmd;
12010 wmi_buf_t buf;
12011 QDF_STATUS retval;
12012 int32_t len;
12013 uint8_t *buf_ptr;
12014 int i;
12015
12016 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12017 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12018 buf = wmi_buf_alloc(wmi_handle, len);
12019 if (!buf) {
12020 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12021 return QDF_STATUS_E_FAILURE;
12022 }
12023 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12024 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12025 WMITLV_SET_HDR(&cmd->tlv_header,
12026 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12027 WMITLV_GET_STRUCT_TLVLEN(
12028 wmi_peer_bwf_request_fixed_param));
12029 cmd->num_peers = param->num_peers;
12030
12031 buf_ptr += sizeof(*cmd);
12032 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12033 sizeof(wmi_bwf_peer_info) *
12034 cmd->num_peers);
12035 buf_ptr += WMI_TLV_HDR_SIZE;
12036 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12037
12038 for (i = 0; i < cmd->num_peers; i++) {
12039 WMITLV_SET_HDR(&peer_info->tlv_header,
12040 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12041 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12042 peer_info->bwf_guaranteed_bandwidth =
12043 param->peer_info[i].throughput;
12044 peer_info->bwf_max_airtime =
12045 param->peer_info[i].max_airtime;
12046 peer_info->bwf_peer_priority =
12047 param->peer_info[i].priority;
12048 qdf_mem_copy(&peer_info->peer_macaddr,
12049 &param->peer_info[i].peer_macaddr,
12050 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012051 peer_info->vdev_id =
12052 param->peer_info[i].vdev_id;
12053 peer_info->pdev_id =
12054 wmi_handle->ops->convert_pdev_id_host_to_target(
12055 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012056 peer_info++;
12057 }
12058
12059 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12060 WMI_PEER_BWF_REQUEST_CMDID);
12061
12062 if (retval != QDF_STATUS_SUCCESS) {
12063 WMI_LOGE("%s : WMI Failed\n", __func__);
12064 wmi_buf_free(buf);
12065 }
12066
12067 return retval;
12068}
12069
12070/**
12071 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12072 * @wmi_handle: wmi handle
12073 * @param: pointer to hold mcast update param
12074 *
12075 * Return: 0 for success or error code
12076 */
12077static QDF_STATUS
12078send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12079 struct mcast_group_update_params *param)
12080{
12081 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12082 wmi_buf_t buf;
12083 QDF_STATUS ret;
12084 int32_t len;
12085 int offset = 0;
12086 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12087
12088 len = sizeof(*cmd);
12089 buf = wmi_buf_alloc(wmi_handle, len);
12090 if (!buf) {
12091 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12092 return QDF_STATUS_E_FAILURE;
12093 }
12094 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12095 WMITLV_SET_HDR(&cmd->tlv_header,
12096 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12097 WMITLV_GET_STRUCT_TLVLEN(
12098 wmi_peer_mcast_group_cmd_fixed_param));
12099 /* confirm the buffer is 4-byte aligned */
12100 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12101 qdf_mem_zero(cmd, sizeof(*cmd));
12102
12103 cmd->vdev_id = param->vap_id;
12104 /* construct the message assuming our endianness matches the target */
12105 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12106 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12107 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12108 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12109 if (param->is_action_delete)
12110 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12111
12112 if (param->is_mcast_addr_len)
12113 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12114
12115 if (param->is_filter_mode_snoop)
12116 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12117
12118 /* unicast address spec only applies for non-wildcard cases */
12119 if (!param->wildcard && param->ucast_mac_addr) {
12120 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12121 &cmd->ucast_mac_addr);
12122 }
Amar Singhal5593c902017-10-03 13:00:29 -070012123
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012124 if (param->mcast_ip_addr) {
12125 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12126 sizeof(cmd->mcast_ip_addr));
12127 offset = sizeof(cmd->mcast_ip_addr) -
12128 param->mcast_ip_addr_bytes;
12129 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12130 param->mcast_ip_addr,
12131 param->mcast_ip_addr_bytes);
12132 }
12133 if (!param->mask)
12134 param->mask = &dummymask[0];
12135
12136 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12137 param->mask,
12138 param->mcast_ip_addr_bytes);
12139
12140 if (param->srcs && param->nsrcs) {
12141 cmd->num_filter_addr = param->nsrcs;
12142 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12143 sizeof(cmd->filter_addr));
12144
12145 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12146 param->nsrcs * param->mcast_ip_addr_bytes);
12147 }
12148
12149 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12150 WMI_PEER_MCAST_GROUP_CMDID);
12151
12152 if (ret != QDF_STATUS_SUCCESS) {
12153 WMI_LOGE("%s : WMI Failed\n", __func__);
12154 wmi_buf_free(buf);
12155 }
12156
12157 return ret;
12158}
12159
12160/**
12161 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12162 * command to fw
12163 * @wmi_handle: wmi handle
12164 * @param: pointer to hold spectral config parameter
12165 *
12166 * Return: 0 for success or error code
12167 */
12168static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12169 struct vdev_spectral_configure_params *param)
12170{
12171 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12172 wmi_buf_t buf;
12173 QDF_STATUS ret;
12174 int32_t len;
12175
12176 len = sizeof(*cmd);
12177 buf = wmi_buf_alloc(wmi_handle, len);
12178 if (!buf) {
12179 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12180 return QDF_STATUS_E_FAILURE;
12181 }
12182
12183 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12184 WMITLV_SET_HDR(&cmd->tlv_header,
12185 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12186 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012187 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012188
12189 cmd->vdev_id = param->vdev_id;
12190 cmd->spectral_scan_count = param->count;
12191 cmd->spectral_scan_period = param->period;
12192 cmd->spectral_scan_priority = param->spectral_pri;
12193 cmd->spectral_scan_fft_size = param->fft_size;
12194 cmd->spectral_scan_gc_ena = param->gc_enable;
12195 cmd->spectral_scan_restart_ena = param->restart_enable;
12196 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12197 cmd->spectral_scan_init_delay = param->init_delay;
12198 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12199 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12200 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12201 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12202 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12203 cmd->spectral_scan_pwr_format = param->pwr_format;
12204 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12205 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012206 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012207 cmd->spectral_scan_chn_mask = param->chn_mask;
12208
12209 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12210 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12211
12212 if (ret != 0) {
12213 WMI_LOGE("Sending set quiet cmd failed\n");
12214 wmi_buf_free(buf);
12215 }
12216
12217 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12218 __func__);
12219
12220 WMI_LOGI("vdev_id = %u\n"
12221 "spectral_scan_count = %u\n"
12222 "spectral_scan_period = %u\n"
12223 "spectral_scan_priority = %u\n"
12224 "spectral_scan_fft_size = %u\n"
12225 "spectral_scan_gc_ena = %u\n"
12226 "spectral_scan_restart_ena = %u\n"
12227 "spectral_scan_noise_floor_ref = %u\n"
12228 "spectral_scan_init_delay = %u\n"
12229 "spectral_scan_nb_tone_thr = %u\n"
12230 "spectral_scan_str_bin_thr = %u\n"
12231 "spectral_scan_wb_rpt_mode = %u\n"
12232 "spectral_scan_rssi_rpt_mode = %u\n"
12233 "spectral_scan_rssi_thr = %u\n"
12234 "spectral_scan_pwr_format = %u\n"
12235 "spectral_scan_rpt_mode = %u\n"
12236 "spectral_scan_bin_scale = %u\n"
12237 "spectral_scan_dBm_adj = %u\n"
12238 "spectral_scan_chn_mask = %u\n",
12239 param->vdev_id,
12240 param->count,
12241 param->period,
12242 param->spectral_pri,
12243 param->fft_size,
12244 param->gc_enable,
12245 param->restart_enable,
12246 param->noise_floor_ref,
12247 param->init_delay,
12248 param->nb_tone_thr,
12249 param->str_bin_thr,
12250 param->wb_rpt_mode,
12251 param->rssi_rpt_mode,
12252 param->rssi_thr,
12253 param->pwr_format,
12254 param->rpt_mode,
12255 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012256 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012257 param->chn_mask);
12258 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12259
12260 return ret;
12261}
12262
12263/**
12264 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12265 * command to fw
12266 * @wmi_handle: wmi handle
12267 * @param: pointer to hold spectral enable parameter
12268 *
12269 * Return: 0 for success or error code
12270 */
12271static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12272 struct vdev_spectral_enable_params *param)
12273{
12274 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12275 wmi_buf_t buf;
12276 QDF_STATUS ret;
12277 int32_t len;
12278
12279 len = sizeof(*cmd);
12280 buf = wmi_buf_alloc(wmi_handle, len);
12281 if (!buf) {
12282 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12283 return QDF_STATUS_E_FAILURE;
12284 }
12285
12286 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12287 WMITLV_SET_HDR(&cmd->tlv_header,
12288 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12289 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012290 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012291
12292 cmd->vdev_id = param->vdev_id;
12293
12294 if (param->active_valid) {
12295 cmd->trigger_cmd = param->active ? 1 : 2;
12296 /* 1: Trigger, 2: Clear Trigger */
12297 } else {
12298 cmd->trigger_cmd = 0; /* 0: Ignore */
12299 }
12300
12301 if (param->enabled_valid) {
12302 cmd->enable_cmd = param->enabled ? 1 : 2;
12303 /* 1: Enable 2: Disable */
12304 } else {
12305 cmd->enable_cmd = 0; /* 0: Ignore */
12306 }
12307
12308 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12309 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12310
12311 if (ret != 0) {
12312 WMI_LOGE("Sending scan enable CMD failed\n");
12313 wmi_buf_free(buf);
12314 }
12315
12316 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12317
12318 WMI_LOGI("vdev_id = %u\n"
12319 "trigger_cmd = %u\n"
12320 "enable_cmd = %u\n",
12321 cmd->vdev_id,
12322 cmd->trigger_cmd,
12323 cmd->enable_cmd);
12324
12325 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12326
12327 return ret;
12328}
12329
12330/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012331 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12332 * @param wmi_handle : handle to WMI.
12333 * @param param : pointer to hold thermal mitigation param
12334 *
12335 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12336 */
12337static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12338 wmi_unified_t wmi_handle,
12339 struct thermal_mitigation_params *param)
12340{
12341 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12342 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12343 wmi_buf_t buf = NULL;
12344 uint8_t *buf_ptr = NULL;
12345 int error;
12346 int32_t len;
12347 int i;
12348
12349 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12350 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12351
12352 buf = wmi_buf_alloc(wmi_handle, len);
12353 if (!buf) {
12354 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12355 return QDF_STATUS_E_NOMEM;
12356 }
12357 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12358
12359 /* init fixed params */
12360 WMITLV_SET_HDR(tt_conf,
12361 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12362 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12363
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012364 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12365 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012366 tt_conf->enable = param->enable;
12367 tt_conf->dc = param->dc;
12368 tt_conf->dc_per_event = param->dc_per_event;
12369 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12370
12371 buf_ptr = (uint8_t *) ++tt_conf;
12372 /* init TLV params */
12373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12374 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12375
12376 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12377 for (i = 0; i < THERMAL_LEVELS; i++) {
12378 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12379 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12380 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12381 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12382 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12383 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12384 lvl_conf->prio = param->levelconf[i].priority;
12385 lvl_conf++;
12386 }
12387
12388 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12389 WMI_THERM_THROT_SET_CONF_CMDID);
12390 if (QDF_IS_STATUS_ERROR(error)) {
12391 wmi_buf_free(buf);
12392 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12393 }
12394
12395 return error;
12396}
12397
12398/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012399 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12400 * @wmi_handle: wmi handle
12401 * @param: pointer to pdev_qvit_params
12402 *
12403 * Return: 0 for success or error code
12404 */
12405static QDF_STATUS
12406send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12407 struct pdev_qvit_params *param)
12408{
12409 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012410 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012411 uint8_t *cmd;
12412 static uint8_t msgref = 1;
12413 uint8_t segnumber = 0, seginfo, numsegments;
12414 uint16_t chunk_len, total_bytes;
12415 uint8_t *bufpos;
12416 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12417
12418 bufpos = param->utf_payload;
12419 total_bytes = param->len;
12420 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12421 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12422 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12423
12424 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12425 numsegments++;
12426
12427 while (param->len) {
12428 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012429 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012430 else
12431 chunk_len = param->len;
12432
12433 buf = wmi_buf_alloc(wmi_handle,
12434 (chunk_len + sizeof(seghdrinfo) +
12435 WMI_TLV_HDR_SIZE));
12436 if (!buf) {
12437 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12438 return QDF_STATUS_E_NOMEM;
12439 }
12440
12441 cmd = (uint8_t *) wmi_buf_data(buf);
12442
12443 seghdrinfo.len = total_bytes;
12444 seghdrinfo.msgref = msgref;
12445 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12446 seghdrinfo.segmentInfo = seginfo;
12447
12448 segnumber++;
12449
12450 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12451 (chunk_len + sizeof(seghdrinfo)));
12452 cmd += WMI_TLV_HDR_SIZE;
12453 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12454 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12455
12456 ret = wmi_unified_cmd_send(wmi_handle, buf,
12457 (chunk_len + sizeof(seghdrinfo) +
12458 WMI_TLV_HDR_SIZE),
12459 WMI_PDEV_QVIT_CMDID);
12460
12461 if (ret != 0) {
12462 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12463 wmi_buf_free(buf);
12464 break;
12465 }
12466
12467 param->len -= chunk_len;
12468 bufpos += chunk_len;
12469 }
12470 msgref++;
12471
12472 return ret;
12473}
12474
12475/**
12476 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12477 * @wmi_handle: wmi handle
12478 * @param: pointer to wmm update param
12479 *
12480 * Return: 0 for success or error code
12481 */
12482static QDF_STATUS
12483send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12484 struct wmm_update_params *param)
12485{
12486 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12487 wmi_wmm_params *wmm_param;
12488 wmi_buf_t buf;
12489 QDF_STATUS ret;
12490 int32_t len;
12491 int ac = 0;
12492 struct wmi_host_wmeParams *wmep;
12493 uint8_t *buf_ptr;
12494
12495 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12496 buf = wmi_buf_alloc(wmi_handle, len);
12497 if (!buf) {
12498 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12499 return QDF_STATUS_E_FAILURE;
12500 }
12501
12502 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12503 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12504 WMITLV_SET_HDR(&cmd->tlv_header,
12505 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12506 WMITLV_GET_STRUCT_TLVLEN
12507 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12508
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012509 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012510
12511 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12512
12513 for (ac = 0; ac < WME_NUM_AC; ac++) {
12514 wmep = &param->wmep_array[ac];
12515 wmm_param = (wmi_wmm_params *)buf_ptr;
12516 WMITLV_SET_HDR(&wmm_param->tlv_header,
12517 WMITLV_TAG_STRUC_wmi_wmm_params,
12518 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12519 wmm_param->aifs = wmep->wmep_aifsn;
12520 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12521 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12522 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12523 wmm_param->acm = wmep->wmep_acm;
12524 wmm_param->no_ack = wmep->wmep_noackPolicy;
12525 buf_ptr += sizeof(wmi_wmm_params);
12526 }
12527 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12528 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12529
12530 if (ret != 0) {
12531 WMI_LOGE("Sending WMM update CMD failed\n");
12532 wmi_buf_free(buf);
12533 }
12534
12535 return ret;
12536}
12537
Sathish Kumar80f4f382017-04-24 11:36:00 +053012538/**
12539 * send_coex_config_cmd_tlv() - send coex config command to fw
12540 * @wmi_handle: wmi handle
12541 * @param: pointer to coex config param
12542 *
12543 * Return: 0 for success or error code
12544 */
12545static QDF_STATUS
12546send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12547 struct coex_config_params *param)
12548{
12549 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12550 wmi_buf_t buf;
12551 QDF_STATUS ret;
12552 int32_t len;
12553
12554 len = sizeof(*cmd);
12555 buf = wmi_buf_alloc(wmi_handle, len);
12556 if (!buf) {
12557 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12558 return QDF_STATUS_E_FAILURE;
12559 }
12560
12561 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12562 WMITLV_SET_HDR(&cmd->tlv_header,
12563 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12564 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012565 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012566
12567 cmd->vdev_id = param->vdev_id;
12568 cmd->config_type = param->config_type;
12569 cmd->config_arg1 = param->config_arg1;
12570 cmd->config_arg2 = param->config_arg2;
12571 cmd->config_arg3 = param->config_arg3;
12572 cmd->config_arg4 = param->config_arg4;
12573 cmd->config_arg5 = param->config_arg5;
12574 cmd->config_arg6 = param->config_arg6;
12575
12576 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12577 WMI_COEX_CONFIG_CMDID);
12578
12579 if (ret != 0) {
12580 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12581 wmi_buf_free(buf);
12582 }
12583
12584 return ret;
12585}
12586
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012587
12588#ifdef WLAN_SUPPORT_TWT
12589static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12590 target_resource_config *tgt_res_cfg)
12591{
12592 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12593 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12594}
12595#else
12596static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12597 target_resource_config *tgt_res_cfg)
12598{
12599 resource_cfg->twt_ap_pdev_count = 0;
12600 resource_cfg->twt_ap_sta_count = 0;
12601}
12602#endif
12603
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012604static
Govind Singh9ddd5162016-03-07 16:30:32 +053012605void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012606 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012607{
Govind Singhe7f2f342016-05-23 12:12:52 +053012608 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012609 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12610 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12611 resource_cfg->num_offload_reorder_buffs =
12612 tgt_res_cfg->num_offload_reorder_buffs;
12613 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12614 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12615 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12616 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12617 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12618 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12619 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12620 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12621 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12622 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12623 resource_cfg->scan_max_pending_req =
12624 tgt_res_cfg->scan_max_pending_req;
12625 resource_cfg->bmiss_offload_max_vdev =
12626 tgt_res_cfg->bmiss_offload_max_vdev;
12627 resource_cfg->roam_offload_max_vdev =
12628 tgt_res_cfg->roam_offload_max_vdev;
12629 resource_cfg->roam_offload_max_ap_profiles =
12630 tgt_res_cfg->roam_offload_max_ap_profiles;
12631 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12632 resource_cfg->num_mcast_table_elems =
12633 tgt_res_cfg->num_mcast_table_elems;
12634 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12635 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12636 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12637 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12638 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12639 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12640 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12641 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12642 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12643 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12644 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12645 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12646 resource_cfg->num_tdls_conn_table_entries =
12647 tgt_res_cfg->num_tdls_conn_table_entries;
12648 resource_cfg->beacon_tx_offload_max_vdev =
12649 tgt_res_cfg->beacon_tx_offload_max_vdev;
12650 resource_cfg->num_multicast_filter_entries =
12651 tgt_res_cfg->num_multicast_filter_entries;
12652 resource_cfg->num_wow_filters =
12653 tgt_res_cfg->num_wow_filters;
12654 resource_cfg->num_keep_alive_pattern =
12655 tgt_res_cfg->num_keep_alive_pattern;
12656 resource_cfg->keep_alive_pattern_size =
12657 tgt_res_cfg->keep_alive_pattern_size;
12658 resource_cfg->max_tdls_concurrent_sleep_sta =
12659 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12660 resource_cfg->max_tdls_concurrent_buffer_sta =
12661 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12662 resource_cfg->wmi_send_separate =
12663 tgt_res_cfg->wmi_send_separate;
12664 resource_cfg->num_ocb_vdevs =
12665 tgt_res_cfg->num_ocb_vdevs;
12666 resource_cfg->num_ocb_channels =
12667 tgt_res_cfg->num_ocb_channels;
12668 resource_cfg->num_ocb_schedules =
12669 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012670 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012671 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12672 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012673 resource_cfg->max_num_dbs_scan_duty_cycle =
12674 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012675 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012676 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12677 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012678
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012679 if (tgt_res_cfg->atf_config)
12680 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12681 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12682 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12683 resource_cfg->flag1, 1);
12684 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12685 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12686 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012687 if (tgt_res_cfg->cce_disable)
12688 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012689
12690 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012691}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012692
12693/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12694 * @wmi_handle: pointer to wmi handle
12695 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012696 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012697 * @param: point host parameters for init command
12698 *
12699 * Return: Updated pointer of buf_ptr.
12700 */
12701static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12702 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12703{
12704 uint16_t idx;
12705
12706 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12707 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12708 wmi_pdev_band_to_mac *band_to_mac;
12709
12710 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12711 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12712 sizeof(wmi_resource_config) +
12713 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12714 sizeof(wlan_host_memory_chunk)));
12715
12716 WMITLV_SET_HDR(&hw_mode->tlv_header,
12717 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12718 (WMITLV_GET_STRUCT_TLVLEN
12719 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12720
12721 hw_mode->hw_mode_index = param->hw_mode_id;
12722 hw_mode->num_band_to_mac = param->num_band_to_mac;
12723
12724 buf_ptr = (uint8_t *) (hw_mode + 1);
12725 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12726 WMI_TLV_HDR_SIZE);
12727 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12728 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12729 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12730 WMITLV_GET_STRUCT_TLVLEN
12731 (wmi_pdev_band_to_mac));
12732 band_to_mac[idx].pdev_id =
12733 wmi_handle->ops->convert_pdev_id_host_to_target(
12734 param->band_to_mac[idx].pdev_id);
12735 band_to_mac[idx].start_freq =
12736 param->band_to_mac[idx].start_freq;
12737 band_to_mac[idx].end_freq =
12738 param->band_to_mac[idx].end_freq;
12739 }
12740 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12741 (param->num_band_to_mac *
12742 sizeof(wmi_pdev_band_to_mac)) +
12743 WMI_TLV_HDR_SIZE;
12744
12745 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12746 (param->num_band_to_mac *
12747 sizeof(wmi_pdev_band_to_mac)));
12748 }
12749
12750 return buf_ptr;
12751}
12752
12753static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12754 wmi_init_cmd_fixed_param *cmd)
12755{
12756 int num_whitelist;
12757 wmi_abi_version my_vers;
12758
12759 num_whitelist = sizeof(version_whitelist) /
12760 sizeof(wmi_whitelist_version_info);
12761 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12762 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12763 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12764 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12765 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12766 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12767
12768 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12769 &my_vers,
12770 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12771 &cmd->host_abi_vers);
12772
12773 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12774 __func__,
12775 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12776 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12777 cmd->host_abi_vers.abi_version_ns_0,
12778 cmd->host_abi_vers.abi_version_ns_1,
12779 cmd->host_abi_vers.abi_version_ns_2,
12780 cmd->host_abi_vers.abi_version_ns_3);
12781
12782 /* Save version sent from host -
12783 * Will be used to check ready event
12784 */
12785 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12786 sizeof(wmi_abi_version));
12787}
12788
Sathish Kumarfd347372017-02-13 12:29:09 +053012789static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012790{
12791 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12792 wmi_service_ready_event_fixed_param *ev;
12793
12794
12795 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12796
12797 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12798 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012799 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012800
12801 /*Save fw version from service ready message */
12802 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012803 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012804 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012805
Govind Singhb53420c2016-03-09 14:32:57 +053012806 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012807}
12808
12809/**
12810 * wmi_unified_save_fw_version_cmd() - save fw version
12811 * @wmi_handle: pointer to wmi handle
12812 * @res_cfg: resource config
12813 * @num_mem_chunks: no of mem chunck
12814 * @mem_chunk: pointer to mem chunck structure
12815 *
12816 * This function sends IE information to firmware
12817 *
Govind Singhb53420c2016-03-09 14:32:57 +053012818 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012819 *
12820 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012821static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012822 void *evt_buf)
12823{
12824 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12825 wmi_ready_event_fixed_param *ev = NULL;
12826
12827 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12828 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012829 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12830 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012831 &ev->fw_abi_vers)) {
12832 /*
12833 * Error: Our host version and the given firmware version
12834 * are incompatible.
12835 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012836 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012837 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12838 __func__,
12839 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12840 abi_version_0),
12841 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12842 abi_version_0),
12843 wmi_handle->final_abi_vers.abi_version_ns_0,
12844 wmi_handle->final_abi_vers.abi_version_ns_1,
12845 wmi_handle->final_abi_vers.abi_version_ns_2,
12846 wmi_handle->final_abi_vers.abi_version_ns_3,
12847 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12848 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12849 ev->fw_abi_vers.abi_version_ns_0,
12850 ev->fw_abi_vers.abi_version_ns_1,
12851 ev->fw_abi_vers.abi_version_ns_2,
12852 ev->fw_abi_vers.abi_version_ns_3);
12853
Govind Singhb53420c2016-03-09 14:32:57 +053012854 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012855 }
Govind Singhb53420c2016-03-09 14:32:57 +053012856 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012857 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012858 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012859 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012860
Govind Singhb53420c2016-03-09 14:32:57 +053012861 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012862}
Govind Singha4836fd2016-03-07 16:45:38 +053012863
12864/**
12865 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12866 * @wmi_handle: wmi handle
12867 * @custom_addr: base mac address
12868 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012869 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012870 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012871static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012872 uint8_t *custom_addr)
12873{
12874 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12875 wmi_buf_t buf;
12876 int err;
12877
12878 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12879 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012880 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012881 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012882 }
12883
12884 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012885 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012886
12887 WMITLV_SET_HDR(&cmd->tlv_header,
12888 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12889 WMITLV_GET_STRUCT_TLVLEN
12890 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12891 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012892 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12893 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012894 err = wmi_unified_cmd_send(wmi_handle, buf,
12895 sizeof(*cmd),
12896 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12897 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012898 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012899 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012900 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012901 }
12902
12903 return 0;
12904}
12905
12906/**
12907 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12908 * @handle: wmi handle
12909 * @event: Event received from FW
12910 * @len: Length of the event
12911 *
12912 * Enables the low frequency events and disables the high frequency
12913 * events. Bit 17 indicates if the event if low/high frequency.
12914 * 1 - high frequency, 0 - low frequency
12915 *
12916 * Return: 0 on successfully enabling/disabling the events
12917 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012918static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012919 uint8_t *event,
12920 uint32_t len)
12921{
12922 uint32_t num_of_diag_events_logs;
12923 wmi_diag_event_log_config_fixed_param *cmd;
12924 wmi_buf_t buf;
12925 uint8_t *buf_ptr;
12926 uint32_t *cmd_args, *evt_args;
12927 uint32_t buf_len, i;
12928
12929 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12930 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12931
Govind Singhb53420c2016-03-09 14:32:57 +053012932 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012933
12934 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12935 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012936 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012937 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012938 }
12939 wmi_event = param_buf->fixed_param;
12940 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012941
12942 if (num_of_diag_events_logs >
12943 param_buf->num_diag_events_logs_list) {
12944 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12945 num_of_diag_events_logs,
12946 param_buf->num_diag_events_logs_list);
12947 return QDF_STATUS_E_INVAL;
12948 }
12949
Govind Singha4836fd2016-03-07 16:45:38 +053012950 evt_args = param_buf->diag_events_logs_list;
12951 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012952 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012953 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012954 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012955 }
12956
Govind Singhb53420c2016-03-09 14:32:57 +053012957 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012958 __func__, num_of_diag_events_logs);
12959
12960 /* Free any previous allocation */
12961 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012962 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012963
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012964 if (num_of_diag_events_logs >
12965 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12966 WMI_LOGE("%s: excess num of logs:%d", __func__,
12967 num_of_diag_events_logs);
12968 QDF_ASSERT(0);
12969 return QDF_STATUS_E_INVAL;
12970 }
Govind Singha4836fd2016-03-07 16:45:38 +053012971 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012972 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012973 sizeof(uint32_t));
12974 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012975 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012976 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012977 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012978 }
12979 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12980
12981 /* Prepare the send buffer */
12982 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12983 (num_of_diag_events_logs * sizeof(uint32_t));
12984
12985 buf = wmi_buf_alloc(wmi_handle, buf_len);
12986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012987 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12988 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012989 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012990 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012991 }
12992
12993 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12994 buf_ptr = (uint8_t *) cmd;
12995
12996 WMITLV_SET_HDR(&cmd->tlv_header,
12997 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12998 WMITLV_GET_STRUCT_TLVLEN(
12999 wmi_diag_event_log_config_fixed_param));
13000
13001 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13002
13003 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13004
13005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13006 (num_of_diag_events_logs * sizeof(uint32_t)));
13007
13008 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13009
13010 /* Populate the events */
13011 for (i = 0; i < num_of_diag_events_logs; i++) {
13012 /* Low freq (0) - Enable (1) the event
13013 * High freq (1) - Disable (0) the event
13014 */
13015 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13016 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13017 /* Set the event ID */
13018 WMI_DIAG_ID_SET(cmd_args[i],
13019 WMI_DIAG_ID_GET(evt_args[i]));
13020 /* Set the type */
13021 WMI_DIAG_TYPE_SET(cmd_args[i],
13022 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013023 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013024 wmi_handle->events_logs_list[i] = evt_args[i];
13025 }
13026
13027 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13028 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013029 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013030 __func__);
13031 wmi_buf_free(buf);
13032 /* Not clearing events_logs_list, though wmi cmd failed.
13033 * Host can still have this list
13034 */
Govind Singh67922e82016-04-01 16:48:57 +053013035 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013036 }
13037
13038 return 0;
13039}
13040
13041/**
13042 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13043 * @wmi_handle: wmi handle
13044 * @start_log: Start logging related parameters
13045 *
13046 * Send the command to the FW based on which specific logging of diag
13047 * event/log id can be started/stopped
13048 *
13049 * Return: None
13050 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013051static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013052 struct wmi_wifi_start_log *start_log)
13053{
13054 wmi_diag_event_log_config_fixed_param *cmd;
13055 wmi_buf_t buf;
13056 uint8_t *buf_ptr;
13057 uint32_t len, count, log_level, i;
13058 uint32_t *cmd_args;
13059 uint32_t total_len;
13060 count = 0;
13061
13062 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013063 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013064 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013065 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013066 }
13067 /* total_len stores the number of events where BITS 17 and 18 are set.
13068 * i.e., events of high frequency (17) and for extended debugging (18)
13069 */
13070 total_len = 0;
13071 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13072 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13073 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13074 total_len++;
13075 }
13076
13077 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13078 (total_len * sizeof(uint32_t));
13079
13080 buf = wmi_buf_alloc(wmi_handle, len);
13081 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013082 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013083 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013084 }
13085 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13086 buf_ptr = (uint8_t *) cmd;
13087
13088 WMITLV_SET_HDR(&cmd->tlv_header,
13089 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13090 WMITLV_GET_STRUCT_TLVLEN(
13091 wmi_diag_event_log_config_fixed_param));
13092
13093 cmd->num_of_diag_events_logs = total_len;
13094
13095 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13096
13097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13098 (total_len * sizeof(uint32_t)));
13099
13100 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13101
Govind Singh224a7312016-06-21 14:33:26 +053013102 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013103 log_level = 1;
13104 else
13105 log_level = 0;
13106
Govind Singhb53420c2016-03-09 14:32:57 +053013107 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013108 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13109 uint32_t val = wmi_handle->events_logs_list[i];
13110 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13111 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13112
13113 WMI_DIAG_ID_SET(cmd_args[count],
13114 WMI_DIAG_ID_GET(val));
13115 WMI_DIAG_TYPE_SET(cmd_args[count],
13116 WMI_DIAG_TYPE_GET(val));
13117 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13118 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013119 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013120 count++;
13121 }
13122 }
13123
13124 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13125 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013126 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013127 __func__);
13128 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013129 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013130 }
13131
Govind Singhb53420c2016-03-09 14:32:57 +053013132 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013133}
13134
13135/**
13136 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13137 * @wmi_handle: WMI handle
13138 *
13139 * This function is used to send the flush command to the FW,
13140 * that will flush the fw logs that are residue in the FW
13141 *
13142 * Return: None
13143 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013144static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013145{
13146 wmi_debug_mesg_flush_fixed_param *cmd;
13147 wmi_buf_t buf;
13148 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013149 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013150
13151 buf = wmi_buf_alloc(wmi_handle, len);
13152 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013153 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013154 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013155 }
13156
13157 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13158 WMITLV_SET_HDR(&cmd->tlv_header,
13159 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13160 WMITLV_GET_STRUCT_TLVLEN(
13161 wmi_debug_mesg_flush_fixed_param));
13162 cmd->reserved0 = 0;
13163
13164 ret = wmi_unified_cmd_send(wmi_handle,
13165 buf,
13166 len,
13167 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013168 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013169 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013170 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013171 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013172 }
Govind Singhb53420c2016-03-09 14:32:57 +053013173 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013174
Govind Singh67922e82016-04-01 16:48:57 +053013175 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013176}
13177
13178/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013179 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013180 * @wmi_handle: wmi handle
13181 * @msg: PCL structure containing the PCL and the number of channels
13182 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013183 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013184 * firmware. The DBS Manager is the consumer of this information in the WLAN
13185 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13186 * to migrate to a new channel without host driver involvement. An example of
13187 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13188 * manage the channel selection without firmware involvement.
13189 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013190 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13191 * channel list. The weights corresponds to the channels sent in
13192 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13193 * weightage compared to the non PCL channels.
13194 *
Govind Singha4836fd2016-03-07 16:45:38 +053013195 * Return: Success if the cmd is sent successfully to the firmware
13196 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013197static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013198 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013199{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013200 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013201 wmi_buf_t buf;
13202 uint8_t *buf_ptr;
13203 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013204 uint32_t chan_len;
13205
13206 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013207
13208 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013209 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013210
13211 buf = wmi_buf_alloc(wmi_handle, len);
13212 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013213 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13214 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013215 }
13216
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013217 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013218 buf_ptr = (uint8_t *) cmd;
13219 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013220 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13221 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013222
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013223 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13224 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013225 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013226 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013227
13228 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013229 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013230 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013231 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013232 for (i = 0; i < chan_len ; i++) {
13233 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013234 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013235 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013236 }
13237 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013238 WMI_PDEV_SET_PCL_CMDID)) {
13239 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013240 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013241 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013242 }
Govind Singhb53420c2016-03-09 14:32:57 +053013243 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013244}
13245
13246/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013247 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013248 * @wmi_handle: wmi handle
13249 * @msg: Structure containing the following parameters
13250 *
13251 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13252 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13253 *
13254 * Provides notification to the WLAN firmware that host driver is requesting a
13255 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13256 * configurations that include the Dual Band Simultaneous (DBS) feature.
13257 *
13258 * Return: Success if the cmd is sent successfully to the firmware
13259 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013260static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013261 uint32_t hw_mode_index)
13262{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013263 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013264 wmi_buf_t buf;
13265 uint32_t len;
13266
13267 len = sizeof(*cmd);
13268
13269 buf = wmi_buf_alloc(wmi_handle, len);
13270 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013271 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13272 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013273 }
13274
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013275 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013276 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013277 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13278 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13279
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013280 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13281 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013282 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013283 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013284
13285 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013286 WMI_PDEV_SET_HW_MODE_CMDID)) {
13287 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013288 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013289 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013290 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013291 }
13292
Govind Singhb53420c2016-03-09 14:32:57 +053013293 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013294}
13295
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013296#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013297/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013298 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013299 * @wmi_handle: wmi handle
13300 * @msg: Dual MAC config parameters
13301 *
13302 * Configures WLAN firmware with the dual MAC features
13303 *
Govind Singhb53420c2016-03-09 14:32:57 +053013304 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013305 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013306static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013307QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013308 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013309{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013310 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013311 wmi_buf_t buf;
13312 uint32_t len;
13313
13314 len = sizeof(*cmd);
13315
13316 buf = wmi_buf_alloc(wmi_handle, len);
13317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013318 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13319 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013320 }
13321
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013322 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013323 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013324 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013325 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013326 wmi_pdev_set_mac_config_cmd_fixed_param));
13327
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013328 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13329 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013330 cmd->concurrent_scan_config_bits = msg->scan_config;
13331 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013332 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013333 __func__, msg->scan_config, msg->fw_mode_config);
13334
13335 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013336 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13337 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013338 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013339 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013340 }
Govind Singhb53420c2016-03-09 14:32:57 +053013341 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013342}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013343#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013344
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013345#ifdef BIG_ENDIAN_HOST
13346/**
13347* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13348* @param data_len - data length
13349* @param data - pointer to data
13350*
13351* Return: QDF_STATUS - success or error status
13352*/
13353static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13354 struct fips_params *param)
13355{
13356 unsigned char *key_unaligned, *data_unaligned;
13357 int c;
13358 u_int8_t *key_aligned = NULL;
13359 u_int8_t *data_aligned = NULL;
13360
13361 /* Assigning unaligned space to copy the key */
13362 key_unaligned = qdf_mem_malloc(
13363 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13364 data_unaligned = qdf_mem_malloc(
13365 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13366
Jeff Johnsonda263992018-05-12 14:22:00 -070013367 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013368 if (key_unaligned == NULL)
13369 return QDF_STATUS_SUCCESS;
13370 /* Checking if space is aligned */
13371 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13372 /* align to 4 */
13373 key_aligned =
13374 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13375 FIPS_ALIGN);
13376 } else {
13377 key_aligned = (u_int8_t *)key_unaligned;
13378 }
13379
13380 /* memset and copy content from key to key aligned */
13381 OS_MEMSET(key_aligned, 0, param->key_len);
13382 OS_MEMCPY(key_aligned, param->key, param->key_len);
13383
13384 /* print a hexdump for host debug */
13385 print_hex_dump(KERN_DEBUG,
13386 "\t Aligned and Copied Key:@@@@ ",
13387 DUMP_PREFIX_NONE,
13388 16, 1, key_aligned, param->key_len, true);
13389
Jeff Johnsonda263992018-05-12 14:22:00 -070013390 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013391 if (data_unaligned == NULL)
13392 return QDF_STATUS_SUCCESS;
13393 /* Checking of space is aligned */
13394 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13395 /* align to 4 */
13396 data_aligned =
13397 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13398 FIPS_ALIGN);
13399 } else {
13400 data_aligned = (u_int8_t *)data_unaligned;
13401 }
13402
13403 /* memset and copy content from data to data aligned */
13404 OS_MEMSET(data_aligned, 0, param->data_len);
13405 OS_MEMCPY(data_aligned, param->data, param->data_len);
13406
13407 /* print a hexdump for host debug */
13408 print_hex_dump(KERN_DEBUG,
13409 "\t Properly Aligned and Copied Data:@@@@ ",
13410 DUMP_PREFIX_NONE,
13411 16, 1, data_aligned, param->data_len, true);
13412
13413 /* converting to little Endian both key_aligned and
13414 * data_aligned*/
13415 for (c = 0; c < param->key_len/4; c++) {
13416 *((u_int32_t *)key_aligned+c) =
13417 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13418 }
13419 for (c = 0; c < param->data_len/4; c++) {
13420 *((u_int32_t *)data_aligned+c) =
13421 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13422 }
13423
13424 /* update endian data to key and data vectors */
13425 OS_MEMCPY(param->key, key_aligned, param->key_len);
13426 OS_MEMCPY(param->data, data_aligned, param->data_len);
13427
13428 /* clean up allocated spaces */
13429 qdf_mem_free(key_unaligned);
13430 key_unaligned = NULL;
13431 key_aligned = NULL;
13432
13433 qdf_mem_free(data_unaligned);
13434 data_unaligned = NULL;
13435 data_aligned = NULL;
13436
13437 return QDF_STATUS_SUCCESS;
13438}
13439#else
13440/**
13441* fips_align_data_be() - DUMMY for LE platform
13442*
13443* Return: QDF_STATUS - success
13444*/
13445static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13446 struct fips_params *param)
13447{
13448 return QDF_STATUS_SUCCESS;
13449}
13450#endif
13451
13452
13453/**
13454 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13455 * @wmi_handle: wmi handle
13456 * @param: pointer to hold pdev fips param
13457 *
13458 * Return: 0 for success or error code
13459 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013460static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013461send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13462 struct fips_params *param)
13463{
13464 wmi_pdev_fips_cmd_fixed_param *cmd;
13465 wmi_buf_t buf;
13466 uint8_t *buf_ptr;
13467 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13468 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13469
13470 /* Length TLV placeholder for array of bytes */
13471 len += WMI_TLV_HDR_SIZE;
13472 if (param->data_len)
13473 len += (param->data_len*sizeof(uint8_t));
13474
13475 /*
13476 * Data length must be multiples of 16 bytes - checked against 0xF -
13477 * and must be less than WMI_SVC_MSG_SIZE - static size of
13478 * wmi_pdev_fips_cmd structure
13479 */
13480
13481 /* do sanity on the input */
13482 if (!(((param->data_len & 0xF) == 0) &&
13483 ((param->data_len > 0) &&
13484 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13485 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13486 return QDF_STATUS_E_INVAL;
13487 }
13488
13489 buf = wmi_buf_alloc(wmi_handle, len);
13490 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013491 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013492 return QDF_STATUS_E_FAILURE;
13493 }
13494
13495 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13496 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13497 WMITLV_SET_HDR(&cmd->tlv_header,
13498 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13499 WMITLV_GET_STRUCT_TLVLEN
13500 (wmi_pdev_fips_cmd_fixed_param));
13501
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013502 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13503 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013504 if (param->key != NULL && param->data != NULL) {
13505 cmd->key_len = param->key_len;
13506 cmd->data_len = param->data_len;
13507 cmd->fips_cmd = !!(param->op);
13508
13509 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13510 return QDF_STATUS_E_FAILURE;
13511
13512 qdf_mem_copy(cmd->key, param->key, param->key_len);
13513
13514 if (param->mode == FIPS_ENGINE_AES_CTR ||
13515 param->mode == FIPS_ENGINE_AES_MIC) {
13516 cmd->mode = param->mode;
13517 } else {
13518 cmd->mode = FIPS_ENGINE_AES_CTR;
13519 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013520 qdf_print("Key len = %d, Data len = %d",
13521 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013522
13523 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13524 cmd->key, cmd->key_len, true);
13525 buf_ptr += sizeof(*cmd);
13526
13527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13528
13529 buf_ptr += WMI_TLV_HDR_SIZE;
13530 if (param->data_len)
13531 qdf_mem_copy(buf_ptr,
13532 (uint8_t *) param->data, param->data_len);
13533
13534 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13535 16, 1, buf_ptr, cmd->data_len, true);
13536
13537 buf_ptr += param->data_len;
13538
13539 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13540 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013541 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013542 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013543 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013544 wmi_buf_free(buf);
13545 retval = -QDF_STATUS_E_BADMSG;
13546 }
13547
13548 return retval;
13549}
13550
Wu Gao52c0b772018-05-17 16:14:00 +080013551#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013552/**
13553 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13554 * @wmi_handle: wmi handle
13555 * @vdev_id: vdev id
13556 * @bitmap: Event bitmap
13557 * @enable: enable/disable
13558 *
13559 * Return: CDF status
13560 */
13561static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13562 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013563 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013564 bool enable)
13565{
13566 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13567 uint16_t len;
13568 wmi_buf_t buf;
13569 int ret;
13570
13571 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13572 buf = wmi_buf_alloc(wmi_handle, len);
13573 if (!buf) {
13574 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13575 return QDF_STATUS_E_NOMEM;
13576 }
13577 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13578 WMITLV_SET_HDR(&cmd->tlv_header,
13579 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13580 WMITLV_GET_STRUCT_TLVLEN
13581 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13582 cmd->vdev_id = vdev_id;
13583 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013584 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13585 WMI_WOW_MAX_EVENT_BM_LEN);
13586
13587 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13588 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13589 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013590
13591 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13592 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13593 if (ret) {
13594 WMI_LOGE("Failed to config wow wakeup event");
13595 wmi_buf_free(buf);
13596 return QDF_STATUS_E_FAILURE;
13597 }
13598
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013599 return QDF_STATUS_SUCCESS;
13600}
13601
13602/**
13603 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13604 * @wmi_handle: wmi handle
13605 * @vdev_id: vdev id
13606 * @ptrn_id: pattern id
13607 * @ptrn: pattern
13608 * @ptrn_len: pattern length
13609 * @ptrn_offset: pattern offset
13610 * @mask: mask
13611 * @mask_len: mask length
13612 * @user: true for user configured pattern and false for default pattern
13613 * @default_patterns: default patterns
13614 *
13615 * Return: CDF status
13616 */
13617static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13618 uint8_t vdev_id, uint8_t ptrn_id,
13619 const uint8_t *ptrn, uint8_t ptrn_len,
13620 uint8_t ptrn_offset, const uint8_t *mask,
13621 uint8_t mask_len, bool user,
13622 uint8_t default_patterns)
13623{
13624 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13625 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13626 wmi_buf_t buf;
13627 uint8_t *buf_ptr;
13628 int32_t len;
13629 int ret;
13630
13631 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13632 WMI_TLV_HDR_SIZE +
13633 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13634 WMI_TLV_HDR_SIZE +
13635 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13636 WMI_TLV_HDR_SIZE +
13637 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13638 WMI_TLV_HDR_SIZE +
13639 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13640 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013641 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013642
13643 buf = wmi_buf_alloc(wmi_handle, len);
13644 if (!buf) {
13645 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13646 return QDF_STATUS_E_NOMEM;
13647 }
13648
13649 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13650 buf_ptr = (uint8_t *) cmd;
13651
13652 WMITLV_SET_HDR(&cmd->tlv_header,
13653 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13654 WMITLV_GET_STRUCT_TLVLEN
13655 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13656 cmd->vdev_id = vdev_id;
13657 cmd->pattern_id = ptrn_id;
13658
13659 cmd->pattern_type = WOW_BITMAP_PATTERN;
13660 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13661
13662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13663 sizeof(WOW_BITMAP_PATTERN_T));
13664 buf_ptr += WMI_TLV_HDR_SIZE;
13665 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13666
13667 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13668 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13669 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13670
13671 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13672 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13673
13674 bitmap_pattern->pattern_offset = ptrn_offset;
13675 bitmap_pattern->pattern_len = ptrn_len;
13676
13677 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13678 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13679
13680 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13681 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13682
13683 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13684 bitmap_pattern->pattern_id = ptrn_id;
13685
13686 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13687 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13688 bitmap_pattern->pattern_offset, user);
13689 WMI_LOGI("Pattern : ");
13690 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13691 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13692
13693 WMI_LOGI("Mask : ");
13694 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13695 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13696
13697 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13698
13699 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13700 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13701 buf_ptr += WMI_TLV_HDR_SIZE;
13702
13703 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13704 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13705 buf_ptr += WMI_TLV_HDR_SIZE;
13706
13707 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13708 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13709 buf_ptr += WMI_TLV_HDR_SIZE;
13710
13711 /* Fill TLV for pattern_info_timeout but no data. */
13712 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13713 buf_ptr += WMI_TLV_HDR_SIZE;
13714
13715 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013717 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013718 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013719
13720 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13721 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13722 if (ret) {
13723 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13724 wmi_buf_free(buf);
13725 return QDF_STATUS_E_FAILURE;
13726 }
13727
13728 return QDF_STATUS_SUCCESS;
13729}
13730
Govind Singha4836fd2016-03-07 16:45:38 +053013731/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013732 * fill_arp_offload_params_tlv() - Fill ARP offload data
13733 * @wmi_handle: wmi handle
13734 * @offload_req: offload request
13735 * @buf_ptr: buffer pointer
13736 *
13737 * To fill ARP offload data to firmware
13738 * when target goes to wow mode.
13739 *
13740 * Return: None
13741 */
13742static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013743 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013744{
13745
13746 int i;
13747 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013748 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013749
13750 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13751 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13752 *buf_ptr += WMI_TLV_HDR_SIZE;
13753 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13754 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13755 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13756 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13757 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13758
13759 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013760 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013761 /* Copy the target ip addr and flags */
13762 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13763 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013764 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013765 WMI_IPV4_ADDR_LEN);
13766 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013767 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013768 }
13769 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13770 }
13771}
13772
13773#ifdef WLAN_NS_OFFLOAD
13774/**
13775 * fill_ns_offload_params_tlv() - Fill NS offload data
13776 * @wmi|_handle: wmi handle
13777 * @offload_req: offload request
13778 * @buf_ptr: buffer pointer
13779 *
13780 * To fill NS offload data to firmware
13781 * when target goes to wow mode.
13782 *
13783 * Return: None
13784 */
13785static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013786 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013787{
13788
13789 int i;
13790 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013791
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013792 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13793 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13794 *buf_ptr += WMI_TLV_HDR_SIZE;
13795 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13796 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13797 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13798 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13799 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13800
13801 /*
13802 * Fill data only for NS offload in the first ARP tuple for LA
13803 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013804 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013805 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13806 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013807 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013808 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013809 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013810 sizeof(WMI_IPV6_ADDR));
13811 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013812 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013813 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013814 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013815 ns_tuple->flags |=
13816 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13817 }
13818 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013819 i, &ns_req->self_ipv6_addr[i],
13820 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013821
13822 /* target MAC is optional, check if it is valid,
13823 * if this is not valid, the target will use the known
13824 * local MAC address rather than the tuple
13825 */
13826 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013827 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013828 &ns_tuple->target_mac);
13829 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13830 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13831 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13832 }
13833 }
13834 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13835 }
13836}
13837
13838
13839/**
13840 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13841 * @wmi: wmi handle
13842 * @offload_req: offload request
13843 * @buf_ptr: buffer pointer
13844 *
13845 * To fill extended NS offload extended data to firmware
13846 * when target goes to wow mode.
13847 *
13848 * Return: None
13849 */
13850static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013851 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013852{
13853 int i;
13854 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13855 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013856
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013857 count = ns_req->num_ns_offload_count;
13858 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013859 WMI_MAX_NS_OFFLOADS;
13860
13861 /* Populate extended NS offload tuples */
13862 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13863 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13864 *buf_ptr += WMI_TLV_HDR_SIZE;
13865 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13866 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13867 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13868 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13869 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13870
13871 /*
13872 * Fill data only for NS offload in the first ARP tuple for LA
13873 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013874 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013875 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13876 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013877 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013878 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013879 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013880 sizeof(WMI_IPV6_ADDR));
13881 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013882 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013883 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013884 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013885 ns_tuple->flags |=
13886 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13887 }
13888 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013889 i, &ns_req->self_ipv6_addr[i],
13890 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013891
13892 /* target MAC is optional, check if it is valid,
13893 * if this is not valid, the target will use the
13894 * known local MAC address rather than the tuple
13895 */
13896 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013897 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013898 &ns_tuple->target_mac);
13899 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13900 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13901 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13902 }
13903 }
13904 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13905 }
13906}
13907#else
13908static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013909 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013910{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013911}
13912
13913static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013914 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013915{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013916}
13917#endif
13918
13919/**
Govind Singha4836fd2016-03-07 16:45:38 +053013920 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13921 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013922 * @arp_offload_req: arp offload request
13923 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013924 * @arp_only: flag
13925 *
13926 * To configure ARP NS off load data to firmware
13927 * when target goes to wow mode.
13928 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013929 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013930 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013931static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013932 struct pmo_arp_offload_params *arp_offload_req,
13933 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013934 uint8_t vdev_id)
13935{
Govind Singha4836fd2016-03-07 16:45:38 +053013936 int32_t res;
13937 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013938 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013939 wmi_buf_t buf;
13940 int32_t len;
13941 uint32_t count = 0, num_ns_ext_tuples = 0;
13942
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013943 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013944
Govind Singha4836fd2016-03-07 16:45:38 +053013945 /*
13946 * TLV place holder size for array of NS tuples
13947 * TLV place holder size for array of ARP tuples
13948 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013949 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13950 WMI_TLV_HDR_SIZE +
13951 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13952 WMI_TLV_HDR_SIZE +
13953 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013954
13955 /*
13956 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13957 * extra length for extended NS offload tuples which follows ARP offload
13958 * tuples. Host needs to fill this structure in following format:
13959 * 2 NS ofload tuples
13960 * 2 ARP offload tuples
13961 * N numbers of extended NS offload tuples if HDD has given more than
13962 * 2 NS offload addresses
13963 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013964 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013965 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013966 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13967 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013968 }
13969
13970 buf = wmi_buf_alloc(wmi_handle, len);
13971 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013972 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013973 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013974 }
13975
Vivekc5823092018-03-22 23:27:21 +053013976 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013977 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13978 WMITLV_SET_HDR(&cmd->tlv_header,
13979 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13980 WMITLV_GET_STRUCT_TLVLEN
13981 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13982 cmd->flags = 0;
13983 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013984 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013985
Govind Singhb53420c2016-03-09 14:32:57 +053013986 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013987
Govind Singha4836fd2016-03-07 16:45:38 +053013988 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013989 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13990 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13991 if (num_ns_ext_tuples)
13992 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013993
13994 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13995 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13996 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013997 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013998 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013999 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014000 }
14001
Govind Singhb53420c2016-03-09 14:32:57 +053014002 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014003}
14004
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014005/**
14006 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14007 * @wmi_handle: wmi handle
14008 * @vdev_id: vdev id
14009 * @action: true for enable else false
14010 *
14011 * To enable enhance multicast offload to firmware
14012 * when target goes to wow mode.
14013 *
14014 * Return: QDF Status
14015 */
14016
14017static
14018QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14019 wmi_unified_t wmi_handle,
14020 uint8_t vdev_id, bool action)
14021{
14022 QDF_STATUS status;
14023 wmi_buf_t buf;
14024 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14025
14026 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14027 if (!buf) {
14028 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14029 return QDF_STATUS_E_NOMEM;
14030 }
14031
14032 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14033 wmi_buf_data(buf);
14034
14035 WMITLV_SET_HDR(&cmd->tlv_header,
14036 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14037 WMITLV_GET_STRUCT_TLVLEN(
14038 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14039
14040 cmd->vdev_id = vdev_id;
14041 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14042 ENHANCED_MCAST_FILTER_ENABLED);
14043 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14044 __func__, action, vdev_id);
14045 status = wmi_unified_cmd_send(wmi_handle, buf,
14046 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14047 if (status != QDF_STATUS_SUCCESS) {
14048 qdf_nbuf_free(buf);
14049 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14050 __func__);
14051 }
14052
14053 return status;
14054}
14055
14056/**
14057 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14058 * @wmi_handle: wmi handle
14059 * @param evt_buf: pointer to event buffer
14060 * @param hdr: Pointer to hold header
14061 * @param bufp: Pointer to hold pointer to rx param buffer
14062 *
14063 * Return: QDF_STATUS_SUCCESS for success or error code
14064 */
14065static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14066 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14067{
14068 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14069 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14070
14071 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14072 if (!param_buf) {
14073 WMI_LOGE("gtk param_buf is NULL");
14074 return QDF_STATUS_E_INVAL;
14075 }
14076
14077 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14078 WMI_LOGE("Invalid length for GTK status");
14079 return QDF_STATUS_E_INVAL;
14080 }
14081
14082 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14083 param_buf->fixed_param;
14084 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14085 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14086 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14087 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14088 &fixed_param->replay_counter,
14089 GTK_REPLAY_COUNTER_BYTES);
14090
14091 return QDF_STATUS_SUCCESS;
14092
14093}
14094
14095#ifdef FEATURE_WLAN_RA_FILTERING
14096/**
14097 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14098 * @wmi_handle: wmi handle
14099 * @vdev_id: vdev id
14100 *
14101 * Return: CDF status
14102 */
14103static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14104 uint8_t vdev_id, uint8_t default_pattern,
14105 uint16_t rate_limit_interval)
14106{
14107
14108 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14109 wmi_buf_t buf;
14110 uint8_t *buf_ptr;
14111 int32_t len;
14112 int ret;
14113
14114 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14115 WMI_TLV_HDR_SIZE +
14116 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14117 WMI_TLV_HDR_SIZE +
14118 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14119 WMI_TLV_HDR_SIZE +
14120 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14121 WMI_TLV_HDR_SIZE +
14122 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14123 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014124 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014125
14126 buf = wmi_buf_alloc(wmi_handle, len);
14127 if (!buf) {
14128 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14129 return QDF_STATUS_E_NOMEM;
14130 }
14131
14132 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14133 buf_ptr = (uint8_t *) cmd;
14134
14135 WMITLV_SET_HDR(&cmd->tlv_header,
14136 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14137 WMITLV_GET_STRUCT_TLVLEN
14138 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14139 cmd->vdev_id = vdev_id;
14140 cmd->pattern_id = default_pattern,
14141 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14142 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14143
14144 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14145 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14146 buf_ptr += WMI_TLV_HDR_SIZE;
14147
14148 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14149 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14150 buf_ptr += WMI_TLV_HDR_SIZE;
14151
14152 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14153 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14154 buf_ptr += WMI_TLV_HDR_SIZE;
14155
14156 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14157 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14158 buf_ptr += WMI_TLV_HDR_SIZE;
14159
14160 /* Fill TLV for pattern_info_timeout but no data. */
14161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14162 buf_ptr += WMI_TLV_HDR_SIZE;
14163
14164 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014166 buf_ptr += WMI_TLV_HDR_SIZE;
14167
Vivekc5823092018-03-22 23:27:21 +053014168 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014169
14170 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14171 rate_limit_interval, vdev_id);
14172
14173 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14174 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14175 if (ret) {
14176 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14177 wmi_buf_free(buf);
14178 return QDF_STATUS_E_FAILURE;
14179 }
14180
14181 return QDF_STATUS_SUCCESS;
14182
14183}
14184#endif /* FEATURE_WLAN_RA_FILTERING */
14185
14186/**
14187 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14188 * @wmi_handle: wmi handle
14189 * @vdev_id: vdev id
14190 * @multicastAddr: mcast address
14191 * @clearList: clear list flag
14192 *
14193 * Return: QDF_STATUS_SUCCESS for success or error code
14194 */
14195static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14196 uint8_t vdev_id,
14197 struct qdf_mac_addr multicast_addr,
14198 bool clearList)
14199{
14200 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14201 wmi_buf_t buf;
14202 int err;
14203
14204 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14205 if (!buf) {
14206 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14207 return QDF_STATUS_E_NOMEM;
14208 }
14209
14210 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14211 qdf_mem_zero(cmd, sizeof(*cmd));
14212
14213 WMITLV_SET_HDR(&cmd->tlv_header,
14214 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14215 WMITLV_GET_STRUCT_TLVLEN
14216 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14217 cmd->action =
14218 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14219 cmd->vdev_id = vdev_id;
14220 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14221
14222 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14223 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14224
14225 err = wmi_unified_cmd_send(wmi_handle, buf,
14226 sizeof(*cmd),
14227 WMI_SET_MCASTBCAST_FILTER_CMDID);
14228 if (err) {
14229 WMI_LOGE("Failed to send set_param cmd");
14230 wmi_buf_free(buf);
14231 return QDF_STATUS_E_FAILURE;
14232 }
14233
14234 return QDF_STATUS_SUCCESS;
14235}
14236
14237/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014238 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14239 * command to fw
14240 * @wmi_handle: wmi handle
14241 * @vdev_id: vdev id
14242 * @mcast_filter_params: mcast filter params
14243 *
14244 * Return: QDF_STATUS_SUCCESS for success or error code
14245 */
14246static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14247 wmi_unified_t wmi_handle,
14248 uint8_t vdev_id,
14249 struct pmo_mcast_filter_params *filter_param)
14250
14251{
14252 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14253 uint8_t *buf_ptr;
14254 wmi_buf_t buf;
14255 int err;
14256 int i;
14257 uint8_t *mac_addr_src_ptr = NULL;
14258 wmi_mac_addr *mac_addr_dst_ptr;
14259 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14260 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14261
14262 buf = wmi_buf_alloc(wmi_handle, len);
14263 if (!buf) {
14264 WMI_LOGE("Failed to allocate memory");
14265 return QDF_STATUS_E_NOMEM;
14266 }
14267
Vivekc5823092018-03-22 23:27:21 +053014268 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014269 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14270 wmi_buf_data(buf);
14271 qdf_mem_zero(cmd, sizeof(*cmd));
14272
14273 WMITLV_SET_HDR(&cmd->tlv_header,
14274 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14275 WMITLV_GET_STRUCT_TLVLEN
14276 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14277 cmd->operation =
14278 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14279 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14280 cmd->vdev_id = vdev_id;
14281 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14282
14283 buf_ptr += sizeof(*cmd);
14284 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14285 sizeof(wmi_mac_addr) *
14286 filter_param->multicast_addr_cnt);
14287
14288 if (filter_param->multicast_addr_cnt == 0)
14289 goto send_cmd;
14290
14291 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14292 mac_addr_dst_ptr = (wmi_mac_addr *)
14293 (buf_ptr + WMI_TLV_HDR_SIZE);
14294
14295 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14296 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14297 mac_addr_src_ptr += ATH_MAC_LEN;
14298 mac_addr_dst_ptr++;
14299 }
14300
14301send_cmd:
14302 err = wmi_unified_cmd_send(wmi_handle, buf,
14303 len,
14304 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14305 if (err) {
14306 WMI_LOGE("Failed to send set_param cmd");
14307 wmi_buf_free(buf);
14308 return QDF_STATUS_E_FAILURE;
14309 }
14310
14311 return QDF_STATUS_SUCCESS;
14312}
14313
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014314static void
14315fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
14316 uint8_t vdev_id,
14317 struct pmo_gtk_req *params)
14318{
14319 uint8_t *buf_ptr;
14320 wmi_gtk_offload_fils_tlv_param *ext_param;
14321
14322 buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
14323 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14324 sizeof(*ext_param));
14325 buf_ptr += WMI_TLV_HDR_SIZE;
14326
14327 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14328 WMITLV_SET_HDR(&ext_param->tlv_header,
14329 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14330 WMITLV_GET_STRUCT_TLVLEN(
14331 wmi_gtk_offload_fils_tlv_param));
14332 ext_param->vdev_id = vdev_id;
14333 ext_param->flags = cmd->flags;
14334 ext_param->kek_len = params->kek_len;
14335 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14336 qdf_mem_copy(ext_param->KCK, params->kck,
14337 WMI_GTK_OFFLOAD_KCK_BYTES);
14338 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14339 GTK_REPLAY_COUNTER_BYTES);
14340}
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014341
14342/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014343 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14344 * @wmi_handle: wmi handle
14345 * @vdev_id: vdev id
14346 * @params: GTK offload parameters
14347 *
14348 * Return: CDF status
14349 */
14350static
14351QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14352 struct pmo_gtk_req *params,
14353 bool enable_offload,
14354 uint32_t gtk_offload_opcode)
14355{
14356 int len;
14357 wmi_buf_t buf;
14358 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14359 QDF_STATUS status = QDF_STATUS_SUCCESS;
14360
14361 WMI_LOGD("%s Enter", __func__);
14362
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014363 len = sizeof(*cmd);
14364
14365 if (params->is_fils_connection)
14366 len += WMI_TLV_HDR_SIZE +
14367 sizeof(wmi_gtk_offload_fils_tlv_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014368
14369 /* alloc wmi buffer */
14370 buf = wmi_buf_alloc(wmi_handle, len);
14371 if (!buf) {
14372 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14373 status = QDF_STATUS_E_NOMEM;
14374 goto out;
14375 }
14376
14377 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14378 WMITLV_SET_HDR(&cmd->tlv_header,
14379 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14380 WMITLV_GET_STRUCT_TLVLEN
14381 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14382
14383 cmd->vdev_id = vdev_id;
14384
14385 /* Request target to enable GTK offload */
14386 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14387 cmd->flags = gtk_offload_opcode;
14388
14389 /* Copy the keys and replay counter */
14390 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014391 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014392 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14393 GTK_REPLAY_COUNTER_BYTES);
14394 } else {
14395 cmd->flags = gtk_offload_opcode;
14396 }
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014397 if (params->is_fils_connection)
14398 fill_fils_tlv_params(cmd, vdev_id, params);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014399
14400 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 +053014401 /* send the wmi command */
14402 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14403 WMI_GTK_OFFLOAD_CMDID)) {
14404 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14405 wmi_buf_free(buf);
14406 status = QDF_STATUS_E_FAILURE;
14407 }
14408
14409out:
14410 WMI_LOGD("%s Exit", __func__);
14411 return status;
14412}
14413
14414/**
14415 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14416 * @wmi_handle: wmi handle
14417 * @params: GTK offload params
14418 *
14419 * Return: CDF status
14420 */
14421static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14422 wmi_unified_t wmi_handle,
14423 uint8_t vdev_id,
14424 uint64_t offload_req_opcode)
14425{
14426 int len;
14427 wmi_buf_t buf;
14428 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14429 QDF_STATUS status = QDF_STATUS_SUCCESS;
14430
14431 len = sizeof(*cmd);
14432
14433 /* alloc wmi buffer */
14434 buf = wmi_buf_alloc(wmi_handle, len);
14435 if (!buf) {
14436 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14437 status = QDF_STATUS_E_NOMEM;
14438 goto out;
14439 }
14440
14441 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14442 WMITLV_SET_HDR(&cmd->tlv_header,
14443 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14444 WMITLV_GET_STRUCT_TLVLEN
14445 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14446
14447 /* Request for GTK offload status */
14448 cmd->flags = offload_req_opcode;
14449 cmd->vdev_id = vdev_id;
14450
14451 /* send the wmi command */
14452 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14453 WMI_GTK_OFFLOAD_CMDID)) {
14454 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14455 wmi_buf_free(buf);
14456 status = QDF_STATUS_E_FAILURE;
14457 }
14458
14459out:
14460 return status;
14461}
14462
14463/**
14464 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14465 * @wmi_handle: wmi handler
14466 * @action_params: pointer to action_params
14467 *
14468 * Return: 0 for success, otherwise appropriate error code
14469 */
14470static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14471 struct pmo_action_wakeup_set_params *action_params)
14472{
14473 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14474 wmi_buf_t buf;
14475 int i;
14476 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014477 uint32_t len = 0, *cmd_args;
14478 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014479
Vivekc5823092018-03-22 23:27:21 +053014480 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014481 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14482 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014483 if (!buf) {
14484 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14485 return QDF_STATUS_E_NOMEM;
14486 }
14487 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014488 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014489 WMITLV_SET_HDR(&cmd->tlv_header,
14490 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14491 WMITLV_GET_STRUCT_TLVLEN(
14492 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14493
14494 cmd->vdev_id = action_params->vdev_id;
14495 cmd->operation = action_params->operation;
14496
14497 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14498 cmd->action_category_map[i] =
14499 action_params->action_category_map[i];
14500
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014501 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14502 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014503 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014504 buf_ptr += WMI_TLV_HDR_SIZE;
14505 cmd_args = (uint32_t *) buf_ptr;
14506 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14507 cmd_args[i] = action_params->action_per_category[i];
14508
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014509 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014510 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014511 if (err) {
14512 WMI_LOGE("Failed to send ap_ps_egap cmd");
14513 wmi_buf_free(buf);
14514 return QDF_STATUS_E_FAILURE;
14515 }
14516
14517 return QDF_STATUS_SUCCESS;
14518}
14519
14520#ifdef FEATURE_WLAN_LPHB
14521
14522/**
14523 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14524 * @wmi_handle: wmi handle
14525 * @lphb_conf_req: configuration info
14526 *
14527 * Return: CDF status
14528 */
14529static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14530 wmi_hb_set_enable_cmd_fixed_param *params)
14531{
14532 QDF_STATUS status;
14533 wmi_buf_t buf = NULL;
14534 uint8_t *buf_ptr;
14535 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14536 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14537
14538
14539 buf = wmi_buf_alloc(wmi_handle, len);
14540 if (!buf) {
14541 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14542 return QDF_STATUS_E_NOMEM;
14543 }
14544
14545 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14546 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14547 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14548 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14549 WMITLV_GET_STRUCT_TLVLEN
14550 (wmi_hb_set_enable_cmd_fixed_param));
14551
14552 /* fill in values */
14553 hb_enable_fp->vdev_id = params->session;
14554 hb_enable_fp->enable = params->enable;
14555 hb_enable_fp->item = params->item;
14556 hb_enable_fp->session = params->session;
14557
14558 status = wmi_unified_cmd_send(wmi_handle, buf,
14559 len, WMI_HB_SET_ENABLE_CMDID);
14560 if (QDF_IS_STATUS_ERROR(status)) {
14561 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14562 status);
14563 wmi_buf_free(buf);
14564 }
14565
14566 return status;
14567}
14568
14569/**
14570 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14571 * @wmi_handle: wmi handle
14572 * @lphb_conf_req: lphb config request
14573 *
14574 * Return: CDF status
14575 */
14576static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14577 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14578{
14579 QDF_STATUS status;
14580 wmi_buf_t buf = NULL;
14581 uint8_t *buf_ptr;
14582 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14583 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14584
14585 buf = wmi_buf_alloc(wmi_handle, len);
14586 if (!buf) {
14587 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14588 return QDF_STATUS_E_NOMEM;
14589 }
14590
14591 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14592 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14593 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14594 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14595 WMITLV_GET_STRUCT_TLVLEN
14596 (wmi_hb_set_tcp_params_cmd_fixed_param));
14597
14598 /* fill in values */
14599 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14600 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14601 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14602 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14603 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14604 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14605 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14606 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14607 hb_tcp_params_fp->session = lphb_conf_req->session;
14608 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14609 &lphb_conf_req->gateway_mac,
14610 sizeof(hb_tcp_params_fp->gateway_mac));
14611
14612 status = wmi_unified_cmd_send(wmi_handle, buf,
14613 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14614 if (QDF_IS_STATUS_ERROR(status)) {
14615 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14616 status);
14617 wmi_buf_free(buf);
14618 }
14619
14620 return status;
14621}
14622
14623/**
14624 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14625 * @wmi_handle: wmi handle
14626 * @lphb_conf_req: lphb config request
14627 *
14628 * Return: CDF status
14629 */
14630static
14631QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14632 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14633{
14634 QDF_STATUS status;
14635 wmi_buf_t buf = NULL;
14636 uint8_t *buf_ptr;
14637 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14638 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14639
14640 buf = wmi_buf_alloc(wmi_handle, len);
14641 if (!buf) {
14642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14643 return QDF_STATUS_E_NOMEM;
14644 }
14645
14646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14647 hb_tcp_filter_fp =
14648 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14649 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14650 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14651 WMITLV_GET_STRUCT_TLVLEN
14652 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14653
14654 /* fill in values */
14655 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14656 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14657 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14658 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14659 memcpy((void *)&hb_tcp_filter_fp->filter,
14660 (void *)&g_hb_tcp_filter_fp->filter,
14661 WMI_WLAN_HB_MAX_FILTER_SIZE);
14662
14663 status = wmi_unified_cmd_send(wmi_handle, buf,
14664 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14665 if (QDF_IS_STATUS_ERROR(status)) {
14666 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14667 status);
14668 wmi_buf_free(buf);
14669 }
14670
14671 return status;
14672}
14673
14674/**
14675 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14676 * @wmi_handle: wmi handle
14677 * @lphb_conf_req: lphb config request
14678 *
14679 * Return: CDF status
14680 */
14681static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14682 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14683{
14684 QDF_STATUS status;
14685 wmi_buf_t buf = NULL;
14686 uint8_t *buf_ptr;
14687 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14688 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14689
14690 buf = wmi_buf_alloc(wmi_handle, len);
14691 if (!buf) {
14692 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14693 return QDF_STATUS_E_NOMEM;
14694 }
14695
14696 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14697 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14698 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14699 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14700 WMITLV_GET_STRUCT_TLVLEN
14701 (wmi_hb_set_udp_params_cmd_fixed_param));
14702
14703 /* fill in values */
14704 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14705 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14706 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14707 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14708 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14709 hb_udp_params_fp->interval = lphb_conf_req->interval;
14710 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14711 hb_udp_params_fp->session = lphb_conf_req->session;
14712 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14713 &lphb_conf_req->gateway_mac,
14714 sizeof(lphb_conf_req->gateway_mac));
14715
14716 status = wmi_unified_cmd_send(wmi_handle, buf,
14717 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14718 if (QDF_IS_STATUS_ERROR(status)) {
14719 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14720 status);
14721 wmi_buf_free(buf);
14722 }
14723
14724 return status;
14725}
14726
14727/**
14728 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14729 * @wmi_handle: wmi handle
14730 * @lphb_conf_req: lphb config request
14731 *
14732 * Return: CDF status
14733 */
14734static
14735QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14736 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14737{
14738 QDF_STATUS status;
14739 wmi_buf_t buf = NULL;
14740 uint8_t *buf_ptr;
14741 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14742 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14743
14744 buf = wmi_buf_alloc(wmi_handle, len);
14745 if (!buf) {
14746 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14747 return QDF_STATUS_E_NOMEM;
14748 }
14749
14750 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14751 hb_udp_filter_fp =
14752 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14753 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14754 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14755 WMITLV_GET_STRUCT_TLVLEN
14756 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14757
14758 /* fill in values */
14759 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14760 hb_udp_filter_fp->length = lphb_conf_req->length;
14761 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14762 hb_udp_filter_fp->session = lphb_conf_req->session;
14763 memcpy((void *)&hb_udp_filter_fp->filter,
14764 (void *)&lphb_conf_req->filter,
14765 WMI_WLAN_HB_MAX_FILTER_SIZE);
14766
14767 status = wmi_unified_cmd_send(wmi_handle, buf,
14768 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14769 if (QDF_IS_STATUS_ERROR(status)) {
14770 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14771 status);
14772 wmi_buf_free(buf);
14773 }
14774
14775 return status;
14776}
14777#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014778
Dustin Brownf31f88b2017-05-12 14:01:44 -070014779static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14780 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014781{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014782 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014783 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014784 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014785
Dustin Brownf31f88b2017-05-12 14:01:44 -070014786 if (!req) {
14787 WMI_LOGE("req is null");
14788 return QDF_STATUS_E_INVAL;
14789 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014790
Dustin Brownf31f88b2017-05-12 14:01:44 -070014791 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14792 if (!wmi_buf) {
14793 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014794 return QDF_STATUS_E_NOMEM;
14795 }
14796
Dustin Brownf31f88b2017-05-12 14:01:44 -070014797 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014798 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014799 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14800 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14801 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014802 cmd->enable = req->enable;
14803 /* Set all modes in case of disable */
14804 if (!cmd->enable)
14805 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14806 else
14807 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014808
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014809 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14810 req->enable ? "enable" : "disable", req->mode_bitmap,
14811 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014812
Dustin Brownf31f88b2017-05-12 14:01:44 -070014813 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14814 WMI_HW_DATA_FILTER_CMDID);
14815 if (QDF_IS_STATUS_ERROR(status)) {
14816 WMI_LOGE("Failed to configure hw filter");
14817 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014818 }
14819
Dustin Brownf31f88b2017-05-12 14:01:44 -070014820 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014821}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014822
14823/**
14824 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14825 * @wmi_handle: wmi handle
14826 * @vdev_id: vdev id
14827 * @enable: Flag to enable/disable packet filter
14828 *
14829 * Return: QDF_STATUS_SUCCESS for success or error code
14830 */
14831static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14832 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14833{
14834 int32_t len;
14835 int ret = 0;
14836 wmi_buf_t buf;
14837 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14838
14839 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14840
14841 buf = wmi_buf_alloc(wmi_handle, len);
14842 if (!buf) {
14843 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14844 return QDF_STATUS_E_NOMEM;
14845 }
14846
14847 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14848 WMITLV_SET_HDR(&cmd->tlv_header,
14849 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14850 WMITLV_GET_STRUCT_TLVLEN(
14851 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14852
14853 cmd->vdev_id = vdev_id;
14854 if (enable)
14855 cmd->enable = PACKET_FILTER_SET_ENABLE;
14856 else
14857 cmd->enable = PACKET_FILTER_SET_DISABLE;
14858
14859 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14860 __func__, cmd->enable, vdev_id);
14861
14862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14863 WMI_PACKET_FILTER_ENABLE_CMDID);
14864 if (ret) {
14865 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14866 wmi_buf_free(buf);
14867 }
14868
14869 return ret;
14870}
14871
14872/**
14873 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14874 * @wmi_handle: wmi handle
14875 * @vdev_id: vdev id
14876 * @rcv_filter_param: Packet filter parameters
14877 * @filter_id: Filter id
14878 * @enable: Flag to add/delete packet filter configuration
14879 *
14880 * Return: QDF_STATUS_SUCCESS for success or error code
14881 */
14882static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14883 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14884 uint8_t filter_id, bool enable)
14885{
14886 int len, i;
14887 int err = 0;
14888 wmi_buf_t buf;
14889 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14890
14891
14892 /* allocate the memory */
14893 len = sizeof(*cmd);
14894 buf = wmi_buf_alloc(wmi_handle, len);
14895 if (!buf) {
14896 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14897 return QDF_STATUS_E_NOMEM;
14898 }
14899
14900 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14901 WMITLV_SET_HDR(&cmd->tlv_header,
14902 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14903 WMITLV_GET_STRUCT_TLVLEN
14904 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14905
14906 cmd->vdev_id = vdev_id;
14907 cmd->filter_id = filter_id;
14908 if (enable)
14909 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14910 else
14911 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14912
14913 if (enable) {
14914 cmd->num_params = QDF_MIN(
14915 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14916 rcv_filter_param->num_params);
14917 cmd->filter_type = rcv_filter_param->filter_type;
14918 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14919
14920 for (i = 0; i < cmd->num_params; i++) {
14921 cmd->paramsData[i].proto_type =
14922 rcv_filter_param->params_data[i].protocol_layer;
14923 cmd->paramsData[i].cmp_type =
14924 rcv_filter_param->params_data[i].compare_flag;
14925 cmd->paramsData[i].data_length =
14926 rcv_filter_param->params_data[i].data_length;
14927 cmd->paramsData[i].data_offset =
14928 rcv_filter_param->params_data[i].data_offset;
14929 memcpy(&cmd->paramsData[i].compareData,
14930 rcv_filter_param->params_data[i].compare_data,
14931 sizeof(cmd->paramsData[i].compareData));
14932 memcpy(&cmd->paramsData[i].dataMask,
14933 rcv_filter_param->params_data[i].data_mask,
14934 sizeof(cmd->paramsData[i].dataMask));
14935 }
14936 }
14937
14938 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14939 cmd->filter_action, cmd->filter_id, cmd->num_params);
14940 /* send the command along with data */
14941 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14942 WMI_PACKET_FILTER_CONFIG_CMDID);
14943 if (err) {
14944 WMI_LOGE("Failed to send pkt_filter cmd");
14945 wmi_buf_free(buf);
14946 return QDF_STATUS_E_FAILURE;
14947 }
14948
14949 return QDF_STATUS_SUCCESS;
14950}
Wu Gao52c0b772018-05-17 16:14:00 +080014951#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014952
Govind Singha4836fd2016-03-07 16:45:38 +053014953/**
14954 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14955 * @wmi_handle: wmi handle
14956 * @request: SSID hotlist set request
14957 *
Govind Singhb53420c2016-03-09 14:32:57 +053014958 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014959 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014960static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014961send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14962 struct ssid_hotlist_request_params *request)
14963{
14964 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14965 wmi_buf_t wmi_buf;
14966 uint32_t len;
14967 uint32_t array_size;
14968 uint8_t *buf_ptr;
14969
14970 /* length of fixed portion */
14971 len = sizeof(*cmd);
14972
14973 /* length of variable portion */
14974 array_size =
14975 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14976 len += WMI_TLV_HDR_SIZE + array_size;
14977
14978 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14979 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014980 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14981 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014982 }
14983
14984 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14985 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14986 buf_ptr;
14987 WMITLV_SET_HDR
14988 (&cmd->tlv_header,
14989 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14990 WMITLV_GET_STRUCT_TLVLEN
14991 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14992
14993 cmd->request_id = request->request_id;
14994 cmd->requestor_id = 0;
14995 cmd->vdev_id = request->session_id;
14996 cmd->table_id = 0;
14997 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14998 cmd->total_entries = request->ssid_count;
14999 cmd->num_entries_in_page = request->ssid_count;
15000 cmd->first_entry_index = 0;
15001
15002 buf_ptr += sizeof(*cmd);
15003 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15004
15005 if (request->ssid_count) {
15006 wmi_extscan_hotlist_ssid_entry *entry;
15007 int i;
15008
15009 buf_ptr += WMI_TLV_HDR_SIZE;
15010 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15011 for (i = 0; i < request->ssid_count; i++) {
15012 WMITLV_SET_HDR
15013 (entry,
15014 WMITLV_TAG_ARRAY_STRUC,
15015 WMITLV_GET_STRUCT_TLVLEN
15016 (wmi_extscan_hotlist_ssid_entry));
15017 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015018 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015019 request->ssids[i].ssid.mac_ssid,
15020 request->ssids[i].ssid.length);
15021 entry->band = request->ssids[i].band;
15022 entry->min_rssi = request->ssids[i].rssi_low;
15023 entry->max_rssi = request->ssids[i].rssi_high;
15024 entry++;
15025 }
15026 cmd->mode = WMI_EXTSCAN_MODE_START;
15027 } else {
15028 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15029 }
15030
15031 if (wmi_unified_cmd_send
15032 (wmi_handle, wmi_buf, len,
15033 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015034 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015035 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015036 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015037 }
15038
Govind Singhb53420c2016-03-09 14:32:57 +053015039 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015040}
15041
15042/**
15043 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15044 * @wmi_handle: wmi handle
15045 * @vdev_id: vdev id
15046 *
15047 * This function sends roam synch complete event to fw.
15048 *
15049 * Return: CDF STATUS
15050 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015051static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015052 uint8_t vdev_id)
15053{
15054 wmi_roam_synch_complete_fixed_param *cmd;
15055 wmi_buf_t wmi_buf;
15056 uint8_t *buf_ptr;
15057 uint16_t len;
15058 len = sizeof(wmi_roam_synch_complete_fixed_param);
15059
15060 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15061 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015062 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15063 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015064 }
15065 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15066 buf_ptr = (uint8_t *) cmd;
15067 WMITLV_SET_HDR(&cmd->tlv_header,
15068 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15069 WMITLV_GET_STRUCT_TLVLEN
15070 (wmi_roam_synch_complete_fixed_param));
15071 cmd->vdev_id = vdev_id;
15072 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15073 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015074 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015075 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015076 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015077 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015078 }
15079
Govind Singhb53420c2016-03-09 14:32:57 +053015080 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015081}
15082
15083/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015084 * send_fw_test_cmd_tlv() - send fw test command to fw.
15085 * @wmi_handle: wmi handle
15086 * @wmi_fwtest: fw test command
15087 *
15088 * This function sends fw test command to fw.
15089 *
15090 * Return: CDF STATUS
15091 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015092static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015093QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15094 struct set_fwtest_params *wmi_fwtest)
15095{
15096 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15097 wmi_buf_t wmi_buf;
15098 uint16_t len;
15099
15100 len = sizeof(*cmd);
15101
15102 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15103 if (!wmi_buf) {
15104 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15105 return QDF_STATUS_E_NOMEM;
15106 }
15107
15108 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15109 WMITLV_SET_HDR(&cmd->tlv_header,
15110 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15111 WMITLV_GET_STRUCT_TLVLEN(
15112 wmi_fwtest_set_param_cmd_fixed_param));
15113 cmd->param_id = wmi_fwtest->arg;
15114 cmd->param_value = wmi_fwtest->value;
15115
15116 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15117 WMI_FWTEST_CMDID)) {
15118 WMI_LOGP("%s: failed to send fw test command", __func__);
15119 qdf_nbuf_free(wmi_buf);
15120 return QDF_STATUS_E_FAILURE;
15121 }
15122
15123 return QDF_STATUS_SUCCESS;
15124}
15125
15126/**
Govind Singha4836fd2016-03-07 16:45:38 +053015127 * send_unit_test_cmd_tlv() - send unit test command to fw.
15128 * @wmi_handle: wmi handle
15129 * @wmi_utest: unit test command
15130 *
15131 * This function send unit test command to fw.
15132 *
15133 * Return: CDF STATUS
15134 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015135static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015136 struct wmi_unit_test_cmd *wmi_utest)
15137{
15138 wmi_unit_test_cmd_fixed_param *cmd;
15139 wmi_buf_t wmi_buf;
15140 uint8_t *buf_ptr;
15141 int i;
15142 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015143 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015144
15145 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015146 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015147 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15148
15149 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15150 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015151 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15152 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015153 }
15154
15155 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15156 buf_ptr = (uint8_t *) cmd;
15157 WMITLV_SET_HDR(&cmd->tlv_header,
15158 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15159 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15160 cmd->vdev_id = wmi_utest->vdev_id;
15161 cmd->module_id = wmi_utest->module_id;
15162 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015163 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015164 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15166 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015167 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015168 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15169 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15170 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015171 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015172 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015173 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015174 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015175 }
15176 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15177 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015178 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015179 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015180 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015181 }
15182
Govind Singhb53420c2016-03-09 14:32:57 +053015183 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015184}
15185
15186/**
15187 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15188 * @wmi_handle: wma handle
15189 * @roaminvoke: roam invoke command
15190 *
15191 * Send roam invoke command to fw for fastreassoc.
15192 *
15193 * Return: CDF STATUS
15194 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015195static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015196 struct wmi_roam_invoke_cmd *roaminvoke,
15197 uint32_t ch_hz)
15198{
15199 wmi_roam_invoke_cmd_fixed_param *cmd;
15200 wmi_buf_t wmi_buf;
15201 u_int8_t *buf_ptr;
15202 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015203 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015204 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015205 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015206
15207 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015208 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015209 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15210 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015211 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15212 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15213 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015214 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15215 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015216 }
15217
15218 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15219 buf_ptr = (u_int8_t *) cmd;
15220 WMITLV_SET_HDR(&cmd->tlv_header,
15221 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15222 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15223 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015224 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015225 if (roaminvoke->is_same_bssid)
15226 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15227 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015228
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015229 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015230 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015231 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15232 cmd->num_buf = 1;
15233 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015234 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015235 cmd->num_buf = 0;
15236 }
Naveen Rawat77797922017-01-20 17:00:07 -080015237
Govind Singha4836fd2016-03-07 16:45:38 +053015238 cmd->roam_ap_sel_mode = 0;
15239 cmd->roam_delay = 0;
15240 cmd->num_chan = 1;
15241 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015242
Govind Singha4836fd2016-03-07 16:45:38 +053015243 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15244 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15245 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015246 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015247 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015248 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015249 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15250 (sizeof(wmi_mac_addr)));
15251 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15252 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015253
15254 /* move to next tlv i.e. bcn_prb_buf_list */
15255 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15256
15257 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15258 sizeof(wmi_tlv_buf_len_param));
15259
15260 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15261 buf_len_tlv->buf_len = roaminvoke->frame_len;
15262
15263 /* move to next tlv i.e. bcn_prb_frm */
15264 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15265 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15266 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15267
15268 /* copy frame after the header */
15269 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15270 roaminvoke->frame_buf,
15271 roaminvoke->frame_len);
15272
15273 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015274 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015275 buf_ptr + WMI_TLV_HDR_SIZE,
15276 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015277 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15278 cmd->flags, cmd->roam_scan_mode,
15279 cmd->roam_ap_sel_mode, cmd->roam_delay,
15280 cmd->num_chan, cmd->num_bssid);
15281 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015282
Govind Singha4836fd2016-03-07 16:45:38 +053015283 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15284 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015285 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015286 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015287 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015288 }
15289
Govind Singhb53420c2016-03-09 14:32:57 +053015290 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015291}
15292
15293/**
15294 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15295 * @wmi_handle: wmi handle
15296 * @command: command
15297 * @vdev_id: vdev id
15298 *
15299 * This function set roam offload command to fw.
15300 *
15301 * Return: CDF status
15302 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015303static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015304 uint32_t command, uint32_t vdev_id)
15305{
Govind Singh67922e82016-04-01 16:48:57 +053015306 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015307 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15308 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015309 int len;
15310 uint8_t *buf_ptr;
15311
15312 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15313 buf = wmi_buf_alloc(wmi_handle, len);
15314 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015315 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15316 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015317 }
15318
15319 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15320
15321 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15322 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15323 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15324 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15325 cmd_fp->vdev_id = vdev_id;
15326 cmd_fp->command_arg = command;
15327
15328 status = wmi_unified_cmd_send(wmi_handle, buf,
15329 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015330 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015331 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015332 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015333 goto error;
15334 }
15335
Govind Singhb53420c2016-03-09 14:32:57 +053015336 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15337 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015338
15339error:
15340 wmi_buf_free(buf);
15341
Govind Singh67922e82016-04-01 16:48:57 +053015342 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015343}
15344
15345/**
15346 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15347 * @wmi_handle: wmi handle
15348 * @ap_profile_p: ap profile
15349 * @vdev_id: vdev id
15350 *
15351 * Send WMI_ROAM_AP_PROFILE to firmware
15352 *
15353 * Return: CDF status
15354 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015355static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015356 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015357{
Govind Singha4836fd2016-03-07 16:45:38 +053015358 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015359 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015360 int len;
15361 uint8_t *buf_ptr;
15362 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015363 wmi_roam_cnd_scoring_param *score_param;
15364 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015365
15366 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015367 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015368 buf = wmi_buf_alloc(wmi_handle, len);
15369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015370 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15371 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015372 }
15373
15374 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15375 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15376 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15377 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15378 WMITLV_GET_STRUCT_TLVLEN
15379 (wmi_roam_ap_profile_fixed_param));
15380 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015381 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015382 roam_ap_profile_fp->id = 0;
15383 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15384
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015385 profile = (wmi_ap_profile *)buf_ptr;
15386 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015387 WMITLV_TAG_STRUC_wmi_ap_profile,
15388 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015389 profile->flags = ap_profile->profile.flags;
15390 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15391 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15392 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15393 profile->ssid.ssid_len);
15394 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15395 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15396 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15397 profile->rsn_mcastmgmtcipherset =
15398 ap_profile->profile.rsn_mcastmgmtcipherset;
15399 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15400
15401 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",
15402 profile->flags, profile->rssi_threshold,
15403 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15404 profile->rsn_authmode, profile->rsn_ucastcipherset,
15405 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15406 profile->rssi_abs_thresh);
15407
15408 buf_ptr += sizeof(wmi_ap_profile);
15409
15410 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15411 WMITLV_SET_HDR(&score_param->tlv_header,
15412 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15413 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15414 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15415 score_param->rssi_weightage_pcnt =
15416 ap_profile->param.rssi_weightage;
15417 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15418 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15419 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15420 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15421 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15422 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15423 score_param->esp_qbss_weightage_pcnt =
15424 ap_profile->param.esp_qbss_weightage;
15425 score_param->beamforming_weightage_pcnt =
15426 ap_profile->param.beamforming_weightage;
15427 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15428 score_param->oce_wan_weightage_pcnt =
15429 ap_profile->param.oce_wan_weightage;
15430
15431 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",
15432 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15433 score_param->ht_weightage_pcnt,
15434 score_param->vht_weightage_pcnt,
15435 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15436 score_param->band_weightage_pcnt,
15437 score_param->nss_weightage_pcnt,
15438 score_param->esp_qbss_weightage_pcnt,
15439 score_param->beamforming_weightage_pcnt,
15440 score_param->pcl_weightage_pcnt,
15441 score_param->oce_wan_weightage_pcnt);
15442
15443 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15444 score_param->band_scoring.score_pcnt =
15445 ap_profile->param.band_index_score;
15446 score_param->nss_scoring.score_pcnt =
15447 ap_profile->param.nss_index_score;
15448
15449 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15450 score_param->bw_scoring.score_pcnt,
15451 score_param->band_scoring.score_pcnt,
15452 score_param->nss_scoring.score_pcnt);
15453
15454 score_param->rssi_scoring.best_rssi_threshold =
15455 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15456 score_param->rssi_scoring.good_rssi_threshold =
15457 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15458 score_param->rssi_scoring.bad_rssi_threshold =
15459 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15460 score_param->rssi_scoring.good_rssi_pcnt =
15461 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15462 score_param->rssi_scoring.bad_rssi_pcnt =
15463 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15464 score_param->rssi_scoring.good_bucket_size =
15465 ap_profile->param.rssi_scoring.good_bucket_size;
15466 score_param->rssi_scoring.bad_bucket_size =
15467 ap_profile->param.rssi_scoring.bad_bucket_size;
15468 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15469 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15470
15471 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15472 score_param->rssi_scoring.best_rssi_threshold,
15473 score_param->rssi_scoring.good_rssi_threshold,
15474 score_param->rssi_scoring.bad_rssi_threshold,
15475 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15476 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15477 score_param->rssi_scoring.good_rssi_pcnt,
15478 score_param->rssi_scoring.bad_rssi_pcnt,
15479 score_param->rssi_scoring.good_bucket_size,
15480 score_param->rssi_scoring.bad_bucket_size);
15481
15482 score_param->esp_qbss_scoring.num_slot =
15483 ap_profile->param.esp_qbss_scoring.num_slot;
15484 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15485 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15486 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15487 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15488 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15489 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15490 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15491 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15492
15493 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15494 score_param->esp_qbss_scoring.num_slot,
15495 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15496 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15497 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15498 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15499
15500 score_param->oce_wan_scoring.num_slot =
15501 ap_profile->param.oce_wan_scoring.num_slot;
15502 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15503 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15504 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15505 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15506 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15507 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15508 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15509 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15510
15511 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15512 score_param->oce_wan_scoring.num_slot,
15513 score_param->oce_wan_scoring.score_pcnt3_to_0,
15514 score_param->oce_wan_scoring.score_pcnt7_to_4,
15515 score_param->oce_wan_scoring.score_pcnt11_to_8,
15516 score_param->oce_wan_scoring.score_pcnt15_to_12);
15517
Govind Singha4836fd2016-03-07 16:45:38 +053015518 status = wmi_unified_cmd_send(wmi_handle, buf,
15519 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015520 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015521 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015522 status);
Govind Singh67922e82016-04-01 16:48:57 +053015523 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015524 }
15525
Govind Singhb53420c2016-03-09 14:32:57 +053015526 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015527
Govind Singh67922e82016-04-01 16:48:57 +053015528 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015529}
15530
15531/**
15532 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15533 * @wmi_handle: wmi handle
15534 * @scan_period: scan period
15535 * @scan_age: scan age
15536 * @vdev_id: vdev id
15537 *
15538 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15539 *
15540 * Return: CDF status
15541 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015542static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015543 uint32_t scan_period,
15544 uint32_t scan_age,
15545 uint32_t vdev_id)
15546{
Govind Singh67922e82016-04-01 16:48:57 +053015547 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015548 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015549 int len;
15550 uint8_t *buf_ptr;
15551 wmi_roam_scan_period_fixed_param *scan_period_fp;
15552
15553 /* Send scan period values */
15554 len = sizeof(wmi_roam_scan_period_fixed_param);
15555 buf = wmi_buf_alloc(wmi_handle, len);
15556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015557 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15558 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015559 }
15560
15561 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15562 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15563 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15564 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15565 WMITLV_GET_STRUCT_TLVLEN
15566 (wmi_roam_scan_period_fixed_param));
15567 /* fill in scan period values */
15568 scan_period_fp->vdev_id = vdev_id;
15569 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15570 scan_period_fp->roam_scan_age = scan_age;
15571
15572 status = wmi_unified_cmd_send(wmi_handle, buf,
15573 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015574 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015575 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015576 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015577 goto error;
15578 }
15579
Govind Singhb53420c2016-03-09 14:32:57 +053015580 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015581 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015582 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015583error:
15584 wmi_buf_free(buf);
15585
Govind Singh67922e82016-04-01 16:48:57 +053015586 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015587}
15588
15589/**
15590 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15591 * @wmi_handle: wmi handle
15592 * @chan_count: channel count
15593 * @chan_list: channel list
15594 * @list_type: list type
15595 * @vdev_id: vdev id
15596 *
15597 * Set roam offload channel list.
15598 *
15599 * Return: CDF status
15600 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015601static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015602 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015603 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015604 uint8_t list_type, uint32_t vdev_id)
15605{
Govind Singha4836fd2016-03-07 16:45:38 +053015606 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015607 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015608 int len, list_tlv_len;
15609 int i;
15610 uint8_t *buf_ptr;
15611 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015612 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015613
15614 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015615 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015616 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015617 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015618 }
15619 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015620 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015621 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15622 buf = wmi_buf_alloc(wmi_handle, len);
15623 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015624 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15625 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015626 }
15627
15628 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15629 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15630 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15631 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15632 WMITLV_GET_STRUCT_TLVLEN
15633 (wmi_roam_chan_list_fixed_param));
15634 chan_list_fp->vdev_id = vdev_id;
15635 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015636 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015637 /* external app is controlling channel list */
15638 chan_list_fp->chan_list_type =
15639 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15640 } else {
15641 /* umac supplied occupied channel list in LFR */
15642 chan_list_fp->chan_list_type =
15643 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15644 }
15645
15646 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15648 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015649 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015650 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015651 for (i = 0; ((i < chan_list_fp->num_chan) &&
15652 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15653 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015654 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015655 }
15656
15657 status = wmi_unified_cmd_send(wmi_handle, buf,
15658 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015659 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015660 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015661 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015662 goto error;
15663 }
15664
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015665 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015666 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015667error:
15668 wmi_buf_free(buf);
15669
Govind Singh67922e82016-04-01 16:48:57 +053015670 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015671}
15672
15673/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015674 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15675 * @wmi_handle: wmi handle
15676 * @req_buf: per roam config buffer
15677 *
15678 * Return: QDF status
15679 */
15680static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15681 struct wmi_per_roam_config_req *req_buf)
15682{
15683 wmi_buf_t buf = NULL;
15684 QDF_STATUS status;
15685 int len;
15686 uint8_t *buf_ptr;
15687 wmi_roam_per_config_fixed_param *wmi_per_config;
15688
15689 len = sizeof(wmi_roam_per_config_fixed_param);
15690 buf = wmi_buf_alloc(wmi_handle, len);
15691 if (!buf) {
15692 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15693 return QDF_STATUS_E_NOMEM;
15694 }
15695
15696 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15697 wmi_per_config =
15698 (wmi_roam_per_config_fixed_param *) buf_ptr;
15699 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15700 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15701 WMITLV_GET_STRUCT_TLVLEN
15702 (wmi_roam_per_config_fixed_param));
15703
15704 /* fill in per roam config values */
15705 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015706
15707 wmi_per_config->enable = req_buf->per_config.enable;
15708 wmi_per_config->high_rate_thresh =
15709 (req_buf->per_config.tx_high_rate_thresh << 16) |
15710 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15711 wmi_per_config->low_rate_thresh =
15712 (req_buf->per_config.tx_low_rate_thresh << 16) |
15713 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15714 wmi_per_config->pkt_err_rate_thresh_pct =
15715 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15716 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15717 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015718 wmi_per_config->pkt_err_rate_mon_time =
15719 (req_buf->per_config.tx_per_mon_time << 16) |
15720 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015721 wmi_per_config->min_candidate_rssi =
15722 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015723
15724 /* Send per roam config parameters */
15725 status = wmi_unified_cmd_send(wmi_handle, buf,
15726 len, WMI_ROAM_PER_CONFIG_CMDID);
15727 if (QDF_IS_STATUS_ERROR(status)) {
15728 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15729 status);
15730 wmi_buf_free(buf);
15731 return status;
15732 }
15733
15734 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15735 req_buf->per_config.enable, req_buf->vdev_id);
15736 return QDF_STATUS_SUCCESS;
15737}
15738
15739/**
Govind Singha4836fd2016-03-07 16:45:38 +053015740 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15741 * @wmi_handle: wmi handle
15742 * @rssi_change_thresh: RSSI Change threshold
15743 * @bcn_rssi_weight: beacon RSSI weight
15744 * @vdev_id: vdev id
15745 *
15746 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15747 *
15748 * Return: CDF status
15749 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015750static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015751 uint32_t vdev_id,
15752 int32_t rssi_change_thresh,
15753 uint32_t bcn_rssi_weight,
15754 uint32_t hirssi_delay_btw_scans)
15755{
Govind Singha4836fd2016-03-07 16:45:38 +053015756 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015757 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015758 int len;
15759 uint8_t *buf_ptr;
15760 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15761
15762 /* Send rssi change parameters */
15763 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15764 buf = wmi_buf_alloc(wmi_handle, len);
15765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015766 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15767 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015768 }
15769
15770 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15771 rssi_change_fp =
15772 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15773 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15774 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15775 WMITLV_GET_STRUCT_TLVLEN
15776 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15777 /* fill in rssi change threshold (hysteresis) values */
15778 rssi_change_fp->vdev_id = vdev_id;
15779 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15780 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15781 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15782
15783 status = wmi_unified_cmd_send(wmi_handle, buf,
15784 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015785 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015786 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015787 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015788 goto error;
15789 }
15790
Govind Singhb53420c2016-03-09 14:32:57 +053015791 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015792 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015793 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15794 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015795error:
15796 wmi_buf_free(buf);
15797
Govind Singh67922e82016-04-01 16:48:57 +053015798 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015799}
15800
Govind Singhbca3b1b2016-05-02 17:59:24 +053015801/**
15802 * send_power_dbg_cmd_tlv() - send power debug commands
15803 * @wmi_handle: wmi handle
15804 * @param: wmi power debug parameter
15805 *
15806 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15807 *
15808 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15809 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015810static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15811 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015812{
15813 wmi_buf_t buf = NULL;
15814 QDF_STATUS status;
15815 int len, args_tlv_len;
15816 uint8_t *buf_ptr;
15817 uint8_t i;
15818 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15819 uint32_t *cmd_args;
15820
15821 /* Prepare and send power debug cmd parameters */
15822 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15823 len = sizeof(*cmd) + args_tlv_len;
15824 buf = wmi_buf_alloc(wmi_handle, len);
15825 if (!buf) {
15826 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15827 return QDF_STATUS_E_NOMEM;
15828 }
15829
15830 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15831 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15832 WMITLV_SET_HDR(&cmd->tlv_header,
15833 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15834 WMITLV_GET_STRUCT_TLVLEN
15835 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15836
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015837 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15838 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015839 cmd->module_id = param->module_id;
15840 cmd->num_args = param->num_args;
15841 buf_ptr += sizeof(*cmd);
15842 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15843 (param->num_args * sizeof(uint32_t)));
15844 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15845 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015846 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015847 cmd_args[i] = param->args[i];
15848 WMI_LOGI("%d,", param->args[i]);
15849 }
15850
15851 status = wmi_unified_cmd_send(wmi_handle, buf,
15852 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15853 if (QDF_IS_STATUS_ERROR(status)) {
15854 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15855 status);
15856 goto error;
15857 }
15858
15859 return QDF_STATUS_SUCCESS;
15860error:
15861 wmi_buf_free(buf);
15862
15863 return status;
15864}
15865
Govind Singhe7f2f342016-05-23 12:12:52 +053015866/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015867 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15868 * @wmi_handle: wmi handle
15869 * @param: wmi multiple vdev restart req param
15870 *
15871 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15872 *
15873 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15874 */
15875static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15876 wmi_unified_t wmi_handle,
15877 struct multiple_vdev_restart_params *param)
15878{
15879 wmi_buf_t buf;
15880 QDF_STATUS qdf_status;
15881 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15882 int i;
15883 uint8_t *buf_ptr;
15884 uint32_t *vdev_ids;
15885 wmi_channel *chan_info;
15886 struct channel_param *tchan_info;
15887 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15888
15889 len += sizeof(wmi_channel);
15890 if (param->num_vdevs)
15891 len += sizeof(uint32_t) * param->num_vdevs;
15892
15893 buf = wmi_buf_alloc(wmi_handle, len);
15894 if (!buf) {
15895 WMI_LOGE("Failed to allocate memory\n");
15896 qdf_status = QDF_STATUS_E_NOMEM;
15897 goto end;
15898 }
15899
15900 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15901 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15902 buf_ptr;
15903
15904 WMITLV_SET_HDR(&cmd->tlv_header,
15905 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15906 WMITLV_GET_STRUCT_TLVLEN
15907 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015908 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15909 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015910 cmd->requestor_id = param->requestor_id;
15911 cmd->disable_hw_ack = param->disable_hw_ack;
15912 cmd->cac_duration_ms = param->cac_duration_ms;
15913 cmd->num_vdevs = param->num_vdevs;
15914
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015915 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15916 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15917 " cmd->num_vdevs: %d ",
15918 __func__, cmd->pdev_id, cmd->requestor_id,
15919 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015920 buf_ptr += sizeof(*cmd);
15921
15922 WMITLV_SET_HDR(buf_ptr,
15923 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015924 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015925 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15926 for (i = 0; i < param->num_vdevs; i++) {
15927 vdev_ids[i] = param->vdev_ids[i];
15928 }
15929
Vivekc5823092018-03-22 23:27:21 +053015930 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015931
15932 WMITLV_SET_HDR(buf_ptr,
15933 WMITLV_TAG_STRUC_wmi_channel,
15934 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015935 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015936 tchan_info = &(param->ch_param);
15937 chan_info->mhz = tchan_info->mhz;
15938 chan_info->band_center_freq1 = tchan_info->cfreq1;
15939 chan_info->band_center_freq2 = tchan_info->cfreq2;
15940 if (tchan_info->is_chan_passive)
15941 WMI_SET_CHANNEL_FLAG(chan_info,
15942 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015943 if (tchan_info->dfs_set)
15944 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15945
Sathish Kumar45e991b2017-02-27 10:35:40 +053015946 if (tchan_info->allow_vht)
15947 WMI_SET_CHANNEL_FLAG(chan_info,
15948 WMI_CHAN_FLAG_ALLOW_VHT);
15949 else if (tchan_info->allow_ht)
15950 WMI_SET_CHANNEL_FLAG(chan_info,
15951 WMI_CHAN_FLAG_ALLOW_HT);
15952 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15953 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15954 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15955 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15956 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15957 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015958 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015959
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015960 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15961 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15962 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15963 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15964 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15965 "tchan_info->reg_class_id: %d ,"
15966 "tchan_info->maxregpower : %d ", __func__,
15967 tchan_info->is_chan_passive, tchan_info->dfs_set,
15968 tchan_info->allow_vht, tchan_info->allow_ht,
15969 tchan_info->antennamax, tchan_info->phy_mode,
15970 tchan_info->minpower, tchan_info->maxpower,
15971 tchan_info->maxregpower, tchan_info->reg_class_id,
15972 tchan_info->maxregpower);
15973
Sathish Kumar45e991b2017-02-27 10:35:40 +053015974 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15975 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15976
15977 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15978 WMI_LOGE("%s: Failed to send\n", __func__);
15979 wmi_buf_free(buf);
15980 }
15981
15982end:
15983 return qdf_status;
15984}
15985
15986/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015987 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15988 * @wmi_handle: wmi handle
15989 * @pdev_id: pdev id
15990 *
15991 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15992 *
15993 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15994 */
15995static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15996 uint32_t pdev_id)
15997{
15998 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15999 wmi_buf_t buf;
16000 uint16_t len;
16001 QDF_STATUS ret;
16002
16003 len = sizeof(*cmd);
16004 buf = wmi_buf_alloc(wmi_handle, len);
16005
16006 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16007
16008 if (!buf) {
16009 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16010 return QDF_STATUS_E_NOMEM;
16011 }
16012
16013 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16014 wmi_buf_data(buf);
16015
16016 WMITLV_SET_HDR(&cmd->tlv_header,
16017 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16018 WMITLV_GET_STRUCT_TLVLEN(
16019 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16020
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016021 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016022 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16023 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16024 if (QDF_IS_STATUS_ERROR(ret)) {
16025 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16026 __func__, ret, pdev_id);
16027 wmi_buf_free(buf);
16028 return QDF_STATUS_E_FAILURE;
16029 }
16030
16031 return QDF_STATUS_SUCCESS;
16032}
16033
16034/**
16035 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16036 * @wmi_handle: wmi handle
16037 * @pdev_id: pdev id
16038 *
16039 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16040 *
16041 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16042 */
16043static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16044 uint32_t pdev_id)
16045{
16046 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16047 wmi_buf_t buf;
16048 uint16_t len;
16049 QDF_STATUS ret;
16050
16051 len = sizeof(*cmd);
16052 buf = wmi_buf_alloc(wmi_handle, len);
16053
16054 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16055
16056 if (!buf) {
16057 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16058 return QDF_STATUS_E_NOMEM;
16059 }
16060
16061 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16062 wmi_buf_data(buf);
16063
16064 WMITLV_SET_HDR(&cmd->tlv_header,
16065 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16066 WMITLV_GET_STRUCT_TLVLEN(
16067 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16068
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016069 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016070 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16071 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16072 if (QDF_IS_STATUS_ERROR(ret)) {
16073 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16074 __func__, ret, pdev_id);
16075 wmi_buf_free(buf);
16076 return QDF_STATUS_E_FAILURE;
16077 }
16078
16079 return QDF_STATUS_SUCCESS;
16080}
16081
16082/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016083 * init_cmd_send_tlv() - send initialization cmd to fw
16084 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016085 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016086 *
16087 * Return: QDF_STATUS_SUCCESS for success or error code
16088 */
16089static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016090 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016091{
16092 wmi_buf_t buf;
16093 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016094 uint8_t *buf_ptr;
16095 wmi_resource_config *resource_cfg;
16096 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016097 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016098 uint16_t idx;
16099 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016100 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016101
Kiran Venkatappa26117052016-12-23 19:58:54 +053016102 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16103 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016104 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016105
16106 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16107 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16108 WMI_TLV_HDR_SIZE +
16109 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16110
16111 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016112 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016113 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053016114 return QDF_STATUS_E_FAILURE;
16115 }
16116
16117 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16118 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16119 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16120
16121 host_mem_chunks = (wlan_host_memory_chunk *)
16122 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16123 + WMI_TLV_HDR_SIZE);
16124
16125 WMITLV_SET_HDR(&cmd->tlv_header,
16126 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16127 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16128
Kiran Venkatappa26117052016-12-23 19:58:54 +053016129 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016130 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16131 WMITLV_TAG_STRUC_wmi_resource_config,
16132 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16133
Kiran Venkatappa26117052016-12-23 19:58:54 +053016134 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016135 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16136 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16137 WMITLV_GET_STRUCT_TLVLEN
16138 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016139 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16140 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16141 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016142 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16143 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016144 idx, host_mem_chunks[idx].size,
16145 host_mem_chunks[idx].ptr);
16146 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016147 cmd->num_host_mem_chunks = param->num_mem_chunks;
16148 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16149
Govind Singhe7f2f342016-05-23 12:12:52 +053016150 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16151 WMITLV_TAG_ARRAY_STRUC,
16152 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016153 param->num_mem_chunks));
16154
16155 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016156 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016157
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016158 /* Fill fw_abi_vers */
16159 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016160
Abhishek Singh716c46c2016-05-04 16:24:07 +053016161 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16162 if (QDF_IS_STATUS_ERROR(ret)) {
16163 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16164 ret);
16165 wmi_buf_free(buf);
16166 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016167
Abhishek Singh716c46c2016-05-04 16:24:07 +053016168 return ret;
16169
Govind Singhe7f2f342016-05-23 12:12:52 +053016170}
16171
16172/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016173 * send_addba_send_cmd_tlv() - send addba send command to fw
16174 * @wmi_handle: wmi handle
16175 * @param: pointer to delba send params
16176 * @macaddr: peer mac address
16177 *
16178 * Send WMI_ADDBA_SEND_CMDID command to firmware
16179 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16180 */
16181static QDF_STATUS
16182send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16183 uint8_t macaddr[IEEE80211_ADDR_LEN],
16184 struct addba_send_params *param)
16185{
16186 wmi_addba_send_cmd_fixed_param *cmd;
16187 wmi_buf_t buf;
16188 uint16_t len;
16189 QDF_STATUS ret;
16190
16191 len = sizeof(*cmd);
16192
16193 buf = wmi_buf_alloc(wmi_handle, len);
16194 if (!buf) {
16195 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16196 return QDF_STATUS_E_NOMEM;
16197 }
16198
16199 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16200
16201 WMITLV_SET_HDR(&cmd->tlv_header,
16202 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16203 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16204
16205 cmd->vdev_id = param->vdev_id;
16206 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16207 cmd->tid = param->tidno;
16208 cmd->buffersize = param->buffersize;
16209
16210 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16211 if (QDF_IS_STATUS_ERROR(ret)) {
16212 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16213 wmi_buf_free(buf);
16214 return QDF_STATUS_E_FAILURE;
16215 }
16216
16217 return QDF_STATUS_SUCCESS;
16218}
16219
16220/**
16221 * send_delba_send_cmd_tlv() - send delba send command to fw
16222 * @wmi_handle: wmi handle
16223 * @param: pointer to delba send params
16224 * @macaddr: peer mac address
16225 *
16226 * Send WMI_DELBA_SEND_CMDID command to firmware
16227 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16228 */
16229static QDF_STATUS
16230send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16231 uint8_t macaddr[IEEE80211_ADDR_LEN],
16232 struct delba_send_params *param)
16233{
16234 wmi_delba_send_cmd_fixed_param *cmd;
16235 wmi_buf_t buf;
16236 uint16_t len;
16237 QDF_STATUS ret;
16238
16239 len = sizeof(*cmd);
16240
16241 buf = wmi_buf_alloc(wmi_handle, len);
16242 if (!buf) {
16243 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16244 return QDF_STATUS_E_NOMEM;
16245 }
16246
16247 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16248
16249 WMITLV_SET_HDR(&cmd->tlv_header,
16250 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16251 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16252
16253 cmd->vdev_id = param->vdev_id;
16254 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16255 cmd->tid = param->tidno;
16256 cmd->initiator = param->initiator;
16257 cmd->reasoncode = param->reasoncode;
16258
16259 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16260 if (QDF_IS_STATUS_ERROR(ret)) {
16261 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16262 wmi_buf_free(buf);
16263 return QDF_STATUS_E_FAILURE;
16264 }
16265
16266 return QDF_STATUS_SUCCESS;
16267}
16268
16269/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016270 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16271 * to fw
16272 * @wmi_handle: wmi handle
16273 * @param: pointer to addba clearresp params
16274 * @macaddr: peer mac address
16275 * Return: 0 for success or error code
16276 */
16277static QDF_STATUS
16278send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16279 uint8_t macaddr[IEEE80211_ADDR_LEN],
16280 struct addba_clearresponse_params *param)
16281{
16282 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16283 wmi_buf_t buf;
16284 uint16_t len;
16285 QDF_STATUS ret;
16286
16287 len = sizeof(*cmd);
16288
16289 buf = wmi_buf_alloc(wmi_handle, len);
16290 if (!buf) {
16291 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16292 return QDF_STATUS_E_FAILURE;
16293 }
16294 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16295
16296 WMITLV_SET_HDR(&cmd->tlv_header,
16297 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16298 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16299
16300 cmd->vdev_id = param->vdev_id;
16301 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16302
16303 ret = wmi_unified_cmd_send(wmi_handle,
16304 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16305 if (QDF_IS_STATUS_ERROR(ret)) {
16306 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16307 wmi_buf_free(buf);
16308 return QDF_STATUS_E_FAILURE;
16309 }
16310
16311 return QDF_STATUS_SUCCESS;
16312}
16313
16314/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016315 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16316 * @wmi_handle: wmi handle
16317 * @bcn_ctrl_param: pointer to bcn_offload_control param
16318 *
16319 * Return: QDF_STATUS_SUCCESS for success or error code
16320 */
16321static
16322QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16323 struct bcn_offload_control *bcn_ctrl_param)
16324{
16325 wmi_buf_t buf;
16326 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16327 QDF_STATUS ret;
16328 uint32_t len;
16329
16330 len = sizeof(*cmd);
16331
16332 buf = wmi_buf_alloc(wmi_handle, len);
16333 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016334 qdf_print("%s: wmi_buf_alloc failed", __func__);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016335 return QDF_STATUS_E_FAILURE;
16336 }
16337
16338 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16339 WMITLV_SET_HDR(&cmd->tlv_header,
16340 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16341 WMITLV_GET_STRUCT_TLVLEN
16342 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16343 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016344 switch (bcn_ctrl_param->bcn_ctrl_op) {
16345 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016346 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016347 break;
16348 case BCN_OFFLD_CTRL_TX_ENABLE:
16349 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16350 break;
16351 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16352 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16353 break;
16354 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16355 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16356 break;
16357 default:
16358 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16359 bcn_ctrl_param->bcn_ctrl_op);
16360 wmi_buf_free(buf);
16361 return QDF_STATUS_E_FAILURE;
16362 break;
16363 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016364 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16365 WMI_BCN_OFFLOAD_CTRL_CMDID);
16366
16367 if (QDF_IS_STATUS_ERROR(ret)) {
16368 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16369 ret);
16370 wmi_buf_free(buf);
16371 }
16372
16373 return ret;
16374}
16375
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016376#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16377static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16378 struct nan_datapath_initiator_req *ndp_req)
16379{
16380 uint16_t len;
16381 wmi_buf_t buf;
16382 uint8_t *tlv_ptr;
16383 QDF_STATUS status;
16384 wmi_channel *ch_tlv;
16385 wmi_ndp_initiator_req_fixed_param *cmd;
16386 uint32_t passphrase_len, service_name_len;
16387 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016388 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016389
16390 /*
16391 * WMI command expects 4 byte alligned len:
16392 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16393 */
16394 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16395 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16396 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16397 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16398 service_name_len =
16399 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16400 /* allocated memory for fixed params as well as variable size data */
16401 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16402 + ndp_cfg_len + ndp_app_info_len + pmk_len
16403 + passphrase_len + service_name_len;
16404
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016405 if (ndp_req->is_ipv6_addr_present)
16406 len += sizeof(*tcp_ip_param);
16407
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016408 buf = wmi_buf_alloc(wmi_handle, len);
16409 if (!buf) {
16410 WMI_LOGE("wmi_buf_alloc failed");
16411 return QDF_STATUS_E_NOMEM;
16412 }
16413
16414 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16415 WMITLV_SET_HDR(&cmd->tlv_header,
16416 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16417 WMITLV_GET_STRUCT_TLVLEN(
16418 wmi_ndp_initiator_req_fixed_param));
16419 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16420 cmd->transaction_id = ndp_req->transaction_id;
16421 cmd->service_instance_id = ndp_req->service_instance_id;
16422 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16423 &cmd->peer_discovery_mac_addr);
16424
16425 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16426 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16427 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16428 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16429 cmd->nan_csid = ndp_req->ncs_sk_type;
16430 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16431 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16432
16433 ch_tlv = (wmi_channel *)&cmd[1];
16434 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16435 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16436 ch_tlv->mhz = ndp_req->channel;
16437 tlv_ptr = (uint8_t *)&ch_tlv[1];
16438
16439 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16440 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16441 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16442 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16443
16444 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16445 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16446 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16447 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16448
16449 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16450 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16451 cmd->nan_pmk_len);
16452 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16453
16454 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16455 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16456 cmd->nan_passphrase_len);
16457 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16458
16459 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16460 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16461 ndp_req->service_name.service_name,
16462 cmd->nan_servicename_len);
16463 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16464
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016465 if (ndp_req->is_ipv6_addr_present) {
16466 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16467 WMITLV_SET_HDR(tcp_ip_param,
16468 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16469 WMITLV_GET_STRUCT_TLVLEN(
16470 wmi_ndp_transport_ip_param));
16471 tcp_ip_param->ipv6_addr_present = true;
16472 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16473 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16474 }
16475 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16476 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16477
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016478 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16479 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16480 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16481 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16482 cmd->peer_discovery_mac_addr.mac_addr31to0,
16483 cmd->peer_discovery_mac_addr.mac_addr47to32);
16484
16485 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016486 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016487 ndp_req->ndp_config.ndp_cfg,
16488 ndp_req->ndp_config.ndp_cfg_len);
16489
16490 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016491 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016492 ndp_req->ndp_info.ndp_app_info,
16493 ndp_req->ndp_info.ndp_app_info_len);
16494
16495 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016496 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016497 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16498
16499 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016500 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016501 ndp_req->passphrase.passphrase,
16502 cmd->nan_passphrase_len);
16503
16504 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016505 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016506 ndp_req->service_name.service_name,
16507 cmd->nan_servicename_len);
16508
16509 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16510 WMI_NDP_INITIATOR_REQ_CMDID);
16511
16512 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16513 WMI_NDP_INITIATOR_REQ_CMDID);
16514 if (QDF_IS_STATUS_ERROR(status)) {
16515 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16516 wmi_buf_free(buf);
16517 }
16518
16519 return status;
16520}
16521
16522static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16523 struct nan_datapath_responder_req *req)
16524{
16525 uint16_t len;
16526 wmi_buf_t buf;
16527 uint8_t *tlv_ptr;
16528 QDF_STATUS status;
16529 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016530 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016531 uint32_t passphrase_len, service_name_len;
16532 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16533
16534 vdev_id = wlan_vdev_get_id(req->vdev);
16535 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16536 vdev_id, req->transaction_id,
16537 req->ndp_rsp,
16538 req->ndp_instance_id,
16539 req->ndp_info.ndp_app_info_len);
16540
16541 /*
16542 * WMI command expects 4 byte alligned len:
16543 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16544 */
16545 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16546 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16547 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16548 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16549 service_name_len =
16550 qdf_roundup(req->service_name.service_name_len, 4);
16551
16552 /* allocated memory for fixed params as well as variable size data */
16553 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16554 + pmk_len + passphrase_len + service_name_len;
16555
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016556 if (req->is_ipv6_addr_present || req->is_port_present ||
16557 req->is_protocol_present)
16558 len += sizeof(*tcp_ip_param);
16559
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016560 buf = wmi_buf_alloc(wmi_handle, len);
16561 if (!buf) {
16562 WMI_LOGE("wmi_buf_alloc failed");
16563 return QDF_STATUS_E_NOMEM;
16564 }
16565 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16566 WMITLV_SET_HDR(&cmd->tlv_header,
16567 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16568 WMITLV_GET_STRUCT_TLVLEN(
16569 wmi_ndp_responder_req_fixed_param));
16570 cmd->vdev_id = vdev_id;
16571 cmd->transaction_id = req->transaction_id;
16572 cmd->ndp_instance_id = req->ndp_instance_id;
16573 cmd->rsp_code = req->ndp_rsp;
16574 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16575 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16576 cmd->nan_pmk_len = req->pmk.pmk_len;
16577 cmd->nan_csid = req->ncs_sk_type;
16578 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16579 cmd->nan_servicename_len = req->service_name.service_name_len;
16580
16581 tlv_ptr = (uint8_t *)&cmd[1];
16582 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16583 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16584 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16585
16586 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16587 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16588 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16589 req->ndp_info.ndp_app_info,
16590 req->ndp_info.ndp_app_info_len);
16591
16592 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16593 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16594 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16595 cmd->nan_pmk_len);
16596
16597 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16598 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16599 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16600 req->passphrase.passphrase,
16601 cmd->nan_passphrase_len);
16602 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16603
16604 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16605 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16606 req->service_name.service_name,
16607 cmd->nan_servicename_len);
16608
16609 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16610
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016611 if (req->is_ipv6_addr_present || req->is_port_present ||
16612 req->is_protocol_present) {
16613 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16614 WMITLV_SET_HDR(tcp_ip_param,
16615 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16616 WMITLV_GET_STRUCT_TLVLEN(
16617 wmi_ndp_transport_ip_param));
16618 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16619 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16620 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16621
16622 tcp_ip_param->trans_port_present = req->is_port_present;
16623 tcp_ip_param->transport_port = req->port;
16624
16625 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16626 tcp_ip_param->transport_protocol = req->protocol;
16627 }
16628 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16629 req->is_ipv6_addr_present, req->ipv6_addr);
16630 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16631 WMI_LOGD(FL("protocol: %d present: %d"),
16632 req->is_protocol_present, req->protocol);
16633
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016634 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16635 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16636
16637 WMI_LOGD("ndp_config len: %d",
16638 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016639 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016640 req->ndp_config.ndp_cfg,
16641 req->ndp_config.ndp_cfg_len);
16642
16643 WMI_LOGD("ndp_app_info len: %d",
16644 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016645 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016646 req->ndp_info.ndp_app_info,
16647 req->ndp_info.ndp_app_info_len);
16648
16649 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016650 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016651 req->pmk.pmk, cmd->nan_pmk_len);
16652
16653 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016654 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016655 req->passphrase.passphrase,
16656 cmd->nan_passphrase_len);
16657
16658 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016659 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016660 req->service_name.service_name,
16661 cmd->nan_servicename_len);
16662
16663 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16664 WMI_NDP_RESPONDER_REQ_CMDID);
16665 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16666 WMI_NDP_RESPONDER_REQ_CMDID);
16667 if (QDF_IS_STATUS_ERROR(status)) {
16668 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16669 wmi_buf_free(buf);
16670 }
16671 return status;
16672}
16673
16674static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16675 struct nan_datapath_end_req *req)
16676{
16677 uint16_t len;
16678 wmi_buf_t buf;
16679 QDF_STATUS status;
16680 uint32_t ndp_end_req_len, i;
16681 wmi_ndp_end_req *ndp_end_req_lst;
16682 wmi_ndp_end_req_fixed_param *cmd;
16683
16684 /* len of tlv following fixed param */
16685 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16686 /* above comes out to 4 byte alligned already, no need of padding */
16687 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16688 buf = wmi_buf_alloc(wmi_handle, len);
16689 if (!buf) {
16690 WMI_LOGE("Malloc failed");
16691 return QDF_STATUS_E_NOMEM;
16692 }
16693
16694 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16695 WMITLV_SET_HDR(&cmd->tlv_header,
16696 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16697 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16698
16699 cmd->transaction_id = req->transaction_id;
16700
16701 /* set tlv pointer to end of fixed param */
16702 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16703 ndp_end_req_len);
16704
16705 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16706 WMI_TLV_HDR_SIZE);
16707 for (i = 0; i < req->num_ndp_instances; i++) {
16708 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16709 WMITLV_TAG_ARRAY_FIXED_STRUC,
16710 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16711
16712 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16713 }
16714
16715 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16716 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16717 WMI_NDP_END_REQ_CMDID);
16718 if (QDF_IS_STATUS_ERROR(status)) {
16719 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16720 wmi_buf_free(buf);
16721 }
16722
16723 return status;
16724}
16725
16726static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016727 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016728{
16729 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16730 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16731
16732 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16733 fixed_params = event->fixed_param;
16734
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016735 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016736 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16737 fixed_params->vdev_id,
16738 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016739 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016740 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016741 return QDF_STATUS_E_INVAL;
16742 }
16743
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016744 rsp->transaction_id = fixed_params->transaction_id;
16745 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16746 rsp->status = fixed_params->rsp_status;
16747 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016748
16749 return QDF_STATUS_SUCCESS;
16750}
16751
16752static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016753 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016754{
16755 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16756 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016757 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016758
16759 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16760 fixed_params =
16761 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16762
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016763 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16764 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16765 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16766 return QDF_STATUS_E_INVAL;
16767 }
16768
16769 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16770 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16771 fixed_params->ndp_app_info_len,
16772 event->num_ndp_app_info);
16773 return QDF_STATUS_E_INVAL;
16774 }
16775
gaolezab037cf2018-05-23 14:40:32 +080016776 if (fixed_params->ndp_cfg_len >
16777 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16778 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16779 __func__, fixed_params->ndp_cfg_len);
16780 return QDF_STATUS_E_INVAL;
16781 }
16782
16783 total_array_len = fixed_params->ndp_cfg_len +
16784 sizeof(*fixed_params);
16785
16786 if (fixed_params->ndp_app_info_len >
16787 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16788 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16789 __func__, fixed_params->ndp_app_info_len);
16790 return QDF_STATUS_E_INVAL;
16791 }
16792 total_array_len += fixed_params->ndp_app_info_len;
16793
16794 if (fixed_params->nan_scid_len >
16795 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16796 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16797 __func__, fixed_params->nan_scid_len);
16798 return QDF_STATUS_E_INVAL;
16799 }
16800
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016801 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016802 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16803 fixed_params->vdev_id,
16804 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016805 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016806 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016807 return QDF_STATUS_E_INVAL;
16808 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016809 rsp->service_instance_id = fixed_params->service_instance_id;
16810 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16811 rsp->role = fixed_params->self_ndp_role;
16812 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016813
16814 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016815 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016816 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016817 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016818
16819 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16820 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16821 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16822 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16823 fixed_params->service_instance_id,
16824 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16825 fixed_params->accept_policy,
16826 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016827 rsp->peer_mac_addr.bytes,
16828 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016829
16830 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016831 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016832 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16833
16834 WMI_LOGD("ndp_app_info - %d bytes",
16835 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016836 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016837 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16838
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016839 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16840 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16841 rsp->ncs_sk_type = fixed_params->nan_csid;
16842 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016843
16844 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16845 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016846 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16847 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016848
16849 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16850 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016851 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16852 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016853
16854 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16855 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016856 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016857
16858 if (event->ndp_transport_ip_param &&
16859 event->num_ndp_transport_ip_param) {
16860 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16861 rsp->is_ipv6_addr_present = true;
16862 qdf_mem_copy(rsp->ipv6_addr,
16863 event->ndp_transport_ip_param->ipv6_intf_addr,
16864 WMI_NDP_IPV6_INTF_ADDR_LEN);
16865 }
16866 }
16867 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16868 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16869
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016870 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016871 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016872 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016873
16874 return QDF_STATUS_SUCCESS;
16875}
16876
16877static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016878 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016879{
Naveen Rawat38b21462018-05-31 15:04:16 -070016880 uint8_t i;
16881 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016882 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16883 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016884 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016885
16886 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16887 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016888 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 -080016889 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16890 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16891 fixed_params->reason_code,
16892 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016893 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016894
16895 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16896 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16897 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16898 return QDF_STATUS_E_INVAL;
16899 }
16900
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016901 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016902 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016903 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16904
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016905 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16906 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16907 fixed_params->ndp_app_info_len,
16908 event->num_ndp_app_info);
16909 return QDF_STATUS_E_INVAL;
16910 }
16911
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016912 WMI_LOGD("ndp_app_info - %d bytes",
16913 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016914 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016915 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16916
gaolezab037cf2018-05-23 14:40:32 +080016917 if (fixed_params->ndp_cfg_len >
16918 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16919 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16920 __func__, fixed_params->ndp_cfg_len);
16921 return QDF_STATUS_E_INVAL;
16922 }
16923
16924 total_array_len = fixed_params->ndp_cfg_len +
16925 sizeof(*fixed_params);
16926
16927 if (fixed_params->ndp_app_info_len >
16928 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16929 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16930 __func__, fixed_params->ndp_app_info_len);
16931 return QDF_STATUS_E_INVAL;
16932 }
16933
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016934 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016935 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16936 fixed_params->vdev_id,
16937 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016938 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016939 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016940 return QDF_STATUS_E_INVAL;
16941 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016942 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16943 rsp->rsp_code = fixed_params->rsp_code;
16944 rsp->reason_code = fixed_params->reason_code;
16945 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016946 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016947 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016948 rsp->peer_ndi_mac_addr.bytes);
16949 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16950 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16951 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016952
Naveen Rawat38b21462018-05-31 15:04:16 -070016953 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16954 WMI_LOGE(FL("too many channels"));
16955 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16956 }
16957
16958 for (i = 0; i < rsp->num_channels; i++) {
16959 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16960 rsp->ch[i].nss = event->nss_list[i];
16961 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16962 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16963 ch_mode);
16964 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16965 rsp->ch[i].channel,
16966 rsp->ch[i].ch_width,
16967 rsp->ch[i].nss);
16968 }
16969
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016970 if (event->ndp_transport_ip_param &&
16971 event->num_ndp_transport_ip_param) {
16972 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16973 rsp->is_ipv6_addr_present = true;
16974 qdf_mem_copy(rsp->ipv6_addr,
16975 event->ndp_transport_ip_param->ipv6_intf_addr,
16976 WMI_NDP_IPV6_INTF_ADDR_LEN);
16977 }
16978
16979 if (event->ndp_transport_ip_param->trans_port_present) {
16980 rsp->is_port_present = true;
16981 rsp->port =
16982 event->ndp_transport_ip_param->transport_port;
16983 }
16984
16985 if (event->ndp_transport_ip_param->trans_proto_present) {
16986 rsp->is_protocol_present = true;
16987 rsp->protocol =
16988 event->ndp_transport_ip_param->transport_protocol;
16989 }
16990 }
16991 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16992 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16993 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
16994 WMI_LOGD(FL("protocol: %d present: %d"),
16995 rsp->protocol, rsp->is_protocol_present);
16996
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016997 return QDF_STATUS_SUCCESS;
16998}
16999
17000static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017001 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017002{
17003 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17004 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17005
17006 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17007 fixed_params = event->fixed_param;
17008
17009 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",
17010 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017011 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17012 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017013
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017014 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017015 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17016 fixed_params->vdev_id,
17017 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017018 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017019 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017020 return QDF_STATUS_E_INVAL;
17021 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017022 rsp->transaction_id = fixed_params->transaction_id;
17023 rsp->reason = fixed_params->reason_code;
17024 rsp->status = fixed_params->rsp_status;
17025 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017026 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017027 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017028
17029 return QDF_STATUS_SUCCESS;
17030}
17031
17032static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017033 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017034{
17035 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17036 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17037
17038 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17039 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017040 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 -080017041 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17042 fixed_params->rsp_status, fixed_params->reason_code);
17043
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017044 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017045 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017046 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017047 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017048 return QDF_STATUS_E_INVAL;
17049 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017050 rsp->transaction_id = fixed_params->transaction_id;
17051 rsp->reason = fixed_params->reason_code;
17052 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017053
17054 return QDF_STATUS_SUCCESS;
17055}
17056
17057static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17058 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17059{
17060 uint32_t i, buf_size;
17061 wmi_ndp_end_indication *ind;
17062 struct qdf_mac_addr peer_addr;
17063 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17064
17065 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17066 ind = event->ndp_end_indication_list;
17067
17068 if (event->num_ndp_end_indication_list == 0) {
17069 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017070 return QDF_STATUS_E_INVAL;
17071 }
17072
17073 WMI_LOGD("number of ndp instances = %d",
17074 event->num_ndp_end_indication_list);
17075
17076 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17077 sizeof((*rsp)->ndp_map[0]))) {
17078 WMI_LOGE("num_ndp_end_ind_list %d too large",
17079 event->num_ndp_end_indication_list);
17080 return QDF_STATUS_E_INVAL;
17081 }
17082
17083 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17084 sizeof((*rsp)->ndp_map[0]);
17085 *rsp = qdf_mem_malloc(buf_size);
17086 if (!(*rsp)) {
17087 WMI_LOGE("Failed to allocate memory");
17088 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017089 }
17090
17091 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17092 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17093 if (!(*rsp)->vdev) {
17094 WMI_LOGE("vdev is null");
17095 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017096 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017097 return QDF_STATUS_E_INVAL;
17098 }
17099
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017100 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17101 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17102 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17103 peer_addr.bytes);
17104 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17105 i, ind[i].type, ind[i].reason_code,
17106 ind[i].ndp_instance_id,
17107 ind[i].num_active_ndps_on_peer);
17108 /* Add each instance entry to the list */
17109 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17110 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17111 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17112 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17113 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17114 ind[i].num_active_ndps_on_peer;
17115 (*rsp)->ndp_map[i].type = ind[i].type;
17116 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17117 }
17118
17119 return QDF_STATUS_SUCCESS;
17120}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017121
17122static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17123 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17124{
17125 uint8_t i;
17126 WMI_HOST_WLAN_PHY_MODE ch_mode;
17127 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17128 wmi_ndl_schedule_update_fixed_param *fixed_params;
17129
17130 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17131 fixed_params = event->fixed_param;
17132
17133 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17134 fixed_params->flags, fixed_params->num_channels,
17135 fixed_params->num_ndp_instances);
17136
17137 ind->vdev =
17138 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17139 fixed_params->vdev_id,
17140 WLAN_NAN_ID);
17141 if (!ind->vdev) {
17142 WMI_LOGE("vdev is null");
17143 return QDF_STATUS_E_INVAL;
17144 }
17145
17146 ind->flags = fixed_params->flags;
17147 ind->num_channels = fixed_params->num_channels;
17148 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17149 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17150 ind->peer_addr.bytes);
17151
17152 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17153 WMI_LOGE(FL("uint32 overflow"));
17154 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17155 return QDF_STATUS_E_INVAL;
17156 }
17157
17158 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17159 sizeof(uint32_t) * ind->num_ndp_instances);
17160
17161 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17162 WMI_LOGE(FL("too many channels"));
17163 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17164 }
17165 for (i = 0; i < ind->num_channels; i++) {
17166 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17167 ind->ch[i].nss = event->nss_list[i];
17168 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17169 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17170 ch_mode);
17171 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17172 ind->ch[i].channel,
17173 ind->ch[i].ch_width,
17174 ind->ch[i].nss);
17175 }
17176
17177 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17178 WMI_LOGD(FL("instance_id[%d]: %d"),
17179 i, event->ndp_instance_list[i]);
17180
17181 return QDF_STATUS_SUCCESS;
17182}
17183
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017184#endif
17185
Naveen Rawat963ee942018-04-13 16:38:36 -070017186#ifdef QCA_SUPPORT_CP_STATS
17187/**
17188 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17189 * @wmi_handle: wma handle
17190 * @evt_buf: event buffer
17191 * @out_buff: buffer to populated after stats extraction
17192 *
17193 * Return: status of operation
17194 */
17195static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17196 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17197{
17198 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17199 wmi_congestion_stats *congestion_stats;
17200
17201 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17202 congestion_stats = param_buf->congestion_stats;
17203 if (!congestion_stats) {
17204 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17205 return QDF_STATUS_E_INVAL;
17206 }
17207
17208 out_buff->vdev_id = congestion_stats->vdev_id;
17209 out_buff->congestion = congestion_stats->congestion;
17210
17211 WMI_LOGD("%s: cca stats event processed", __func__);
17212 return QDF_STATUS_SUCCESS;
17213}
17214#endif /* QCA_SUPPORT_CP_STATS */
17215
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017216/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017217 * save_service_bitmap_tlv() - save service bitmap
17218 * @wmi_handle: wmi handle
17219 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017220 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017221 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017222 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017223 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017224static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017225QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017226 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017227{
17228 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017229 struct wmi_soc *soc = wmi_handle->soc;
17230
Govind Singhe7f2f342016-05-23 12:12:52 +053017231 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17232
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017233 /* If it is already allocated, use that buffer. This can happen
17234 * during target stop/start scenarios where host allocation is skipped.
17235 */
17236 if (!soc->wmi_service_bitmap) {
17237 soc->wmi_service_bitmap =
17238 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17239 if (!soc->wmi_service_bitmap) {
17240 WMI_LOGE("Failed memory allocation for service bitmap");
17241 return QDF_STATUS_E_NOMEM;
17242 }
17243 }
17244
17245 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017246 param_buf->wmi_service_bitmap,
17247 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017248
17249 if (bitmap_buf)
17250 qdf_mem_copy(bitmap_buf,
17251 param_buf->wmi_service_bitmap,
17252 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017253
17254 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017255}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017256
17257/**
17258 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17259 * @wmi_handle: wmi handle
17260 * @param evt_buf: pointer to event buffer
17261 * @param bitmap_buf: bitmap buffer, for converged legacy support
17262 *
17263 * Return: QDF_STATUS
17264 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017265static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017266QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017267 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017268{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017269 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17270 wmi_service_available_event_fixed_param *ev;
17271 struct wmi_soc *soc = wmi_handle->soc;
17272
17273 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17274
17275 ev = param_buf->fixed_param;
17276
17277 /* If it is already allocated, use that buffer. This can happen
17278 * during target stop/start scenarios where host allocation is skipped.
17279 */
17280 if (!soc->wmi_ext_service_bitmap) {
17281 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17282 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17283 if (!soc->wmi_ext_service_bitmap) {
17284 WMI_LOGE("Failed memory allocation for service bitmap");
17285 return QDF_STATUS_E_NOMEM;
17286 }
17287 }
17288
17289 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17290 ev->wmi_service_segment_bitmap,
17291 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017292
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017293 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17294 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17295 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17296
Rajeev Kumar77901472017-02-12 02:12:17 -080017297 if (bitmap_buf)
17298 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017299 soc->wmi_ext_service_bitmap,
17300 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017301
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017302 return QDF_STATUS_SUCCESS;
17303}
Govind Singhe7f2f342016-05-23 12:12:52 +053017304/**
17305 * is_service_enabled_tlv() - Check if service enabled
17306 * @param wmi_handle: wmi handle
17307 * @param service_id: service identifier
17308 *
17309 * Return: 1 enabled, 0 disabled
17310 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017311static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17312 uint32_t service_id)
17313{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017314 struct wmi_soc *soc = wmi_handle->soc;
17315
17316 if (!soc->wmi_service_bitmap) {
17317 WMI_LOGE("WMI service bit map is not saved yet\n");
17318 return false;
17319 }
17320
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017321 /* if wmi_service_enabled was received with extended bitmap,
17322 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017323 */
17324 if (soc->wmi_ext_service_bitmap)
17325 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17326 soc->wmi_ext_service_bitmap,
17327 service_id);
17328
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017329 if (service_id >= WMI_MAX_SERVICE) {
17330 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17331 service_id);
17332 return false;
17333 }
17334
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017335 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17336 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017337}
Govind Singhe7f2f342016-05-23 12:12:52 +053017338
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017339static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17340 struct wlan_psoc_target_capability_info *cap)
17341{
17342 /* except LDPC all flags are common betwen legacy and here
17343 * also IBFEER is not defined for TLV
17344 */
17345 cap->ht_cap_info |= ev_target_cap & (
17346 WMI_HT_CAP_ENABLED
17347 | WMI_HT_CAP_HT20_SGI
17348 | WMI_HT_CAP_DYNAMIC_SMPS
17349 | WMI_HT_CAP_TX_STBC
17350 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17351 | WMI_HT_CAP_RX_STBC
17352 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17353 | WMI_HT_CAP_LDPC
17354 | WMI_HT_CAP_L_SIG_TXOP_PROT
17355 | WMI_HT_CAP_MPDU_DENSITY
17356 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17357 | WMI_HT_CAP_HT40_SGI);
17358 if (ev_target_cap & WMI_HT_CAP_LDPC)
17359 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17360 WMI_HOST_HT_CAP_TX_LDPC;
17361}
Govind Singhe7f2f342016-05-23 12:12:52 +053017362/**
17363 * extract_service_ready_tlv() - extract service ready event
17364 * @wmi_handle: wmi handle
17365 * @param evt_buf: pointer to received event buffer
17366 * @param cap: pointer to hold target capability information extracted from even
17367 *
17368 * Return: QDF_STATUS_SUCCESS for success or error code
17369 */
17370static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017371 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017372{
17373 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17374 wmi_service_ready_event_fixed_param *ev;
17375
17376
17377 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17378
17379 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17380 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017381 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017382 return QDF_STATUS_E_FAILURE;
17383 }
17384
17385 cap->phy_capability = ev->phy_capability;
17386 cap->max_frag_entry = ev->max_frag_entry;
17387 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017388 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017389 cap->vht_cap_info = ev->vht_cap_info;
17390 cap->vht_supp_mcs = ev->vht_supp_mcs;
17391 cap->hw_min_tx_power = ev->hw_min_tx_power;
17392 cap->hw_max_tx_power = ev->hw_max_tx_power;
17393 cap->sys_cap_info = ev->sys_cap_info;
17394 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17395 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17396 cap->max_num_scan_channels = ev->max_num_scan_channels;
17397 cap->max_supported_macs = ev->max_supported_macs;
17398 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17399 cap->txrx_chainmask = ev->txrx_chainmask;
17400 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17401 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017402 cap->fw_version = ev->fw_build_vers;
17403 /* fw_version_1 is not available in TLV. */
17404 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017405
17406 return QDF_STATUS_SUCCESS;
17407}
17408
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017409/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17410 * to host internal WMI_HOST_REGDMN_MODE values.
17411 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17412 * host currently. Add this in the future if required.
17413 * 11AX (Phase II) : 11ax related values are not currently
17414 * advertised separately by FW. As part of phase II regulatory bring-up,
17415 * finalize the advertisement mechanism.
17416 * @target_wireless_mode: target wireless mode received in message
17417 *
17418 * Return: returns the host internal wireless mode.
17419 */
17420static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17421{
17422
17423 uint32_t wireless_modes = 0;
17424
17425 if (target_wireless_mode & REGDMN_MODE_11A)
17426 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17427
17428 if (target_wireless_mode & REGDMN_MODE_TURBO)
17429 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17430
17431 if (target_wireless_mode & REGDMN_MODE_11B)
17432 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17433
17434 if (target_wireless_mode & REGDMN_MODE_PUREG)
17435 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17436
17437 if (target_wireless_mode & REGDMN_MODE_11G)
17438 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17439
17440 if (target_wireless_mode & REGDMN_MODE_108G)
17441 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17442
17443 if (target_wireless_mode & REGDMN_MODE_108A)
17444 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17445
17446 if (target_wireless_mode & REGDMN_MODE_XR)
17447 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17448
17449 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17450 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17451
17452 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17453 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17454
17455 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17456 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17457
17458 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17459 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17460
17461 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17462 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17463
17464 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17465 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17466
17467 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17468 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17469
17470 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17471 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17472
17473 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17474 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17475
17476 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17477 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17478
17479 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17480 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17481
17482 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17483 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17484
17485 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17486 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17487
17488 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17489 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17490
17491 return wireless_modes;
17492}
17493
Govind Singhe7f2f342016-05-23 12:12:52 +053017494/**
17495 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17496 * @wmi_handle: wmi handle
17497 * @param evt_buf: Pointer to event buffer
17498 * @param cap: pointer to hold HAL reg capabilities
17499 *
17500 * Return: QDF_STATUS_SUCCESS for success or error code
17501 */
17502static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017503 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017504{
17505 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17506
17507 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17508
17509 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17510 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017511 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017512
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017513 cap->wireless_modes = convert_wireless_modes_tlv(
17514 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017515
Govind Singhe7f2f342016-05-23 12:12:52 +053017516 return QDF_STATUS_SUCCESS;
17517}
17518
17519/**
17520 * extract_host_mem_req_tlv() - Extract host memory request event
17521 * @wmi_handle: wmi handle
17522 * @param evt_buf: pointer to event buffer
17523 * @param num_entries: pointer to hold number of entries requested
17524 *
17525 * Return: Number of entries requested
17526 */
17527static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17528 void *evt_buf, uint8_t *num_entries)
17529{
17530 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17531 wmi_service_ready_event_fixed_param *ev;
17532
17533 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17534
17535 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17536 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017537 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017538 return NULL;
17539 }
17540
17541 *num_entries = ev->num_mem_reqs;
17542
17543 return (host_mem_req *)param_buf->mem_reqs;
17544}
17545
17546/**
17547 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17548 * ready function
17549 * @wmi_handle: wmi handle
17550 * @param evt_buf: pointer to event buffer
17551 *
17552 * Return: QDF_STATUS_SUCCESS for success or error code
17553 */
17554static QDF_STATUS
17555save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17556{
17557 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17558 wmi_service_ready_event_fixed_param *ev;
17559
17560
17561 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17562
17563 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17564 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017565 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017566 return QDF_STATUS_E_FAILURE;
17567 }
17568
17569 /*Save fw version from service ready message */
17570 /*This will be used while sending INIT message */
17571 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17572 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017573
Govind Singhe7f2f342016-05-23 12:12:52 +053017574 return QDF_STATUS_SUCCESS;
17575}
17576
17577/**
17578 * ready_extract_init_status_tlv() - Extract init status from ready event
17579 * @wmi_handle: wmi handle
17580 * @param evt_buf: Pointer to event buffer
17581 *
17582 * Return: ready status
17583 */
17584static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17585 void *evt_buf)
17586{
17587 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17588 wmi_ready_event_fixed_param *ev = NULL;
17589
Govind Singhe7f2f342016-05-23 12:12:52 +053017590 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17591 ev = param_buf->fixed_param;
17592
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017593 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +053017594
17595 return ev->status;
17596}
17597
17598/**
17599 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17600 * @wmi_handle: wmi handle
17601 * @param evt_buf: pointer to event buffer
17602 * @param macaddr: Pointer to hold MAC address
17603 *
17604 * Return: QDF_STATUS_SUCCESS for success or error code
17605 */
17606static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17607 void *evt_buf, uint8_t *macaddr)
17608{
17609 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17610 wmi_ready_event_fixed_param *ev = NULL;
17611
17612
17613 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17614 ev = param_buf->fixed_param;
17615
17616 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17617
17618 return QDF_STATUS_SUCCESS;
17619}
17620
17621/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017622 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17623 * @wmi_handle: wmi handle
17624 * @param evt_buf: pointer to event buffer
17625 * @param macaddr: Pointer to hold number of MAC addresses
17626 *
17627 * Return: Pointer to addr list
17628 */
17629static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17630 void *evt_buf, uint8_t *num_mac)
17631{
17632 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17633 wmi_ready_event_fixed_param *ev = NULL;
17634
17635 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17636 ev = param_buf->fixed_param;
17637
17638 *num_mac = ev->num_extra_mac_addr;
17639
17640 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17641}
17642
17643/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017644 * extract_ready_params_tlv() - Extract data from ready event apart from
17645 * status, macaddr and version.
17646 * @wmi_handle: Pointer to WMI handle.
17647 * @evt_buf: Pointer to Ready event buffer.
17648 * @ev_param: Pointer to host defined struct to copy the data from event.
17649 *
17650 * Return: QDF_STATUS_SUCCESS on success.
17651 */
17652static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17653 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17654{
17655 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17656 wmi_ready_event_fixed_param *ev = NULL;
17657
17658 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17659 ev = param_buf->fixed_param;
17660
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017661 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017662 ev_param->num_dscp_table = ev->num_dscp_table;
17663 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17664 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017665 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017666 /* Agile_cap in ready event is not supported in TLV target */
17667 ev_param->agile_capability = false;
17668
17669 return QDF_STATUS_SUCCESS;
17670}
17671
17672/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017673 * extract_dbglog_data_len_tlv() - extract debuglog data length
17674 * @wmi_handle: wmi handle
17675 * @param evt_buf: pointer to event buffer
17676 *
17677 * Return: length
17678 */
17679static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017680 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017681{
17682 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17683
17684 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17685
17686 *len = param_buf->num_bufp;
17687
17688 return param_buf->bufp;
17689}
17690
17691/**
17692 * extract_vdev_start_resp_tlv() - extract vdev start response
17693 * @wmi_handle: wmi handle
17694 * @param evt_buf: pointer to event buffer
17695 * @param vdev_rsp: Pointer to hold vdev response
17696 *
17697 * Return: QDF_STATUS_SUCCESS for success or error code
17698 */
17699static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17700 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17701{
17702 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17703 wmi_vdev_start_response_event_fixed_param *ev;
17704
17705 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17706 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017707 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017708 return QDF_STATUS_E_INVAL;
17709 }
17710
17711 ev = param_buf->fixed_param;
17712 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017713 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017714 return QDF_STATUS_E_INVAL;
17715 }
17716
17717 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17718
17719 vdev_rsp->vdev_id = ev->vdev_id;
17720 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017721 switch (ev->resp_type) {
17722 case WMI_VDEV_START_RESP_EVENT:
17723 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17724 break;
17725 case WMI_VDEV_RESTART_RESP_EVENT:
17726 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17727 break;
17728 default:
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017729 qdf_print("Invalid start response event buffer");
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017730 break;
17731 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017732 vdev_rsp->status = ev->status;
17733 vdev_rsp->chain_mask = ev->chain_mask;
17734 vdev_rsp->smps_mode = ev->smps_mode;
17735 vdev_rsp->mac_id = ev->mac_id;
17736 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17737 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17738
17739 return QDF_STATUS_SUCCESS;
17740}
17741
17742/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017743 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17744 * @wmi_handle: wmi handle
17745 * @param evt_buf: pointer to event buffer
17746 * @param delete_rsp: Pointer to hold vdev delete response
17747 *
17748 * Return: QDF_STATUS_SUCCESS for success or error code
17749 */
17750static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17751 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17752{
17753 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17754 wmi_vdev_delete_resp_event_fixed_param *ev;
17755
17756 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17757 if (!param_buf) {
17758 WMI_LOGE("Invalid vdev delete response event buffer\n");
17759 return QDF_STATUS_E_INVAL;
17760 }
17761
17762 ev = param_buf->fixed_param;
17763 if (!ev) {
17764 WMI_LOGE("Invalid vdev delete response event\n");
17765 return QDF_STATUS_E_INVAL;
17766 }
17767
17768 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17769 delete_rsp->vdev_id = ev->vdev_id;
17770
17771 return QDF_STATUS_SUCCESS;
17772}
17773
17774
17775/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017776 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017777 * @wmi_handle: wmi handle
17778 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017779 * @param num_vdevs: Pointer to hold num vdev
17780 *
17781 * Return: QDF_STATUS_SUCCESS for success or error code
17782 */
17783static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17784 void *evt_buf, uint32_t *num_vdevs)
17785{
17786 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17787 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17788 uint32_t vdev_map;
17789
17790 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17791 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017792 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017793 return QDF_STATUS_E_INVAL;
17794 }
17795 tbtt_offset_event = param_buf->fixed_param;
17796 vdev_map = tbtt_offset_event->vdev_map;
17797 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17798
17799 return QDF_STATUS_SUCCESS;
17800}
17801
17802/**
17803 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17804 * @wmi_handle: wmi handle
17805 * @param evt_buf: pointer to event buffer
17806 * @param num_vdevs: Pointer to hold num vdev
17807 *
17808 * Return: QDF_STATUS_SUCCESS for success or error code
17809 */
17810static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17811 void *evt_buf, uint32_t *num_vdevs)
17812{
17813 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17814 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17815
17816 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17817 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017818 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017819 return QDF_STATUS_E_INVAL;
17820 }
17821 tbtt_offset_ext_event = param_buf->fixed_param;
17822
17823 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17824
17825 return QDF_STATUS_SUCCESS;
17826}
17827
17828/**
17829 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17830 * @wmi_handle: wmi handle
17831 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017832 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017833 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017834 *
17835 * Return: QDF_STATUS_SUCCESS for success or error code
17836 */
17837static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017838 void *evt_buf, uint8_t idx,
17839 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017840{
17841 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17842 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017843 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017844
17845 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17846 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017847 qdf_print("Invalid tbtt update event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017848 return QDF_STATUS_E_INVAL;
17849 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017850
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017851 tbtt_offset_event = param_buf->fixed_param;
17852 vdev_map = tbtt_offset_event->vdev_map;
17853 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17854 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17855 return QDF_STATUS_E_INVAL;
17856 tbtt_param->tbttoffset =
17857 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17858
17859 return QDF_STATUS_SUCCESS;
17860}
17861
17862/**
17863 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17864 * @wmi_handle: wmi handle
17865 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017866 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017867 * @param tbtt_param: Pointer to tbttoffset event param
17868 *
17869 * Return: QDF_STATUS_SUCCESS for success or error code
17870 */
17871static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17872 void *evt_buf, uint8_t idx,
17873 struct tbttoffset_params *tbtt_param)
17874{
17875 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17876 wmi_tbtt_offset_info *tbtt_offset_info;
17877
17878 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17879 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017880 qdf_print("Invalid tbtt update event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017881 return QDF_STATUS_E_INVAL;
17882 }
17883 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17884
17885 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17886 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017887
17888 return QDF_STATUS_SUCCESS;
17889}
17890
17891/**
17892 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17893 * @wmi_handle: wmi handle
17894 * @param evt_buf: pointer to event buffer
17895 * @param hdr: Pointer to hold header
17896 * @param bufp: Pointer to hold pointer to rx param buffer
17897 *
17898 * Return: QDF_STATUS_SUCCESS for success or error code
17899 */
17900static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017901 void *evt_buf, struct mgmt_rx_event_params *hdr,
17902 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017903{
17904 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17905 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017906 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017907
17908 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17909 if (!param_tlvs) {
17910 WMI_LOGE("Get NULL point message from FW");
17911 return QDF_STATUS_E_INVAL;
17912 }
17913
17914 ev_hdr = param_tlvs->hdr;
17915 if (!hdr) {
17916 WMI_LOGE("Rx event is NULL");
17917 return QDF_STATUS_E_INVAL;
17918 }
17919
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017920 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17921 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017922
17923 hdr->channel = ev_hdr->channel;
17924 hdr->snr = ev_hdr->snr;
17925 hdr->rate = ev_hdr->rate;
17926 hdr->phy_mode = ev_hdr->phy_mode;
17927 hdr->buf_len = ev_hdr->buf_len;
17928 hdr->status = ev_hdr->status;
17929 hdr->flags = ev_hdr->flags;
17930 hdr->rssi = ev_hdr->rssi;
17931 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017932 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17933 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017934
17935 *bufp = param_tlvs->bufp;
17936
17937 return QDF_STATUS_SUCCESS;
17938}
17939
17940/**
17941 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17942 * @wmi_handle: wmi handle
17943 * @param evt_buf: pointer to event buffer
17944 * @param vdev_id: Pointer to hold vdev identifier
17945 *
17946 * Return: QDF_STATUS_SUCCESS for success or error code
17947 */
17948static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17949 void *evt_buf, uint32_t *vdev_id)
17950{
17951 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17952 wmi_vdev_stopped_event_fixed_param *resp_event;
17953
17954 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17955 if (!param_buf) {
17956 WMI_LOGE("Invalid event buffer");
17957 return QDF_STATUS_E_INVAL;
17958 }
17959 resp_event = param_buf->fixed_param;
17960 *vdev_id = resp_event->vdev_id;
17961
17962 return QDF_STATUS_SUCCESS;
17963}
17964
17965/**
17966 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17967 * @wmi_handle: wmi handle
17968 * @param evt_buf: pointer to event buffer
17969 * @param param: Pointer to hold roam param
17970 *
17971 * Return: QDF_STATUS_SUCCESS for success or error code
17972 */
17973static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17974 void *evt_buf, wmi_host_roam_event *param)
17975{
17976 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17977 wmi_roam_event_fixed_param *evt;
17978
17979 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17980 if (!param_buf) {
17981 WMI_LOGE("Invalid roam event buffer");
17982 return QDF_STATUS_E_INVAL;
17983 }
17984
17985 evt = param_buf->fixed_param;
17986 qdf_mem_zero(param, sizeof(*param));
17987
17988 param->vdev_id = evt->vdev_id;
17989 param->reason = evt->reason;
17990 param->rssi = evt->rssi;
17991
17992 return QDF_STATUS_SUCCESS;
17993}
17994
17995/**
17996 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
17997 * @wmi_handle: wmi handle
17998 * @param evt_buf: pointer to event buffer
17999 * @param param: Pointer to hold vdev scan param
18000 *
18001 * Return: QDF_STATUS_SUCCESS for success or error code
18002 */
18003static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018004 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018005{
18006 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18007 wmi_scan_event_fixed_param *evt = NULL;
18008
18009 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18010 evt = param_buf->fixed_param;
18011
18012 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018013
Govind Singhe7f2f342016-05-23 12:12:52 +053018014 switch (evt->event) {
18015 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018016 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018017 break;
18018 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018019 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018020 break;
18021 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018022 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018023 break;
18024 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018025 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018026 break;
18027 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018028 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018029 break;
18030 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018031 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018032 break;
18033 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018034 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018035 break;
18036 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018037 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018038 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018039 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018040 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018041 break;
18042 case WMI_SCAN_EVENT_MAX:
18043 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018044 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018045 break;
18046 };
18047
18048 switch (evt->reason) {
18049 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018050 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018051 break;
18052 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018053 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018054 break;
18055 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018056 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018057 break;
18058 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018059 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018060 break;
18061 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018062 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018063 break;
18064 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018065 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018066 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018067 case WMI_SCAN_REASON_SUSPENDED:
18068 param->reason = SCAN_REASON_SUSPENDED;
18069 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018070 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018071 param->reason = SCAN_REASON_MAX;
18072 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018073 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018074 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018075 break;
18076 };
18077
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018078 param->chan_freq = evt->channel_freq;
18079 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018080 param->scan_id = evt->scan_id;
18081 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018082 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018083
18084 return QDF_STATUS_SUCCESS;
18085}
18086
Frank Liu3d5e9992017-03-15 17:51:43 +080018087#ifdef CONVERGED_TDLS_ENABLE
18088/**
18089 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18090 * @wmi_handle: wmi handle
18091 * @param evt_buf: pointer to event buffer
18092 * @param param: Pointer to hold vdev tdls param
18093 *
18094 * Return: QDF_STATUS_SUCCESS for success or error code
18095 */
18096static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18097 void *evt_buf, struct tdls_event_info *param)
18098{
18099 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18100 wmi_tdls_peer_event_fixed_param *evt;
18101
18102 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18103 if (!param_buf) {
18104 WMI_LOGE("%s: NULL param_buf", __func__);
18105 return QDF_STATUS_E_NULL_VALUE;
18106 }
18107
18108 evt = param_buf->fixed_param;
18109
18110 qdf_mem_zero(param, sizeof(*param));
18111
18112 param->vdev_id = evt->vdev_id;
18113 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18114 param->peermac.bytes);
18115 switch (evt->peer_status) {
18116 case WMI_TDLS_SHOULD_DISCOVER:
18117 param->message_type = TDLS_SHOULD_DISCOVER;
18118 break;
18119 case WMI_TDLS_SHOULD_TEARDOWN:
18120 param->message_type = TDLS_SHOULD_TEARDOWN;
18121 break;
18122 case WMI_TDLS_PEER_DISCONNECTED:
18123 param->message_type = TDLS_PEER_DISCONNECTED;
18124 break;
18125 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18126 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18127 break;
18128 default:
18129 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18130 __func__, evt->peer_status);
18131 return QDF_STATUS_E_INVAL;
18132 };
18133
18134 switch (evt->peer_reason) {
18135 case WMI_TDLS_TEARDOWN_REASON_TX:
18136 param->peer_reason = TDLS_TEARDOWN_TX;
18137 break;
18138 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18139 param->peer_reason = TDLS_TEARDOWN_RSSI;
18140 break;
18141 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18142 param->peer_reason = TDLS_TEARDOWN_SCAN;
18143 break;
18144 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18145 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18146 break;
18147 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18148 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18149 break;
18150 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18151 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18152 break;
18153 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18154 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18155 break;
18156 case WMI_TDLS_ENTER_BUF_STA:
18157 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18158 break;
18159 case WMI_TDLS_EXIT_BUF_STA:
18160 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18161 break;
18162 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18163 param->peer_reason = TDLS_ENTER_BT_BUSY;
18164 break;
18165 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18166 param->peer_reason = TDLS_EXIT_BT_BUSY;
18167 break;
18168 case WMI_TDLS_SCAN_STARTED_EVENT:
18169 param->peer_reason = TDLS_SCAN_STARTED;
18170 break;
18171 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18172 param->peer_reason = TDLS_SCAN_COMPLETED;
18173 break;
18174
18175 default:
18176 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18177 __func__, evt->peer_reason, evt->peer_status);
18178 return QDF_STATUS_E_INVAL;
18179 };
18180
18181 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18182 __func__, param->peermac.bytes, param->message_type,
18183 param->peer_reason, param->vdev_id);
18184
18185 return QDF_STATUS_SUCCESS;
18186}
18187#endif
18188
Govind Singhe7f2f342016-05-23 12:12:52 +053018189/**
18190 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18191 * @wmi_handle: wmi handle
18192 * @param evt_buf: pointer to event buffer
18193 * @param param: Pointer to hold MGMT TX completion params
18194 *
18195 * Return: QDF_STATUS_SUCCESS for success or error code
18196 */
18197static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18198 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18199{
18200 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18201 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18202
18203 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18204 evt_buf;
18205 if (!param_buf) {
18206 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18207 return QDF_STATUS_E_INVAL;
18208 }
18209 cmpl_params = param_buf->fixed_param;
18210
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018211 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18212 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018213 param->desc_id = cmpl_params->desc_id;
18214 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018215 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018216
18217 return QDF_STATUS_SUCCESS;
18218}
18219
18220/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018221 * extract_offchan_data_tx_compl_param_tlv() -
18222 * extract Offchan data tx completion event params
18223 * @wmi_handle: wmi handle
18224 * @param evt_buf: pointer to event buffer
18225 * @param param: Pointer to hold offchan data TX completion params
18226 *
18227 * Return: QDF_STATUS_SUCCESS for success or error code
18228 */
18229static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18230 wmi_unified_t wmi_handle, void *evt_buf,
18231 struct wmi_host_offchan_data_tx_compl_event *param)
18232{
18233 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18234 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18235
18236 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18237 evt_buf;
18238 if (!param_buf) {
18239 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18240 return QDF_STATUS_E_INVAL;
18241 }
18242 cmpl_params = param_buf->fixed_param;
18243
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018244 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18245 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018246 param->desc_id = cmpl_params->desc_id;
18247 param->status = cmpl_params->status;
18248
18249 return QDF_STATUS_SUCCESS;
18250}
18251
18252/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018253 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18254 * status tlv
18255 * @wmi_handle: wmi handle
18256 * @param evt_buf: pointer to event buffer
18257 * @param param: Pointer to hold csa switch count status event param
18258 *
18259 * Return: QDF_STATUS_SUCCESS for success or error code
18260 */
18261static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18262 wmi_unified_t wmi_handle,
18263 void *evt_buf,
18264 struct pdev_csa_switch_count_status *param)
18265{
18266 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18267 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18268
18269 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18270 evt_buf;
18271 if (!param_buf) {
18272 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18273 return QDF_STATUS_E_INVAL;
18274 }
18275
18276 csa_status = param_buf->fixed_param;
18277
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018278 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18279 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018280 param->current_switch_count = csa_status->current_switch_count;
18281 param->num_vdevs = csa_status->num_vdevs;
18282 param->vdev_ids = param_buf->vdev_ids;
18283
18284 return QDF_STATUS_SUCCESS;
18285}
18286
18287/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018288 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18289 * param from event
18290 * @wmi_handle: wmi handle
18291 * @param evt_buf: pointer to event buffer
18292 * @param param: Pointer to hold tpc configuration
18293 *
18294 * Return: 0 for success or error code
18295 */
18296static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18297 void *evt_buf,
18298 wmi_host_pdev_tpc_config_event *param)
18299{
18300 wmi_pdev_tpc_config_event_fixed_param *event =
18301 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18302
18303 if (!event) {
18304 WMI_LOGE("Invalid event buffer");
18305 return QDF_STATUS_E_INVAL;
18306 }
18307
18308 param->pdev_id = event->pdev_id;
18309 param->regDomain = event->regDomain;
18310 param->chanFreq = event->chanFreq;
18311 param->phyMode = event->phyMode;
18312 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018313 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018314 param->twiceMaxRDPower = event->twiceMaxRDPower;
18315 param->powerLimit = event->powerLimit;
18316 param->rateMax = event->rateMax;
18317 param->numTxChain = event->numTxChain;
18318 param->ctl = event->ctl;
18319 param->flags = event->flags;
18320
18321 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18322 sizeof(param->maxRegAllowedPower));
18323 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18324 event->maxRegAllowedPowerAGCDD,
18325 sizeof(param->maxRegAllowedPowerAGCDD));
18326 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18327 event->maxRegAllowedPowerAGSTBC,
18328 sizeof(param->maxRegAllowedPowerAGSTBC));
18329 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18330 event->maxRegAllowedPowerAGTXBF,
18331 sizeof(param->maxRegAllowedPowerAGTXBF));
18332 WMI_LOGD("%s:extract success", __func__);
18333
18334 return QDF_STATUS_SUCCESS;
18335}
18336
18337/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018338 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018339 * @wmi_handle: wmi handle
18340 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018341 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018342 *
18343 * Return: QDF_STATUS_SUCCESS for success or error code
18344 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018345static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18346 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018347{
18348 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18349 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018350 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018351
18352 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18353 if (!param_buf) {
18354 WMI_LOGE("Invalid swba event buffer");
18355 return QDF_STATUS_E_INVAL;
18356 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018357
Govind Singhe7f2f342016-05-23 12:12:52 +053018358 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018359 *num_vdevs = swba_event->num_vdevs;
18360 if (!(*num_vdevs)) {
18361 vdev_map = swba_event->vdev_map;
18362 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18363 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018364
18365 return QDF_STATUS_SUCCESS;
18366}
18367
18368/**
18369 * extract_swba_tim_info_tlv() - extract swba tim info from event
18370 * @wmi_handle: wmi handle
18371 * @param evt_buf: pointer to event buffer
18372 * @param idx: Index to bcn info
18373 * @param tim_info: Pointer to hold tim info
18374 *
18375 * Return: QDF_STATUS_SUCCESS for success or error code
18376 */
18377static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18378 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18379{
18380 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18381 wmi_tim_info *tim_info_ev;
18382
18383 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18384 if (!param_buf) {
18385 WMI_LOGE("Invalid swba event buffer");
18386 return QDF_STATUS_E_INVAL;
18387 }
18388
18389 tim_info_ev = &param_buf->tim_info[idx];
18390
18391 tim_info->tim_len = tim_info_ev->tim_len;
18392 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18393 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18394 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18395 tim_info->tim_changed = tim_info_ev->tim_changed;
18396 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018397 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018398
18399 return QDF_STATUS_SUCCESS;
18400}
18401
18402/**
18403 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18404 * @wmi_handle: wmi handle
18405 * @param evt_buf: pointer to event buffer
18406 * @param idx: Index to bcn info
18407 * @param p2p_desc: Pointer to hold p2p NoA info
18408 *
18409 * Return: QDF_STATUS_SUCCESS for success or error code
18410 */
18411static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18412 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18413{
18414 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18415 wmi_p2p_noa_info *p2p_noa_info;
18416 uint8_t i = 0;
18417
18418 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18419 if (!param_buf) {
18420 WMI_LOGE("Invalid swba event buffer");
18421 return QDF_STATUS_E_INVAL;
18422 }
18423
18424 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18425
18426 p2p_desc->modified = false;
18427 p2p_desc->num_descriptors = 0;
18428 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18429 p2p_desc->modified = true;
18430 p2p_desc->index =
18431 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18432 p2p_desc->oppPS =
18433 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18434 p2p_desc->ctwindow =
18435 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18436 p2p_desc->num_descriptors =
18437 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18438 (p2p_noa_info);
18439 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18440 p2p_desc->noa_descriptors[i].type_count =
18441 (uint8_t) p2p_noa_info->noa_descriptors[i].
18442 type_count;
18443 p2p_desc->noa_descriptors[i].duration =
18444 p2p_noa_info->noa_descriptors[i].duration;
18445 p2p_desc->noa_descriptors[i].interval =
18446 p2p_noa_info->noa_descriptors[i].interval;
18447 p2p_desc->noa_descriptors[i].start_time =
18448 p2p_noa_info->noa_descriptors[i].start_time;
18449 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018450 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018451 }
18452
18453 return QDF_STATUS_SUCCESS;
18454}
18455
Wu Gaocd3a8512017-03-13 20:17:34 +080018456#ifdef CONVERGED_P2P_ENABLE
18457/**
18458 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18459 * @wmi_handle: wmi handle
18460 * @param evt_buf: pointer to event buffer
18461 * @param param: Pointer to hold p2p noa info
18462 *
18463 * Return: QDF_STATUS_SUCCESS for success or error code
18464 */
18465static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18466 wmi_unified_t wmi_handle, void *evt_buf,
18467 struct p2p_noa_info *param)
18468{
18469 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18470 wmi_p2p_noa_event_fixed_param *fixed_param;
18471 uint8_t i;
18472 wmi_p2p_noa_info *wmi_noa_info;
18473 uint8_t *buf_ptr;
18474 uint32_t descriptors;
18475
18476 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18477 if (!param_tlvs) {
18478 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18479 return QDF_STATUS_E_INVAL;
18480 }
18481
18482 if (!param) {
18483 WMI_LOGE("noa information param is null");
18484 return QDF_STATUS_E_INVAL;
18485 }
18486
18487 fixed_param = param_tlvs->fixed_param;
18488 buf_ptr = (uint8_t *) fixed_param;
18489 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18490 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18491
18492 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18493 WMI_LOGE("%s: noa attr is not modified", __func__);
18494 return QDF_STATUS_E_INVAL;
18495 }
18496
18497 param->vdev_id = fixed_param->vdev_id;
18498 param->index =
18499 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18500 param->opps_ps =
18501 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18502 param->ct_window =
18503 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18504 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18505 param->num_desc = (uint8_t) descriptors;
18506
18507 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18508 param->index, param->opps_ps, param->ct_window,
18509 param->num_desc);
18510 for (i = 0; i < param->num_desc; i++) {
18511 param->noa_desc[i].type_count =
18512 (uint8_t) wmi_noa_info->noa_descriptors[i].
18513 type_count;
18514 param->noa_desc[i].duration =
18515 wmi_noa_info->noa_descriptors[i].duration;
18516 param->noa_desc[i].interval =
18517 wmi_noa_info->noa_descriptors[i].interval;
18518 param->noa_desc[i].start_time =
18519 wmi_noa_info->noa_descriptors[i].start_time;
18520 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18521 __func__, i, param->noa_desc[i].type_count,
18522 param->noa_desc[i].duration,
18523 param->noa_desc[i].interval,
18524 param->noa_desc[i].start_time);
18525 }
18526
18527 return QDF_STATUS_SUCCESS;
18528}
18529
18530/**
18531 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18532 * information from event
18533 * @wmi_handle: wmi handle
18534 * @param evt_buf: pointer to event buffer
18535 * @param param: Pointer to hold p2p lo stop event information
18536 *
18537 * Return: QDF_STATUS_SUCCESS for success or error code
18538 */
18539static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18540 wmi_unified_t wmi_handle, void *evt_buf,
18541 struct p2p_lo_event *param)
18542{
18543 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18544 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18545
18546 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18547 evt_buf;
18548 if (!param_tlvs) {
18549 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18550 return QDF_STATUS_E_INVAL;
18551 }
18552
18553 if (!param) {
18554 WMI_LOGE("lo stop event param is null");
18555 return QDF_STATUS_E_INVAL;
18556 }
18557
18558 lo_param = param_tlvs->fixed_param;
18559 param->vdev_id = lo_param->vdev_id;
18560 param->reason_code = lo_param->reason;
18561 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18562 param->vdev_id, param->reason_code);
18563
18564 return QDF_STATUS_SUCCESS;
18565}
18566#endif /* End of CONVERGED_P2P_ENABLE */
18567
Govind Singhe7f2f342016-05-23 12:12:52 +053018568/**
18569 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18570 * @wmi_handle: wmi handle
18571 * @param evt_buf: pointer to event buffer
18572 * @param ev: Pointer to hold peer param
18573 *
18574 * Return: QDF_STATUS_SUCCESS for success or error code
18575 */
18576static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18577 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18578{
18579 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18580 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18581
18582 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18583 kickout_event = param_buf->fixed_param;
18584
18585 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18586 ev->peer_macaddr);
18587
18588 ev->reason = kickout_event->reason;
18589 ev->rssi = kickout_event->rssi;
18590
18591 return QDF_STATUS_SUCCESS;
18592}
18593
18594/**
18595 * extract_all_stats_counts_tlv() - extract all stats count from event
18596 * @wmi_handle: wmi handle
18597 * @param evt_buf: pointer to event buffer
18598 * @param stats_param: Pointer to hold stats count
18599 *
18600 * Return: QDF_STATUS_SUCCESS for success or error code
18601 */
18602static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18603 void *evt_buf, wmi_host_stats_event *stats_param)
18604{
Govind Singhe7f2f342016-05-23 12:12:52 +053018605 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018606 wmi_per_chain_rssi_stats *rssi_event;
18607 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018608
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018609 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018610 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018611 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018612 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018613 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018614 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018615 return QDF_STATUS_E_FAILURE;
18616 }
18617
18618 switch (ev->stats_id) {
18619 case WMI_REQUEST_PEER_STAT:
18620 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18621 break;
18622
18623 case WMI_REQUEST_AP_STAT:
18624 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18625 break;
18626
18627 case WMI_REQUEST_PDEV_STAT:
18628 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18629 break;
18630
18631 case WMI_REQUEST_VDEV_STAT:
18632 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18633 break;
18634
18635 case WMI_REQUEST_BCNFLT_STAT:
18636 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18637 break;
18638
18639 case WMI_REQUEST_VDEV_RATE_STAT:
18640 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18641 break;
18642
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018643 case WMI_REQUEST_BCN_STAT:
18644 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18645 break;
18646
Govind Singhe7f2f342016-05-23 12:12:52 +053018647 default:
18648 stats_param->stats_id = 0;
18649 break;
18650
18651 }
18652
18653 stats_param->num_pdev_stats = ev->num_pdev_stats;
18654 stats_param->num_pdev_ext_stats = 0;
18655 stats_param->num_vdev_stats = ev->num_vdev_stats;
18656 stats_param->num_peer_stats = ev->num_peer_stats;
18657 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18658 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018659 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018660 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18661 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018662
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018663 /* if chain_stats is not populated */
18664 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18665 return QDF_STATUS_SUCCESS;
18666
18667 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18668 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18669 return QDF_STATUS_SUCCESS;
18670
18671 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018672 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018673 return QDF_STATUS_SUCCESS;
18674
18675 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18676
Govind Singhe7f2f342016-05-23 12:12:52 +053018677 return QDF_STATUS_SUCCESS;
18678}
18679
18680/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018681 * extract_pdev_tx_stats() - extract pdev tx stats from event
18682 */
18683static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18684{
18685 /* Tx Stats */
18686 tx->comp_queued = tx_stats->comp_queued;
18687 tx->comp_delivered = tx_stats->comp_delivered;
18688 tx->msdu_enqued = tx_stats->msdu_enqued;
18689 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18690 tx->wmm_drop = tx_stats->wmm_drop;
18691 tx->local_enqued = tx_stats->local_enqued;
18692 tx->local_freed = tx_stats->local_freed;
18693 tx->hw_queued = tx_stats->hw_queued;
18694 tx->hw_reaped = tx_stats->hw_reaped;
18695 tx->underrun = tx_stats->underrun;
18696 tx->tx_abort = tx_stats->tx_abort;
18697 tx->mpdus_requed = tx_stats->mpdus_requed;
18698 tx->data_rc = tx_stats->data_rc;
18699 tx->self_triggers = tx_stats->self_triggers;
18700 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18701 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18702 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18703 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18704 tx->pdev_resets = tx_stats->pdev_resets;
18705 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18706 tx->phy_underrun = tx_stats->phy_underrun;
18707 tx->txop_ovf = tx_stats->txop_ovf;
18708
18709 return;
18710}
18711
18712
18713/**
18714 * extract_pdev_rx_stats() - extract pdev rx stats from event
18715 */
18716static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18717{
18718 /* Rx Stats */
18719 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18720 rx->status_rcvd = rx_stats->status_rcvd;
18721 rx->r0_frags = rx_stats->r0_frags;
18722 rx->r1_frags = rx_stats->r1_frags;
18723 rx->r2_frags = rx_stats->r2_frags;
18724 /* Only TLV */
18725 rx->r3_frags = 0;
18726 rx->htt_msdus = rx_stats->htt_msdus;
18727 rx->htt_mpdus = rx_stats->htt_mpdus;
18728 rx->loc_msdus = rx_stats->loc_msdus;
18729 rx->loc_mpdus = rx_stats->loc_mpdus;
18730 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18731 rx->phy_errs = rx_stats->phy_errs;
18732 rx->phy_err_drop = rx_stats->phy_err_drop;
18733 rx->mpdu_errs = rx_stats->mpdu_errs;
18734
18735 return;
18736}
18737
18738/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018739 * extract_pdev_stats_tlv() - extract pdev stats from event
18740 * @wmi_handle: wmi handle
18741 * @param evt_buf: pointer to event buffer
18742 * @param index: Index into pdev stats
18743 * @param pdev_stats: Pointer to hold pdev stats
18744 *
18745 * Return: QDF_STATUS_SUCCESS for success or error code
18746 */
18747static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18748 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18749{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018750 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18751 wmi_stats_event_fixed_param *ev_param;
18752 uint8_t *data;
18753
18754 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18755 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18756
18757 data = param_buf->data;
18758
18759 if (index < ev_param->num_pdev_stats) {
18760 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18761 (index * sizeof(wmi_pdev_stats)));
18762
18763 pdev_stats->chan_nf = ev->chan_nf;
18764 pdev_stats->tx_frame_count = ev->tx_frame_count;
18765 pdev_stats->rx_frame_count = ev->rx_frame_count;
18766 pdev_stats->rx_clear_count = ev->rx_clear_count;
18767 pdev_stats->cycle_count = ev->cycle_count;
18768 pdev_stats->phy_err_count = ev->phy_err_count;
18769 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18770
18771 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18772 &(ev->pdev_stats.tx));
18773 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18774 &(ev->pdev_stats.rx));
18775 }
18776
Govind Singhe7f2f342016-05-23 12:12:52 +053018777 return QDF_STATUS_SUCCESS;
18778}
18779
18780/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018781 * extract_unit_test_tlv() - extract unit test data
18782 * @wmi_handle: wmi handle
18783 * @param evt_buf: pointer to event buffer
18784 * @param unit_test: pointer to hold unit test data
18785 * @param maxspace: Amount of space in evt_buf
18786 *
18787 * Return: QDF_STATUS_SUCCESS for success or error code
18788 */
18789static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18790 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18791{
18792 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18793 wmi_unit_test_event_fixed_param *ev_param;
18794 uint32_t num_bufp;
18795 uint32_t copy_size;
18796 uint8_t *bufp;
18797
18798 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18799 ev_param = param_buf->fixed_param;
18800 bufp = param_buf->bufp;
18801 num_bufp = param_buf->num_bufp;
18802 unit_test->vdev_id = ev_param->vdev_id;
18803 unit_test->module_id = ev_param->module_id;
18804 unit_test->diag_token = ev_param->diag_token;
18805 unit_test->flag = ev_param->flag;
18806 unit_test->payload_len = ev_param->payload_len;
18807 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18808 ev_param->vdev_id,
18809 ev_param->module_id,
18810 ev_param->diag_token,
18811 ev_param->flag);
18812 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18813 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18814 bufp, num_bufp);
18815 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18816 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18817 unit_test->buffer_len = copy_size;
18818
18819 return QDF_STATUS_SUCCESS;
18820}
18821
18822/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018823 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18824 * @wmi_handle: wmi handle
18825 * @param evt_buf: pointer to event buffer
18826 * @param index: Index into extended pdev stats
18827 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18828 *
18829 * Return: QDF_STATUS_SUCCESS for success or error code
18830 */
18831static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18832 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18833{
18834 return QDF_STATUS_SUCCESS;
18835}
18836
18837/**
18838 * extract_vdev_stats_tlv() - extract vdev stats from event
18839 * @wmi_handle: wmi handle
18840 * @param evt_buf: pointer to event buffer
18841 * @param index: Index into vdev stats
18842 * @param vdev_stats: Pointer to hold vdev stats
18843 *
18844 * Return: QDF_STATUS_SUCCESS for success or error code
18845 */
18846static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18847 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18848{
18849 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18850 wmi_stats_event_fixed_param *ev_param;
18851 uint8_t *data;
18852
18853 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18854 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18855 data = (uint8_t *) param_buf->data;
18856
18857 if (index < ev_param->num_vdev_stats) {
18858 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18859 ((ev_param->num_pdev_stats) *
18860 sizeof(wmi_pdev_stats)) +
18861 (index * sizeof(wmi_vdev_stats)));
18862
18863 vdev_stats->vdev_id = ev->vdev_id;
18864 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18865 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18866
18867 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18868 sizeof(ev->tx_frm_cnt));
18869 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18870 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18871 ev->multiple_retry_cnt,
18872 sizeof(ev->multiple_retry_cnt));
18873 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18874 sizeof(ev->fail_cnt));
18875 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18876 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18877 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18878 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18879 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18880 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18881 sizeof(ev->tx_rate_history));
18882 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18883 sizeof(ev->bcn_rssi_history));
18884
18885 }
18886
18887 return QDF_STATUS_SUCCESS;
18888}
18889
18890/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018891 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18892 * buffer
18893 * @wmi_handle: wmi handle
18894 * @evt_buf: pointer to event buffer
18895 * @index: Index into vdev stats
18896 * @rssi_stats: Pointer to hold rssi stats
18897 *
18898 * Return: QDF_STATUS_SUCCESS for success or error code
18899 */
18900static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18901 void *evt_buf, uint32_t index,
18902 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18903{
18904 uint8_t *data;
18905 wmi_rssi_stats *fw_rssi_stats;
18906 wmi_per_chain_rssi_stats *rssi_event;
18907 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18908
18909 if (!evt_buf) {
18910 WMI_LOGE("evt_buf is null");
18911 return QDF_STATUS_E_NULL_VALUE;
18912 }
18913
18914 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18915 rssi_event = param_buf->chain_stats;
18916
18917 if (index >= rssi_event->num_per_chain_rssi_stats) {
18918 WMI_LOGE("invalid index");
18919 return QDF_STATUS_E_INVAL;
18920 }
18921
18922 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18923 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18924
18925 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18926 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18927 fw_rssi_stats->rssi_avg_beacon,
18928 sizeof(fw_rssi_stats->rssi_avg_beacon));
18929 qdf_mem_copy(rssi_stats->rssi_avg_data,
18930 fw_rssi_stats->rssi_avg_data,
18931 sizeof(fw_rssi_stats->rssi_avg_data));
18932 qdf_mem_copy(&rssi_stats->peer_macaddr,
18933 &fw_rssi_stats->peer_macaddr,
18934 sizeof(fw_rssi_stats->peer_macaddr));
18935
18936 return QDF_STATUS_SUCCESS;
18937}
18938
18939
18940
18941/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018942 * extract_bcn_stats_tlv() - extract bcn stats from event
18943 * @wmi_handle: wmi handle
18944 * @param evt_buf: pointer to event buffer
18945 * @param index: Index into vdev stats
18946 * @param bcn_stats: Pointer to hold bcn stats
18947 *
18948 * Return: QDF_STATUS_SUCCESS for success or error code
18949 */
18950static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18951 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18952{
18953 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18954 wmi_stats_event_fixed_param *ev_param;
18955 uint8_t *data;
18956
18957 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18958 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18959 data = (uint8_t *) param_buf->data;
18960
18961 if (index < ev_param->num_bcn_stats) {
18962 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18963 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18964 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18965 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18966 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18967 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18968 (index * sizeof(wmi_bcn_stats)));
18969
18970 bcn_stats->vdev_id = ev->vdev_id;
18971 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18972 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18973 }
18974
18975 return QDF_STATUS_SUCCESS;
18976}
18977
18978/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018979 * extract_peer_stats_tlv() - extract peer stats from event
18980 * @wmi_handle: wmi handle
18981 * @param evt_buf: pointer to event buffer
18982 * @param index: Index into peer stats
18983 * @param peer_stats: Pointer to hold peer stats
18984 *
18985 * Return: QDF_STATUS_SUCCESS for success or error code
18986 */
18987static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
18988 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
18989{
18990 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18991 wmi_stats_event_fixed_param *ev_param;
18992 uint8_t *data;
18993
18994 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18995 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18996 data = (uint8_t *) param_buf->data;
18997
18998 if (index < ev_param->num_peer_stats) {
18999 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19000 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19001 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19002 (index * sizeof(wmi_peer_stats)));
19003
19004 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19005
19006 OS_MEMCPY(&(peer_stats->peer_macaddr),
19007 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19008
19009 peer_stats->peer_rssi = ev->peer_rssi;
19010 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19011 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19012 }
19013
19014 return QDF_STATUS_SUCCESS;
19015}
19016
19017/**
19018 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19019 * @wmi_handle: wmi handle
19020 * @param evt_buf: pointer to event buffer
19021 * @param index: Index into bcn fault stats
19022 * @param bcnflt_stats: Pointer to hold bcn fault stats
19023 *
19024 * Return: QDF_STATUS_SUCCESS for success or error code
19025 */
19026static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19027 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19028{
19029 return QDF_STATUS_SUCCESS;
19030}
19031
19032/**
19033 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19034 * @wmi_handle: wmi handle
19035 * @param evt_buf: pointer to event buffer
19036 * @param index: Index into extended peer stats
19037 * @param peer_extd_stats: Pointer to hold extended peer stats
19038 *
19039 * Return: QDF_STATUS_SUCCESS for success or error code
19040 */
19041static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19042 void *evt_buf, uint32_t index,
19043 wmi_host_peer_extd_stats *peer_extd_stats)
19044{
19045 return QDF_STATUS_SUCCESS;
19046}
19047
19048/**
19049 * extract_chan_stats_tlv() - extract chan stats from event
19050 * @wmi_handle: wmi handle
19051 * @param evt_buf: pointer to event buffer
19052 * @param index: Index into chan stats
19053 * @param vdev_extd_stats: Pointer to hold chan stats
19054 *
19055 * Return: QDF_STATUS_SUCCESS for success or error code
19056 */
19057static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19058 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19059{
19060 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19061 wmi_stats_event_fixed_param *ev_param;
19062 uint8_t *data;
19063
19064 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19065 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19066 data = (uint8_t *) param_buf->data;
19067
19068 if (index < ev_param->num_chan_stats) {
19069 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19070 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19071 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19072 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19073 (index * sizeof(wmi_chan_stats)));
19074
19075
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019076 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019077 chan_stats->chan_mhz = ev->chan_mhz;
19078 chan_stats->sampling_period_us = ev->sampling_period_us;
19079 chan_stats->rx_clear_count = ev->rx_clear_count;
19080 chan_stats->tx_duration_us = ev->tx_duration_us;
19081 chan_stats->rx_duration_us = ev->rx_duration_us;
19082 }
19083
19084 return QDF_STATUS_SUCCESS;
19085}
19086
19087/**
19088 * extract_profile_ctx_tlv() - extract profile context from event
19089 * @wmi_handle: wmi handle
19090 * @param evt_buf: pointer to event buffer
19091 * @idx: profile stats index to extract
19092 * @param profile_ctx: Pointer to hold profile context
19093 *
19094 * Return: QDF_STATUS_SUCCESS for success or error code
19095 */
19096static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19097 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19098{
19099 return QDF_STATUS_SUCCESS;
19100}
19101
19102/**
19103 * extract_profile_data_tlv() - extract profile data from event
19104 * @wmi_handle: wmi handle
19105 * @param evt_buf: pointer to event buffer
19106 * @param profile_data: Pointer to hold profile data
19107 *
19108 * Return: QDF_STATUS_SUCCESS for success or error code
19109 */
19110static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19111 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19112{
19113
19114 return QDF_STATUS_SUCCESS;
19115}
19116
19117/**
19118 * extract_chan_info_event_tlv() - extract chan information from event
19119 * @wmi_handle: wmi handle
19120 * @param evt_buf: pointer to event buffer
19121 * @param chan_info: Pointer to hold chan information
19122 *
19123 * Return: QDF_STATUS_SUCCESS for success or error code
19124 */
19125static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19126 void *evt_buf, wmi_host_chan_info_event *chan_info)
19127{
19128 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19129 wmi_chan_info_event_fixed_param *ev;
19130
19131 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19132
19133 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19134 if (!ev) {
19135 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19136 return QDF_STATUS_E_FAILURE;
19137 }
19138
19139 chan_info->err_code = ev->err_code;
19140 chan_info->freq = ev->freq;
19141 chan_info->cmd_flags = ev->cmd_flags;
19142 chan_info->noise_floor = ev->noise_floor;
19143 chan_info->rx_clear_count = ev->rx_clear_count;
19144 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019145 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19146 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019147 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19148 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19149 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019150 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19151 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19152 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19153 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19154 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19155 chan_info->rx_frame_count = ev->rx_frame_count;
19156 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19157 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019158
19159 return QDF_STATUS_SUCCESS;
19160}
19161
19162/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019163 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19164 * @wmi_handle: WMI handle
19165 * @param evt_buf: Pointer to event buffer
19166 * @param param: Pointer to hold data
19167 *
19168 * Return : QDF_STATUS_SUCCESS for success or error code
19169 */
19170static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19171 uint8_t *evt_buf,
19172 struct wmi_host_pdev_utf_event *event)
19173{
19174 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019175 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019176
19177 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19178 event->data = param_buf->data;
19179 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019180 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019181 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019182 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019183 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019184
19185 return QDF_STATUS_SUCCESS;
19186}
Govind Singhe7f2f342016-05-23 12:12:52 +053019187
Kiran Venkatappa06520822016-08-10 23:55:40 +053019188/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019189 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19190 * @wmi_handle: wmi handle
19191 * @param evt_buf: pointer to event buffer
19192 * @param param: Pointer to hold evt buf
19193 *
19194 * Return: QDF_STATUS_SUCCESS for success or error code
19195 */
19196static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19197 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19198{
19199 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19200 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19201 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19202 uint8_t i = 0, j = 0;
19203
19204 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19205 if (!param_buf)
19206 return QDF_STATUS_E_INVAL;
19207
19208 hw_caps = param_buf->soc_hw_mode_caps;
19209 if (!hw_caps)
19210 return QDF_STATUS_E_INVAL;
19211
19212 if (!hw_caps->num_chainmask_tables)
19213 return QDF_STATUS_E_INVAL;
19214
19215 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19216
19217 if (chainmask_caps == NULL)
19218 return QDF_STATUS_E_INVAL;
19219
19220 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19221
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019222 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019223 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19224
19225 chainmask_table[i].cap_list[j].chainmask =
19226 chainmask_caps->chainmask;
19227
19228 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19229 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19230
19231 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19232 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19233
19234 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19235 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19236
19237 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19238 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19239
19240 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19241 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19242
19243 chainmask_table[i].cap_list[j].chain_mask_2G =
19244 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19245
19246 chainmask_table[i].cap_list[j].chain_mask_5G =
19247 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19248
19249 chainmask_table[i].cap_list[j].chain_mask_tx =
19250 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19251
19252 chainmask_table[i].cap_list[j].chain_mask_rx =
19253 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19254
19255 chainmask_table[i].cap_list[j].supports_aDFS =
19256 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19257
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019258 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
19259 chainmask_caps->supported_flags,
19260 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019261 );
19262 chainmask_caps++;
19263 }
19264 }
19265
19266 return QDF_STATUS_SUCCESS;
19267}
19268
19269/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019270 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19271 * from event
19272 * @wmi_handle: wmi handle
19273 * @param evt_buf: pointer to event buffer
19274 * @param param: Pointer to hold evt buf
19275 *
19276 * Return: QDF_STATUS_SUCCESS for success or error code
19277 */
19278static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019279 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019280{
19281 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19282 wmi_service_ready_ext_event_fixed_param *ev;
19283 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19284 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019285 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19286 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019287
19288 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19289 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019290 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019291
19292 ev = param_buf->fixed_param;
19293 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019294 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019295
19296 /* Move this to host based bitmap */
19297 param->default_conc_scan_config_bits =
19298 ev->default_conc_scan_config_bits;
19299 param->default_fw_config_bits = ev->default_fw_config_bits;
19300 param->he_cap_info = ev->he_cap_info;
19301 param->mpdu_density = ev->mpdu_density;
19302 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019303 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019304 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019305 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19306
19307 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019308 if (hw_caps)
19309 param->num_hw_modes = hw_caps->num_hw_modes;
19310 else
19311 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019312
19313 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019314 if (reg_caps)
19315 param->num_phy = reg_caps->num_phy;
19316 else
19317 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019318
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019319 if (hw_caps) {
19320 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019321 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019322 } else
19323 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019324
19325 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19326
19327 if (chain_mask_combo == NULL)
19328 return QDF_STATUS_SUCCESS;
19329
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019330 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019331
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019332 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019333
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019334 qdf_print("table_id : %d Num valid chainmasks: %d",
19335 chain_mask_combo->chainmask_table_id,
19336 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019337 );
19338
19339 param->chainmask_table[i].table_id =
19340 chain_mask_combo->chainmask_table_id;
19341 param->chainmask_table[i].num_valid_chainmasks =
19342 chain_mask_combo->num_valid_chainmask;
19343 chain_mask_combo++;
19344 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019345 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019346
Kiran Venkatappa06520822016-08-10 23:55:40 +053019347 return QDF_STATUS_SUCCESS;
19348}
19349
19350/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019351 * extract_sar_cap_service_ready_ext_tlv() -
19352 * extract SAR cap from service ready event
19353 * @wmi_handle: wmi handle
19354 * @event: pointer to event buffer
19355 * @ext_param: extended target info
19356 *
19357 * Return: QDF_STATUS_SUCCESS for success or error code
19358 */
19359static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19360 wmi_unified_t wmi_handle,
19361 uint8_t *event,
19362 struct wlan_psoc_host_service_ext_param *ext_param)
19363{
19364 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19365 WMI_SAR_CAPABILITIES *sar_caps;
19366
19367 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19368
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019369 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019370 return QDF_STATUS_E_INVAL;
19371
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019372 sar_caps = param_buf->sar_caps;
19373 if (sar_caps)
19374 ext_param->sar_version = sar_caps->active_version;
19375 else
19376 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019377
19378 return QDF_STATUS_SUCCESS;
19379}
19380
19381/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019382 * extract_hw_mode_cap_service_ready_ext_tlv() -
19383 * extract HW mode cap from service ready event
19384 * @wmi_handle: wmi handle
19385 * @param evt_buf: pointer to event buffer
19386 * @param param: Pointer to hold evt buf
19387 * @param hw_mode_idx: hw mode idx should be less than num_mode
19388 *
19389 * Return: QDF_STATUS_SUCCESS for success or error code
19390 */
19391static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19392 wmi_unified_t wmi_handle,
19393 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019394 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019395{
19396 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19397 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19398
19399 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19400 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019401 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019402
19403 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019404 if (!hw_caps)
19405 return QDF_STATUS_E_INVAL;
19406
Kiran Venkatappa06520822016-08-10 23:55:40 +053019407 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019408 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019409
19410 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19411 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19412
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019413 param->hw_mode_config_type =
19414 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19415
Kiran Venkatappa06520822016-08-10 23:55:40 +053019416 return QDF_STATUS_SUCCESS;
19417}
19418
19419/**
19420 * extract_mac_phy_cap_service_ready_ext_tlv() -
19421 * extract MAC phy cap from service ready event
19422 * @wmi_handle: wmi handle
19423 * @param evt_buf: pointer to event buffer
19424 * @param param: Pointer to hold evt buf
19425 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019426 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019427 *
19428 * Return: QDF_STATUS_SUCCESS for success or error code
19429 */
19430static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19431 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019432 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019433 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019434{
19435 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019436 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019437 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19438 uint32_t phy_map;
19439 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019440
19441 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19442 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019443 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019444
19445 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019446 if (!hw_caps)
19447 return QDF_STATUS_E_INVAL;
19448
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019449 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19450 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19451 break;
19452
19453 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19454 while (phy_map) {
19455 phy_map >>= 1;
19456 phy_idx++;
19457 }
19458 }
19459
19460 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019461 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019462
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019463 phy_idx += phy_id;
19464 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019465 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019466
19467 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019468
19469 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019470 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19471 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019472 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019473 param->supports_11b =
19474 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19475 param->supports_11g =
19476 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19477 param->supports_11a =
19478 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19479 param->supports_11n =
19480 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19481 param->supports_11ac =
19482 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19483 param->supports_11ax =
19484 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019485
19486 param->supported_bands = mac_phy_caps->supported_bands;
19487 param->ampdu_density = mac_phy_caps->ampdu_density;
19488 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19489 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19490 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19491 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19492 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19493 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19494 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19495 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19496 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19497 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19498 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19499 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19500 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19501 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19502 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19503 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019504 qdf_mem_copy(&param->he_cap_phy_info_2G,
19505 &mac_phy_caps->he_cap_phy_info_2G,
19506 sizeof(param->he_cap_phy_info_2G));
19507 qdf_mem_copy(&param->he_cap_phy_info_5G,
19508 &mac_phy_caps->he_cap_phy_info_5G,
19509 sizeof(param->he_cap_phy_info_5G));
19510 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19511 sizeof(param->he_ppet2G));
19512 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19513 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019514 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019515
19516 return QDF_STATUS_SUCCESS;
19517}
19518
19519/**
19520 * extract_reg_cap_service_ready_ext_tlv() -
19521 * extract REG cap from service ready event
19522 * @wmi_handle: wmi handle
19523 * @param evt_buf: pointer to event buffer
19524 * @param param: Pointer to hold evt buf
19525 * @param phy_idx: phy idx should be less than num_mode
19526 *
19527 * Return: QDF_STATUS_SUCCESS for success or error code
19528 */
19529static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19530 wmi_unified_t wmi_handle,
19531 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019532 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019533{
19534 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19535 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19536 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19537
19538 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19539 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019540 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019541
19542 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019543 if (!reg_caps)
19544 return QDF_STATUS_E_INVAL;
19545
Kiran Venkatappa06520822016-08-10 23:55:40 +053019546 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019547 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019548
19549 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19550
19551 param->phy_id = ext_reg_cap->phy_id;
19552 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19553 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19554 param->regcap1 = ext_reg_cap->regcap1;
19555 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019556 param->wireless_modes = convert_wireless_modes_tlv(
19557 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019558 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19559 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19560 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19561 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19562
19563 return QDF_STATUS_SUCCESS;
19564}
19565
Sathish Kumarf396c722017-11-17 17:30:41 +053019566static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19567 wmi_unified_t wmi_handle,
19568 uint8_t *event, uint8_t idx,
19569 struct wlan_psoc_host_dbr_ring_caps *param)
19570{
19571 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19572 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19573
19574 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19575 if (!param_buf)
19576 return QDF_STATUS_E_INVAL;
19577
19578 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19579
19580 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19581 dbr_ring_caps->pdev_id);
19582 param->mod_id = dbr_ring_caps->mod_id;
19583 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19584 param->min_buf_size = dbr_ring_caps->min_buf_size;
19585 param->min_buf_align = dbr_ring_caps->min_buf_align;
19586
19587 return QDF_STATUS_SUCCESS;
19588}
19589
19590static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19591 uint8_t *event, struct direct_buf_rx_rsp *param)
19592{
19593 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19594 wmi_dma_buf_release_fixed_param *ev;
19595
19596 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19597 if (!param_buf)
19598 return QDF_STATUS_E_INVAL;
19599
19600 ev = param_buf->fixed_param;
19601 if (!ev)
19602 return QDF_STATUS_E_INVAL;
19603
19604 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19605 ev->pdev_id);
19606 param->mod_id = ev->mod_id;
19607 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019608 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019609 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19610 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19611
19612 return QDF_STATUS_SUCCESS;
19613}
19614
19615static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19616 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19617{
19618 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19619 wmi_dma_buf_release_entry *entry;
19620
19621 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19622 if (!param_buf)
19623 return QDF_STATUS_E_INVAL;
19624
19625 entry = &param_buf->entries[idx];
19626
19627 if (!entry) {
19628 WMI_LOGE("%s: Entry is NULL\n", __func__);
19629 return QDF_STATUS_E_FAILURE;
19630 }
19631
19632 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19633
19634 param->paddr_lo = entry->paddr_lo;
19635 param->paddr_hi = entry->paddr_hi;
19636
19637 return QDF_STATUS_SUCCESS;
19638}
19639
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019640static QDF_STATUS extract_dbr_buf_metadata_tlv(
19641 wmi_unified_t wmi_handle, uint8_t *event,
19642 uint8_t idx, struct direct_buf_rx_metadata *param)
19643{
19644 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19645 wmi_dma_buf_release_spectral_meta_data *entry;
19646
19647 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19648 if (!param_buf)
19649 return QDF_STATUS_E_INVAL;
19650
19651 entry = &param_buf->meta_data[idx];
19652
19653 if (!entry) {
19654 WMI_LOGE("%s: Entry is NULL\n", __func__);
19655 return QDF_STATUS_E_FAILURE;
19656 }
19657
19658 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19659 sizeof(entry->noise_floor));
19660 return QDF_STATUS_SUCCESS;
19661}
19662
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019663/**
19664 * extract_dcs_interference_type_tlv() - extract dcs interference type
19665 * from event
19666 * @wmi_handle: wmi handle
19667 * @param evt_buf: pointer to event buffer
19668 * @param param: Pointer to hold dcs interference param
19669 *
19670 * Return: 0 for success or error code
19671 */
19672static QDF_STATUS extract_dcs_interference_type_tlv(
19673 wmi_unified_t wmi_handle,
19674 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19675{
19676 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19677
19678 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19679 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019680 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019681
19682 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019683 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19684 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019685
19686 return QDF_STATUS_SUCCESS;
19687}
19688
19689/*
19690 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19691 * @wmi_handle: wmi handle
19692 * @param evt_buf: pointer to event buffer
19693 * @param cw_int: Pointer to hold cw interference
19694 *
19695 * Return: 0 for success or error code
19696 */
19697static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19698 void *evt_buf,
19699 wmi_host_ath_dcs_cw_int *cw_int)
19700{
19701 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19702 wlan_dcs_cw_int *ev;
19703
19704 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19705 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019706 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019707
19708 ev = param_buf->cw_int;
19709
19710 cw_int->channel = ev->channel;
19711
19712 return QDF_STATUS_SUCCESS;
19713}
19714
19715/**
19716 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19717 * @wmi_handle: wmi handle
19718 * @param evt_buf: pointer to event buffer
19719 * @param wlan_stat: Pointer to hold wlan stats
19720 *
19721 * Return: 0 for success or error code
19722 */
19723static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19724 void *evt_buf,
19725 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19726{
19727 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19728 wlan_dcs_im_tgt_stats_t *ev;
19729
19730 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19731 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019732 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019733
19734 ev = param_buf->wlan_stat;
19735 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19736 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19737 wlan_stat->tx_waste_time = ev->tx_waste_time;
19738 wlan_stat->rx_time = ev->rx_time;
19739 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19740 wlan_stat->mib_stats.listen_time = ev->listen_time;
19741 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19742 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19743 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19744 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19745 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19746 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19747 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19748 wlan_stat->chan_nf = ev->chan_nf;
19749 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19750
19751 return QDF_STATUS_SUCCESS;
19752}
19753
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019754/**
19755 * extract_thermal_stats_tlv() - extract thermal stats from event
19756 * @wmi_handle: wmi handle
19757 * @param evt_buf: Pointer to event buffer
19758 * @param temp: Pointer to hold extracted temperature
19759 * @param level: Pointer to hold extracted level
19760 *
19761 * Return: 0 for success or error code
19762 */
19763static QDF_STATUS
19764extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19765 void *evt_buf, uint32_t *temp,
19766 uint32_t *level, uint32_t *pdev_id)
19767{
19768 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19769 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19770
19771 param_buf =
19772 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19773 if (!param_buf)
19774 return QDF_STATUS_E_INVAL;
19775
19776 tt_stats_event = param_buf->fixed_param;
19777
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019778 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19779 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019780 *temp = tt_stats_event->temp;
19781 *level = tt_stats_event->level;
19782
19783 return QDF_STATUS_SUCCESS;
19784}
19785
19786/**
19787 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19788 * @wmi_handle: wmi handle
19789 * @param evt_buf: pointer to event buffer
19790 * @param idx: Index to level stats
19791 * @param levelcount: Pointer to hold levelcount
19792 * @param dccount: Pointer to hold dccount
19793 *
19794 * Return: 0 for success or error code
19795 */
19796static QDF_STATUS
19797extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19798 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19799 uint32_t *dccount)
19800{
19801 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19802 wmi_therm_throt_level_stats_info *tt_level_info;
19803
19804 param_buf =
19805 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19806 if (!param_buf)
19807 return QDF_STATUS_E_INVAL;
19808
19809 tt_level_info = param_buf->therm_throt_level_stats_info;
19810
19811 if (idx < THERMAL_LEVELS) {
19812 *levelcount = tt_level_info[idx].level_count;
19813 *dccount = tt_level_info[idx].dc_count;
19814 return QDF_STATUS_SUCCESS;
19815 }
19816
19817 return QDF_STATUS_E_FAILURE;
19818}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019819#ifdef BIG_ENDIAN_HOST
19820/**
19821 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19822 * @param data_len - data length
19823 * @param data - pointer to data
19824 *
19825 * Return: QDF_STATUS - success or error status
19826 */
19827static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19828{
19829 uint8_t *data_aligned = NULL;
19830 int c;
19831 unsigned char *data_unaligned;
19832
19833 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19834 FIPS_ALIGN));
19835 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019836 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019837 if (data_unaligned == NULL)
19838 return QDF_STATUS_E_FAILURE;
19839
19840 /* Checking if space is alligned */
19841 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19842 /* align the data space */
19843 data_aligned =
19844 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19845 } else {
19846 data_aligned = (u_int8_t *)data_unaligned;
19847 }
19848
19849 /* memset and copy content from data to data aligned */
19850 OS_MEMSET(data_aligned, 0, data_len);
19851 OS_MEMCPY(data_aligned, data, data_len);
19852 /* Endianness to LE */
19853 for (c = 0; c < data_len/4; c++) {
19854 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019855 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019856 }
19857
19858 /* Copy content to event->data */
19859 OS_MEMCPY(data, data_aligned, data_len);
19860
19861 /* clean up allocated space */
19862 qdf_mem_free(data_unaligned);
19863 data_aligned = NULL;
19864 data_unaligned = NULL;
19865
19866 /*************************************************************/
19867
19868 return QDF_STATUS_SUCCESS;
19869}
19870#else
19871/**
19872 * fips_conv_data_be() - DUMMY for LE platform
19873 *
19874 * Return: QDF_STATUS - success
19875 */
19876static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19877{
19878 return QDF_STATUS_SUCCESS;
19879}
19880#endif
19881
19882/**
19883 * extract_fips_event_data_tlv() - extract fips event data
19884 * @wmi_handle: wmi handle
19885 * @param evt_buf: pointer to event buffer
19886 * @param param: pointer FIPS event params
19887 *
19888 * Return: 0 for success or error code
19889 */
19890static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19891 void *evt_buf, struct wmi_host_fips_event_param *param)
19892{
19893 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19894 wmi_pdev_fips_event_fixed_param *event;
19895
19896 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19897 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19898
19899 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19900 QDF_STATUS_SUCCESS)
19901 return QDF_STATUS_E_FAILURE;
19902
19903 param->data = (uint32_t *)param_buf->data;
19904 param->data_len = event->data_len;
19905 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019906 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19907 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019908
19909 return QDF_STATUS_SUCCESS;
19910}
19911
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019912/*
19913 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19914 * @wmi_handle: wmi handle
19915 * @param evt_buf: pointer to event buffer
19916 * @param vdev_id: Pointer to hold vdev_id
19917 * @param mac_addr: Pointer to hold peer mac address
19918 *
19919 * Return: QDF_STATUS_SUCCESS for success or error code
19920 */
19921static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19922 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19923{
19924 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19925 wmi_peer_delete_resp_event_fixed_param *ev;
19926
19927 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19928
19929 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19930 if (!ev) {
19931 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19932 return QDF_STATUS_E_FAILURE;
19933 }
19934
19935 param->vdev_id = ev->vdev_id;
19936 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19937 &param->mac_address.bytes[0]);
19938
19939 return QDF_STATUS_SUCCESS;
19940}
19941
Govind Singhecf03cd2016-05-12 12:45:51 +053019942static bool is_management_record_tlv(uint32_t cmd_id)
19943{
jiad36c94d22018-01-22 15:37:03 +080019944 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19945 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19946 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019947 return true;
jiad36c94d22018-01-22 15:37:03 +080019948 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019949
Govind Singhecf03cd2016-05-12 12:45:51 +053019950 return false;
19951}
19952
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019953static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19954{
19955 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19956
19957 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19958
19959 switch (set_cmd->param_id) {
19960 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19961 case WMI_VDEV_PARAM_DTIM_POLICY:
19962 return HTC_TX_PACKET_TAG_AUTO_PM;
19963 default:
19964 break;
19965 }
19966
19967 return 0;
19968}
19969
19970static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19971{
19972 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19973
19974 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19975
19976 switch (ps_cmd->param) {
19977 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19978 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19979 case WMI_STA_PS_ENABLE_QPOWER:
19980 return HTC_TX_PACKET_TAG_AUTO_PM;
19981 default:
19982 break;
19983 }
19984
19985 return 0;
19986}
19987
19988static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
19989 uint32_t cmd_id)
19990{
19991 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
19992 return 0;
19993
19994 switch (cmd_id) {
19995 case WMI_VDEV_SET_PARAM_CMDID:
19996 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
19997 case WMI_STA_POWERSAVE_PARAM_CMDID:
19998 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
19999 default:
20000 break;
20001 }
20002
20003 return 0;
20004}
20005
20006static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20007{
20008 uint16_t tag = 0;
20009
20010 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20011 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20012 __func__);
20013 return tag;
20014 }
20015
20016 if (wmi_handle->tag_crash_inject)
20017 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20018
20019 wmi_handle->tag_crash_inject = false;
20020 return tag;
20021}
20022
20023/**
20024 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20025 * @wmi_handle: WMI handle
20026 * @buf: WMI buffer
20027 * @cmd_id: WMI command Id
20028 *
20029 * Return htc_tx_tag
20030 */
20031static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20032 wmi_buf_t buf,
20033 uint32_t cmd_id)
20034{
20035 uint16_t htc_tx_tag = 0;
20036
20037 switch (cmd_id) {
20038 case WMI_WOW_ENABLE_CMDID:
20039 case WMI_PDEV_SUSPEND_CMDID:
20040 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20041 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20042 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20043 case WMI_PDEV_RESUME_CMDID:
20044 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20045 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20046#ifdef FEATURE_WLAN_D0WOW
20047 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20048#endif
20049 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20050 break;
20051 case WMI_FORCE_FW_HANG_CMDID:
20052 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20053 break;
20054 case WMI_VDEV_SET_PARAM_CMDID:
20055 case WMI_STA_POWERSAVE_PARAM_CMDID:
20056 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20057 default:
20058 break;
20059 }
20060
20061 return htc_tx_tag;
20062}
20063
Sathish Kumard3ab1002017-02-07 17:10:59 +053020064/**
20065 * extract_channel_hopping_event_tlv() - extract channel hopping param
20066 * from event
20067 * @wmi_handle: wmi handle
20068 * @param evt_buf: pointer to event buffer
20069 * @param ch_hopping: Pointer to hold channel hopping param
20070 *
20071 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20072 */
20073static QDF_STATUS extract_channel_hopping_event_tlv(
20074 wmi_unified_t wmi_handle, void *evt_buf,
20075 wmi_host_pdev_channel_hopping_event *ch_hopping)
20076{
20077 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20078 wmi_pdev_channel_hopping_event_fixed_param *event;
20079
20080 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20081 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20082 param_buf->fixed_param;
20083
20084 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20085 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020086 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20087 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020088
20089 return QDF_STATUS_SUCCESS;
20090}
20091
20092/**
20093 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20094 * @wmi_handle: wmi handle
20095 * @param evt_buf: pointer to event buffer
20096 * @param param: Pointer to hold tpc param
20097 *
20098 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20099 */
20100static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20101 void *evt_buf,
20102 wmi_host_pdev_tpc_event *param)
20103{
20104 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20105 wmi_pdev_tpc_event_fixed_param *event;
20106
20107 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20108 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20109
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020110 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20111 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020112 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20113
20114 return QDF_STATUS_SUCCESS;
20115}
20116
nobeljf74583b2018-01-25 16:35:36 -080020117/**
20118 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20119 * power param from event
20120 * @wmi_handle: wmi handle
20121 * @param evt_buf: pointer to event buffer
20122 * @param param: Pointer to hold nf cal power param
20123 *
20124 * Return: 0 for success or error code
20125 */
20126static QDF_STATUS
20127extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20128 void *evt_buf,
20129 wmi_host_pdev_nfcal_power_all_channels_event *param)
20130{
20131 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20132 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20133 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20134 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20135 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20136 uint32_t i;
20137
20138 param_buf =
20139 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20140 event = param_buf->fixed_param;
20141 ch_nfdbr = param_buf->nfdbr;
20142 ch_nfdbm = param_buf->nfdbm;
20143 ch_freqnum = param_buf->freqnum;
20144
20145 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20146 event->pdev_id, param_buf->num_nfdbr,
20147 param_buf->num_nfdbm, param_buf->num_freqnum);
20148
20149 if (param_buf->num_nfdbr >
20150 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20151 WMI_LOGE("invalid number of nfdBr");
20152 return QDF_STATUS_E_FAILURE;
20153 }
20154
20155 if (param_buf->num_nfdbm >
20156 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20157 WMI_LOGE("invalid number of nfdBm");
20158 return QDF_STATUS_E_FAILURE;
20159 }
20160
20161 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20162 WMI_LOGE("invalid number of freqNum");
20163 return QDF_STATUS_E_FAILURE;
20164 }
20165
20166 for (i = 0; i < param_buf->num_nfdbr; i++) {
20167 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20168 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20169 ch_nfdbr++;
20170 ch_nfdbm++;
20171 }
20172
20173 for (i = 0; i < param_buf->num_freqnum; i++) {
20174 param->freqnum[i] = ch_freqnum->freqNum;
20175 ch_freqnum++;
20176 }
20177
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020178 param->pdev_id = wmi_handle->ops->
20179 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020180
20181 return QDF_STATUS_SUCCESS;
20182}
20183
Sathish Kumard3ab1002017-02-07 17:10:59 +053020184
20185#ifdef BIG_ENDIAN_HOST
20186/**
20187 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20188 * @param data_len - data length
20189 * @param data - pointer to data
20190 *
20191 * Return: QDF_STATUS - success or error status
20192 */
20193static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20194{
20195 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020196 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020197 /* Skip swapping the first word */
20198 datap += sizeof(uint32_t);
20199 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20200 i++, datap += sizeof(uint32_t)) {
20201 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20202 }
20203
20204 return QDF_STATUS_SUCCESS;
20205}
20206#else
20207/**
20208 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20209 * @param data_len - data length
20210 * @param data - pointer to data
20211 *
20212 * Return: QDF_STATUS - success or error status
20213 */
20214static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20215{
20216 return QDF_STATUS_SUCCESS;
20217}
20218#endif
20219
20220/**
20221 * extract_wds_addr_event_tlv() - extract wds address from event
20222 * @wmi_handle: wmi handle
20223 * @param evt_buf: pointer to event buffer
20224 * @param wds_ev: Pointer to hold wds address
20225 *
20226 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20227 */
20228static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20229 void *evt_buf,
20230 uint16_t len, wds_addr_event_t *wds_ev)
20231{
20232 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20233 wmi_wds_addr_event_fixed_param *ev;
20234 int i;
20235
20236 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20237 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20238
20239 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20240 return QDF_STATUS_E_FAILURE;
20241
20242 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20243 sizeof(wds_ev->event_type));
20244 for (i = 0; i < 4; i++) {
20245 wds_ev->peer_mac[i] =
20246 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20247 wds_ev->dest_mac[i] =
20248 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20249 }
20250 for (i = 0; i < 2; i++) {
20251 wds_ev->peer_mac[4+i] =
20252 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20253 wds_ev->dest_mac[4+i] =
20254 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20255 }
20256 return QDF_STATUS_SUCCESS;
20257}
20258
20259/**
20260 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20261 * from event
20262 * @wmi_handle: wmi handle
20263 * @param evt_buf: pointer to event buffer
20264 * @param ev: Pointer to hold peer param and ps state
20265 *
20266 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20267 */
20268static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20269 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20270{
20271 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20272 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20273
20274 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20275 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20276 param_buf->fixed_param;
20277
20278 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20279 ev->peer_ps_state = event->peer_ps_state;
20280
20281 return QDF_STATUS_SUCCESS;
20282}
20283
20284/**
20285 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20286 * @wmi_handle: wmi handle
20287 * @param evt_buf: pointer to event buffer
20288 * @param inst_rssi_resp: Pointer to hold inst rssi response
20289 *
20290 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20291 */
20292static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20293 wmi_unified_t wmi_handle, void *evt_buf,
20294 wmi_host_inst_stats_resp *inst_rssi_resp)
20295{
20296 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20297 wmi_inst_rssi_stats_resp_fixed_param *event;
20298
20299 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20300 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20301
20302 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20303 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20304 inst_rssi_resp->iRSSI = event->iRSSI;
20305
20306 return QDF_STATUS_SUCCESS;
20307}
20308
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020309static struct cur_reg_rule
20310*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20311 wmi_regulatory_rule_struct *wmi_reg_rule)
20312{
20313 struct cur_reg_rule *reg_rule_ptr;
20314 uint32_t count;
20315
20316 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20317
20318 if (NULL == reg_rule_ptr) {
20319 WMI_LOGE("memory allocation failure");
20320 return NULL;
20321 }
20322
20323 for (count = 0; count < num_reg_rules; count++) {
20324 reg_rule_ptr[count].start_freq =
20325 WMI_REG_RULE_START_FREQ_GET(
20326 wmi_reg_rule[count].freq_info);
20327 reg_rule_ptr[count].end_freq =
20328 WMI_REG_RULE_END_FREQ_GET(
20329 wmi_reg_rule[count].freq_info);
20330 reg_rule_ptr[count].max_bw =
20331 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020332 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020333 reg_rule_ptr[count].reg_power =
20334 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020335 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020336 reg_rule_ptr[count].ant_gain =
20337 WMI_REG_RULE_ANTENNA_GAIN_GET(
20338 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020339 reg_rule_ptr[count].flags =
20340 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020341 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020342 }
20343
20344 return reg_rule_ptr;
20345}
20346
20347static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20348 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20349 struct cur_regulatory_info *reg_info, uint32_t len)
20350{
20351 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20352 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20353 wmi_regulatory_rule_struct *wmi_reg_rule;
20354 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20355
20356 WMI_LOGD("processing regulatory channel list");
20357
20358 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20359 if (!param_buf) {
20360 WMI_LOGE("invalid channel list event buf");
20361 return QDF_STATUS_E_FAILURE;
20362 }
20363
20364 chan_list_event_hdr = param_buf->fixed_param;
20365
20366 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20367 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20368 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020369 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020370 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20371 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020372 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020373 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020374 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020375 reg_info->ctry_code = chan_list_event_hdr->country_id;
20376 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20377 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20378 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20379 else if (chan_list_event_hdr->status_code ==
20380 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20381 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20382 else if (chan_list_event_hdr->status_code ==
20383 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20384 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20385 else if (chan_list_event_hdr->status_code ==
20386 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20387 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20388 else if (chan_list_event_hdr->status_code ==
20389 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20390 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20391 else if (chan_list_event_hdr->status_code ==
20392 WMI_REG_SET_CC_STATUS_FAIL)
20393 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20394
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020395 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20396 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20397 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20398 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20399
20400 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20401 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20402
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020403 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20404 __func__, reg_info->alpha2, reg_info->dfs_region,
20405 reg_info->min_bw_2g, reg_info->max_bw_2g,
20406 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020407
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020408 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20409 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020410 wmi_reg_rule =
20411 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20412 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20413 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020414 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20415 wmi_reg_rule);
20416 wmi_reg_rule += num_2g_reg_rules;
20417
20418 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20419 wmi_reg_rule);
20420
20421 WMI_LOGD("processed regulatory channel list");
20422
20423 return QDF_STATUS_SUCCESS;
20424}
20425
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020426static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20427 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20428 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20429{
20430 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20431 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20432
20433 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20434 if (!param_buf) {
20435 WMI_LOGE("invalid 11d country event buf");
20436 return QDF_STATUS_E_FAILURE;
20437 }
20438
20439 reg_11d_country_event = param_buf->fixed_param;
20440
20441 qdf_mem_copy(reg_11d_country->alpha2,
20442 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20443
20444 WMI_LOGD("processed 11d country event, new cc %s",
20445 reg_11d_country->alpha2);
20446
20447 return QDF_STATUS_SUCCESS;
20448}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020449
20450static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20451 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20452 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20453{
20454 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20455 wmi_avoid_freq_range_desc *afr_desc;
20456 uint32_t num_freq_ranges, freq_range_idx;
20457 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20458 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20459
20460 if (!param_buf) {
20461 WMI_LOGE("Invalid channel avoid event buffer");
20462 return QDF_STATUS_E_INVAL;
20463 }
20464
20465 afr_fixed_param = param_buf->fixed_param;
20466 if (!afr_fixed_param) {
20467 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20468 return QDF_STATUS_E_INVAL;
20469 }
20470
20471 if (!ch_avoid_ind) {
20472 WMI_LOGE("Invalid channel avoid indication buffer");
20473 return QDF_STATUS_E_INVAL;
20474 }
20475 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20476 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20477 afr_fixed_param->num_freq_ranges;
20478
20479 WMI_LOGD("Channel avoid event received with %d ranges",
20480 num_freq_ranges);
20481
20482 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20483 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20484 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20485 freq_range_idx++) {
20486 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20487 afr_desc->start_freq;
20488 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20489 afr_desc->end_freq;
20490 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20491 freq_range_idx, afr_desc->tlv_header,
20492 afr_desc->start_freq, afr_desc->end_freq);
20493 afr_desc++;
20494 }
20495
20496 return QDF_STATUS_SUCCESS;
20497}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020498#ifdef DFS_COMPONENT_ENABLE
20499/**
20500 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20501 * @wmi_handle: wma handle
20502 * @evt_buf: event buffer
20503 * @vdev_id: vdev id
20504 * @len: length of buffer
20505 *
20506 * Return: 0 for success or error code
20507 */
20508static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20509 uint8_t *evt_buf,
20510 uint32_t *vdev_id,
20511 uint32_t len)
20512{
20513 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20514 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20515
20516 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20517 if (!param_tlvs) {
20518 WMI_LOGE("invalid cac complete event buf");
20519 return QDF_STATUS_E_FAILURE;
20520 }
20521
20522 cac_event = param_tlvs->fixed_param;
20523 *vdev_id = cac_event->vdev_id;
20524 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20525
20526 return QDF_STATUS_SUCCESS;
20527}
20528
20529/**
20530 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20531 * @wmi_handle: wma handle
20532 * @evt_buf: event buffer
20533 * @radar_found: radar found event info
20534 * @len: length of buffer
20535 *
20536 * Return: 0 for success or error code
20537 */
20538static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20539 wmi_unified_t wmi_handle,
20540 uint8_t *evt_buf,
20541 struct radar_found_info *radar_found,
20542 uint32_t len)
20543{
20544 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20545 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20546
20547 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20548 if (!param_tlv) {
20549 WMI_LOGE("invalid radar detection event buf");
20550 return QDF_STATUS_E_FAILURE;
20551 }
20552
20553 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020554 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20555 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020556 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020557 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020558 radar_found->chan_width = radar_event->chan_width;
20559 radar_found->detector_id = radar_event->detector_id;
20560 radar_found->segment_id = radar_event->segment_id;
20561 radar_found->timestamp = radar_event->timestamp;
20562 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020563 radar_found->freq_offset = radar_event->freq_offset;
20564 radar_found->sidx = radar_event->sidx;
20565
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020566 WMI_LOGI("processed radar found event pdev %d,"
20567 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20568 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20569 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20570 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020571 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020572 radar_event->timestamp, radar_event->chan_freq,
20573 radar_event->chan_width, radar_event->detector_id,
20574 radar_event->freq_offset, radar_event->segment_id,
20575 radar_event->sidx, radar_event->is_chirp,
20576 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020577
20578 return QDF_STATUS_SUCCESS;
20579}
bings1ea12532017-12-18 16:56:53 +080020580
20581#ifdef QCA_MCL_DFS_SUPPORT
20582/**
20583 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20584 * @wmi_handle: wma handle
20585 * @evt_buf: event buffer
20586 * @wlan_radar_event: Pointer to struct radar_event_info
20587 * @len: length of buffer
20588 *
20589 * Return: QDF_STATUS
20590 */
20591static QDF_STATUS extract_wlan_radar_event_info_tlv(
20592 wmi_unified_t wmi_handle,
20593 uint8_t *evt_buf,
20594 struct radar_event_info *wlan_radar_event,
20595 uint32_t len)
20596{
20597 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20598 wmi_dfs_radar_event_fixed_param *radar_event;
20599
20600 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20601 if (!param_tlv) {
20602 WMI_LOGE("invalid wlan radar event buf");
20603 return QDF_STATUS_E_FAILURE;
20604 }
20605
20606 radar_event = param_tlv->fixed_param;
20607 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20608 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20609 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20610 wlan_radar_event->rssi = radar_event->rssi;
20611 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20612 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20613 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20614 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020615 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20616 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020617 if (radar_event->pulse_flags &
20618 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20619 wlan_radar_event->is_psidx_diff_valid = true;
20620 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20621 } else {
20622 wlan_radar_event->is_psidx_diff_valid = false;
20623 }
20624
bings1ea12532017-12-18 16:56:53 +080020625 wlan_radar_event->pdev_id = radar_event->pdev_id;
20626
20627 return QDF_STATUS_SUCCESS;
20628}
20629#else
20630static QDF_STATUS extract_wlan_radar_event_info_tlv(
20631 wmi_unified_t wmi_handle,
20632 uint8_t *evt_buf,
20633 struct radar_event_info *wlan_radar_event,
20634 uint32_t len)
20635{
20636 return QDF_STATUS_SUCCESS;
20637}
20638#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020639#endif
20640
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020641/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020642 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20643 * @wmi_handle: wmi handle
20644 * @get_rcpi_param: rcpi params
20645 *
20646 * Return: QDF status
20647 */
20648static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20649 struct rcpi_req *get_rcpi_param)
20650{
20651 wmi_buf_t buf;
20652 wmi_request_rcpi_cmd_fixed_param *cmd;
20653 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20654
20655 buf = wmi_buf_alloc(wmi_handle, len);
20656 if (!buf) {
20657 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20658 return QDF_STATUS_E_NOMEM;
20659 }
20660
20661 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20662 WMITLV_SET_HDR(&cmd->tlv_header,
20663 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20664 WMITLV_GET_STRUCT_TLVLEN
20665 (wmi_request_rcpi_cmd_fixed_param));
20666
20667 cmd->vdev_id = get_rcpi_param->vdev_id;
20668 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20669 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020670
20671 switch (get_rcpi_param->measurement_type) {
20672
20673 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20674 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20675 break;
20676
20677 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20678 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20679 break;
20680
20681 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20682 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20683 break;
20684
20685 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20686 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20687 break;
20688
20689 default:
20690 /*
20691 * invalid rcpi measurement type, fall back to
20692 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20693 */
20694 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20695 break;
20696 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020697 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20698 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20699 WMI_REQUEST_RCPI_CMDID)) {
20700
20701 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20702 __func__);
20703 wmi_buf_free(buf);
20704 return QDF_STATUS_E_FAILURE;
20705 }
20706
20707 return QDF_STATUS_SUCCESS;
20708}
20709
20710/**
20711 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20712 * @wmi_handle: wmi handle
20713 * @evt_buf: pointer to event buffer
20714 * @res: pointer to hold rcpi response from firmware
20715 *
20716 * Return: QDF_STATUS_SUCCESS for successful event parse
20717 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20718 */
20719static QDF_STATUS
20720extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20721 void *evt_buf, struct rcpi_res *res)
20722{
20723 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20724 wmi_update_rcpi_event_fixed_param *event;
20725
20726 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20727 if (!param_buf) {
20728 WMI_LOGE(FL("Invalid rcpi event"));
20729 return QDF_STATUS_E_INVAL;
20730 }
20731
20732 event = param_buf->fixed_param;
20733 res->vdev_id = event->vdev_id;
20734 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20735
20736 switch (event->measurement_type) {
20737
20738 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20739 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20740 break;
20741
20742 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20743 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20744 break;
20745
20746 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20747 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20748 break;
20749
20750 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20751 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20752 break;
20753
20754 default:
20755 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20756 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20757 return QDF_STATUS_E_FAILURE;
20758 }
20759
20760 if (event->status)
20761 return QDF_STATUS_E_FAILURE;
20762 else
20763 return QDF_STATUS_SUCCESS;
20764}
20765
20766/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020767 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20768 * host to target defines. For legacy there is not conversion
20769 * required. Just return pdev_id as it is.
20770 * @param pdev_id: host pdev_id to be converted.
20771 * Return: target pdev_id after conversion.
20772 */
20773static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20774 uint32_t pdev_id)
20775{
20776 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20777 return WMI_PDEV_ID_SOC;
20778
20779 /*No conversion required*/
20780 return pdev_id;
20781}
20782
20783/**
20784 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20785 * target to host defines. For legacy there is not conversion
20786 * required. Just return pdev_id as it is.
20787 * @param pdev_id: target pdev_id to be converted.
20788 * Return: host pdev_id after conversion.
20789 */
20790static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20791 uint32_t pdev_id)
20792{
20793 /*No conversion required*/
20794 return pdev_id;
20795}
20796
20797/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020798 * send_set_country_cmd_tlv() - WMI scan channel list function
20799 * @param wmi_handle : handle to WMI.
20800 * @param param : pointer to hold scan channel list parameter
20801 *
20802 * Return: 0 on success and -ve on failure.
20803 */
20804static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20805 struct set_country *params)
20806{
20807 wmi_buf_t buf;
20808 QDF_STATUS qdf_status;
20809 wmi_set_current_country_cmd_fixed_param *cmd;
20810 uint16_t len = sizeof(*cmd);
20811
20812 buf = wmi_buf_alloc(wmi_handle, len);
20813 if (!buf) {
20814 WMI_LOGE("Failed to allocate memory");
20815 qdf_status = QDF_STATUS_E_NOMEM;
20816 goto end;
20817 }
20818
20819 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20820 WMITLV_SET_HDR(&cmd->tlv_header,
20821 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20822 WMITLV_GET_STRUCT_TLVLEN
20823 (wmi_set_current_country_cmd_fixed_param));
20824
20825 WMI_LOGD("setting cuurnet country to %s", params->country);
20826
20827 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20828
20829 cmd->pdev_id = params->pdev_id;
20830
20831 qdf_status = wmi_unified_cmd_send(wmi_handle,
20832 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20833
20834 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20835 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20836 wmi_buf_free(buf);
20837 }
20838
20839end:
20840 return qdf_status;
20841}
20842
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020843#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20844 WMI_SET_BITS(alpha, 0, 8, val0); \
20845 WMI_SET_BITS(alpha, 8, 8, val1); \
20846 WMI_SET_BITS(alpha, 16, 8, val2); \
20847 } while (0)
20848
20849static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20850 uint8_t pdev_id, struct cc_regdmn_s *rd)
20851{
20852 wmi_set_init_country_cmd_fixed_param *cmd;
20853 uint16_t len;
20854 wmi_buf_t buf;
20855 int ret;
20856
20857 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20858 buf = wmi_buf_alloc(wmi_handle, len);
20859 if (!buf) {
20860 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20861 return QDF_STATUS_E_NOMEM;
20862 }
20863 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20864 WMITLV_SET_HDR(&cmd->tlv_header,
20865 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20866 WMITLV_GET_STRUCT_TLVLEN
20867 (wmi_set_init_country_cmd_fixed_param));
20868
20869 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20870
20871 if (rd->flags == CC_IS_SET) {
20872 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20873 cmd->country_code.country_id = rd->cc.country_code;
20874 } else if (rd->flags == ALPHA_IS_SET) {
20875 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20876 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20877 rd->cc.alpha[0],
20878 rd->cc.alpha[1],
20879 rd->cc.alpha[2]);
20880 } else if (rd->flags == REGDMN_IS_SET) {
20881 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20882 cmd->country_code.domain_code = rd->cc.regdmn_id;
20883 }
20884
20885 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20886 WMI_SET_INIT_COUNTRY_CMDID);
20887 if (ret) {
20888 WMI_LOGE("Failed to config wow wakeup event");
20889 wmi_buf_free(buf);
20890 return QDF_STATUS_E_FAILURE;
20891 }
20892
20893 return QDF_STATUS_SUCCESS;
20894}
20895
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020896/**
20897 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20898 * configuration params
20899 * @wmi_handle: wmi handler
20900 * @limit_off_chan_param: pointer to wmi_off_chan_param
20901 *
20902 * Return: 0 for success and non zero for failure
20903 */
20904static
20905QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20906 struct wmi_limit_off_chan_param *limit_off_chan_param)
20907{
20908 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20909 wmi_buf_t buf;
20910 uint32_t len = sizeof(*cmd);
20911 int err;
20912
20913 buf = wmi_buf_alloc(wmi_handle, len);
20914 if (!buf) {
20915 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20916 __func__);
20917 return QDF_STATUS_E_NOMEM;
20918 }
20919
20920 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20921
20922 WMITLV_SET_HDR(&cmd->tlv_header,
20923 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20924 WMITLV_GET_STRUCT_TLVLEN(
20925 wmi_vdev_limit_offchan_cmd_fixed_param));
20926
20927 cmd->vdev_id = limit_off_chan_param->vdev_id;
20928
20929 cmd->flags &= 0;
20930 if (limit_off_chan_param->status)
20931 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20932 if (limit_off_chan_param->skip_dfs_chans)
20933 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20934
20935 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20936 cmd->rest_time = limit_off_chan_param->rest_time;
20937
20938 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20939 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20940 cmd->rest_time);
20941
20942 err = wmi_unified_cmd_send(wmi_handle, buf,
20943 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20944 if (QDF_IS_STATUS_ERROR(err)) {
20945 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20946 wmi_buf_free(buf);
20947 return QDF_STATUS_E_FAILURE;
20948 }
20949
20950 return QDF_STATUS_SUCCESS;
20951}
20952
Anurag Chouhan97f00422017-09-11 14:56:30 +053020953/**
20954 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20955 * @wmi_handle: wmi handler
20956 * @req_buf: set arp stats request buffer
20957 *
20958 * Return: 0 for success and non zero for failure
20959 */
20960static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20961 struct set_arp_stats *req_buf)
20962{
20963 wmi_buf_t buf = NULL;
20964 QDF_STATUS status;
20965 int len;
20966 uint8_t *buf_ptr;
20967 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20968
20969 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020970 if (req_buf->pkt_type_bitmap) {
20971 len += WMI_TLV_HDR_SIZE;
20972 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20973 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020974 buf = wmi_buf_alloc(wmi_handle, len);
20975 if (!buf) {
20976 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20977 return QDF_STATUS_E_NOMEM;
20978 }
20979
20980 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20981 wmi_set_arp =
20982 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20983 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20984 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20985 WMITLV_GET_STRUCT_TLVLEN
20986 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20987
20988 /* fill in per roam config values */
20989 wmi_set_arp->vdev_id = req_buf->vdev_id;
20990
20991 wmi_set_arp->set_clr = req_buf->flag;
20992 wmi_set_arp->pkt_type = req_buf->pkt_type;
20993 wmi_set_arp->ipv4 = req_buf->ip_addr;
20994
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020995 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
20996 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
20997 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
20998
20999 /*
21000 * pkt_type_bitmap should be non-zero to ensure
21001 * presence of additional stats.
21002 */
21003 if (req_buf->pkt_type_bitmap) {
21004 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21005
21006 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21007 WMITLV_SET_HDR(buf_ptr,
21008 WMITLV_TAG_ARRAY_STRUC,
21009 sizeof(wmi_vdev_set_connectivity_check_stats));
21010 buf_ptr += WMI_TLV_HDR_SIZE;
21011 wmi_set_connect_stats =
21012 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21013 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21014 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21015 WMITLV_GET_STRUCT_TLVLEN(
21016 wmi_vdev_set_connectivity_check_stats));
21017 wmi_set_connect_stats->pkt_type_bitmap =
21018 req_buf->pkt_type_bitmap;
21019 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21020 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21021 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21022
21023 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21024 wmi_set_connect_stats->pkt_type_bitmap,
21025 wmi_set_connect_stats->tcp_src_port,
21026 wmi_set_connect_stats->tcp_dst_port,
21027 wmi_set_connect_stats->icmp_ipv4);
21028 }
21029
Anurag Chouhan97f00422017-09-11 14:56:30 +053021030 /* Send per roam config parameters */
21031 status = wmi_unified_cmd_send(wmi_handle, buf,
21032 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21033 if (QDF_IS_STATUS_ERROR(status)) {
21034 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21035 status);
21036 goto error;
21037 }
21038
21039 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21040 req_buf->flag, req_buf->vdev_id);
21041 return QDF_STATUS_SUCCESS;
21042error:
21043 wmi_buf_free(buf);
21044
21045 return status;
21046}
21047
21048/**
21049 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21050 * @wmi_handle: wmi handler
21051 * @req_buf: get arp stats request buffer
21052 *
21053 * Return: 0 for success and non zero for failure
21054 */
21055static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21056 struct get_arp_stats *req_buf)
21057{
21058 wmi_buf_t buf = NULL;
21059 QDF_STATUS status;
21060 int len;
21061 uint8_t *buf_ptr;
21062 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21063
21064 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21065 buf = wmi_buf_alloc(wmi_handle, len);
21066 if (!buf) {
21067 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21068 return QDF_STATUS_E_NOMEM;
21069 }
21070
21071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21072 get_arp_stats =
21073 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21074 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21075 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21076 WMITLV_GET_STRUCT_TLVLEN
21077 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21078
21079 /* fill in arp stats req cmd values */
21080 get_arp_stats->vdev_id = req_buf->vdev_id;
21081
21082 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21083 /* Send per roam config parameters */
21084 status = wmi_unified_cmd_send(wmi_handle, buf,
21085 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21086 if (QDF_IS_STATUS_ERROR(status)) {
21087 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21088 status);
21089 goto error;
21090 }
21091
21092 return QDF_STATUS_SUCCESS;
21093error:
21094 wmi_buf_free(buf);
21095
21096 return status;
21097}
21098
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021099/**
21100 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21101 * @wmi_handle: wmi handler
21102 * @pmk_info: pointer to PMK cache entry
21103 * @vdev_id: vdev id
21104 *
21105 * Return: 0 for success and non zero for failure
21106 */
21107static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21108 struct wmi_unified_pmk_cache *pmk_info)
21109{
21110 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21111 wmi_buf_t buf;
21112 QDF_STATUS status;
21113 uint8_t *buf_ptr;
21114 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021115 uint32_t len = sizeof(*cmd);
21116
21117 if (pmk_info->pmk_len)
21118 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021119
21120 buf = wmi_buf_alloc(wmi_handle, len);
21121 if (!buf) {
21122 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21123 __func__);
21124 return QDF_STATUS_E_NOMEM;
21125 }
21126
21127 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21128 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21129
21130 WMITLV_SET_HDR(&cmd->tlv_header,
21131 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21132 WMITLV_GET_STRUCT_TLVLEN(
21133 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21134
21135 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021136
21137 /* If pmk_info->pmk_len is 0, this is a flush request */
21138 if (!pmk_info->pmk_len) {
21139 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21140 cmd->num_cache = 0;
21141 goto send_cmd;
21142 }
21143
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021144 cmd->num_cache = 1;
21145 buf_ptr += sizeof(*cmd);
21146
21147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21148 sizeof(*pmksa));
21149 buf_ptr += WMI_TLV_HDR_SIZE;
21150
21151 pmksa = (wmi_pmk_cache *)buf_ptr;
21152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21153 WMITLV_GET_STRUCT_TLVLEN
21154 (wmi_pmk_cache));
21155 pmksa->pmk_len = pmk_info->pmk_len;
21156 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21157 pmksa->pmkid_len = pmk_info->pmkid_len;
21158 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21159 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21160 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21161 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21162 pmksa->ssid.ssid_len);
21163 pmksa->cache_id = pmk_info->cache_id;
21164 pmksa->cat_flag = pmk_info->cat_flag;
21165 pmksa->action_flag = pmk_info->action_flag;
21166
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021167send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021168 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21169 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21170 if (status != QDF_STATUS_SUCCESS) {
21171 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21172 __func__, status);
21173 wmi_buf_free(buf);
21174 }
21175
21176 return status;
21177}
21178
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021179/**
21180 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21181 * @wmi_handle: wmi handle
21182 * @param: reserved param
21183 *
21184 * Return: 0 for success or error code
21185 */
21186static QDF_STATUS
21187send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21188 uint32_t param)
21189{
21190 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21191 wmi_buf_t buf;
21192 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21193
21194 buf = wmi_buf_alloc(wmi_handle, len);
21195 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021196 qdf_print("%s:wmi_buf_alloc failed", __func__);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021197 return QDF_STATUS_E_FAILURE;
21198 }
21199 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21200 WMITLV_SET_HDR(&cmd->tlv_header,
21201 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21202 WMITLV_GET_STRUCT_TLVLEN
21203 (wmi_pdev_check_cal_version_cmd_fixed_param));
21204 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21205 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21206 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21207 wmi_buf_free(buf);
21208 return QDF_STATUS_E_FAILURE;
21209 }
21210
21211 return QDF_STATUS_SUCCESS;
21212}
21213
21214/**
21215 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21216 * @wmi_handle: wmi handle
21217 * @param evt_buf: pointer to event buffer
21218 * @param param: Pointer to hold peer caldata version data
21219 *
21220 * Return: 0 for success or error code
21221 */
21222static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21223 wmi_unified_t wmi_handle,
21224 void *evt_buf,
21225 wmi_host_pdev_check_cal_version_event *param)
21226{
21227 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21228 wmi_pdev_check_cal_version_event_fixed_param *event;
21229
21230 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21231 if (!param_tlvs) {
21232 WMI_LOGE("invalid cal version event buf");
21233 return QDF_STATUS_E_FAILURE;
21234 }
21235 event = param_tlvs->fixed_param;
21236 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21237 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21238 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21239 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21240
21241 param->software_cal_version = event->software_cal_version;
21242 param->board_cal_version = event->board_cal_version;
21243 param->cal_ok = event->cal_status;
21244
21245 return QDF_STATUS_SUCCESS;
21246}
21247
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021248/*
21249 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21250 * @wmi_handle: wmi handle
21251 * @params: pointer to wmi_btm_config
21252 *
21253 * Return: QDF_STATUS
21254 */
21255static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21256 struct wmi_btm_config *params)
21257{
21258
21259 wmi_btm_config_fixed_param *cmd;
21260 wmi_buf_t buf;
21261 uint32_t len;
21262
21263 len = sizeof(*cmd);
21264 buf = wmi_buf_alloc(wmi_handle, len);
21265 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021266 qdf_print("%s:wmi_buf_alloc failed", __func__);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021267 return QDF_STATUS_E_NOMEM;
21268 }
21269
21270 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21271 WMITLV_SET_HDR(&cmd->tlv_header,
21272 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21273 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21274 cmd->vdev_id = params->vdev_id;
21275 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021276 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21277 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21278 cmd->stick_time_seconds = params->btm_sticky_time;
21279
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021280 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21281 WMI_ROAM_BTM_CONFIG_CMDID)) {
21282 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21283 __func__);
21284 wmi_buf_free(buf);
21285 return QDF_STATUS_E_FAILURE;
21286 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021287
21288 return QDF_STATUS_SUCCESS;
21289}
21290
21291/**
21292 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21293 * configurations to firmware.
21294 * @wmi_handle: wmi handle
21295 * @obss_cfg_param: obss detection configurations
21296 *
21297 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21298 *
21299 * Return: QDF_STATUS
21300 */
21301static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21302 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21303{
21304 wmi_buf_t buf;
21305 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21306 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21307
21308 buf = wmi_buf_alloc(wmi_handle, len);
21309 if (!buf) {
21310 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21311 return QDF_STATUS_E_NOMEM;
21312 }
21313
21314 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21315 WMITLV_SET_HDR(&cmd->tlv_header,
21316 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21317 WMITLV_GET_STRUCT_TLVLEN
21318 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21319
21320 cmd->vdev_id = obss_cfg_param->vdev_id;
21321 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21322 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21323 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21324 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21325 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21326 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21327 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21328 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021329
21330 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21331 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21332 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21333 wmi_buf_free(buf);
21334 return QDF_STATUS_E_FAILURE;
21335 }
21336
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021337 return QDF_STATUS_SUCCESS;
21338}
21339
Arif Hussain33d98502018-01-12 13:15:04 -080021340/**
21341 * extract_obss_detection_info_tlv() - Extract obss detection info
21342 * received from firmware.
21343 * @evt_buf: pointer to event buffer
21344 * @obss_detection: Pointer to hold obss detection info
21345 *
21346 * Return: QDF_STATUS
21347 */
21348static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21349 struct wmi_obss_detect_info
21350 *obss_detection)
21351{
21352 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21353 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21354
21355 if (!obss_detection) {
21356 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21357 return QDF_STATUS_E_INVAL;
21358 }
21359
21360 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21361 if (!param_buf) {
21362 WMI_LOGE("%s: Invalid evt_buf", __func__);
21363 return QDF_STATUS_E_INVAL;
21364 }
21365
21366 fix_param = param_buf->fixed_param;
21367 obss_detection->vdev_id = fix_param->vdev_id;
21368 obss_detection->matched_detection_masks =
21369 fix_param->matched_detection_masks;
21370 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21371 &obss_detection->matched_bssid_addr[0]);
21372 switch (fix_param->reason) {
21373 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21374 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21375 break;
21376 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21377 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21378 break;
21379 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21380 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21381 break;
21382 default:
21383 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21384 return QDF_STATUS_E_INVAL;
21385 }
21386
21387 return QDF_STATUS_SUCCESS;
21388}
21389
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021390/**
21391 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21392 * @wmi_handle: wmi handler
21393 * @params: pointer to 11k offload params
21394 *
21395 * Return: 0 for success and non zero for failure
21396 */
21397static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21398 struct wmi_11k_offload_params *params)
21399{
21400 wmi_11k_offload_report_fixed_param *cmd;
21401 wmi_buf_t buf;
21402 QDF_STATUS status;
21403 uint8_t *buf_ptr;
21404 wmi_neighbor_report_11k_offload_tlv_param
21405 *neighbor_report_offload_params;
21406 wmi_neighbor_report_offload *neighbor_report_offload;
21407
21408 uint32_t len = sizeof(*cmd);
21409
21410 if (params->offload_11k_bitmask &
21411 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21412 len += WMI_TLV_HDR_SIZE +
21413 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21414
21415 buf = wmi_buf_alloc(wmi_handle, len);
21416 if (!buf) {
21417 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21418 __func__);
21419 return QDF_STATUS_E_NOMEM;
21420 }
21421
21422 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21423 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21424
21425 WMITLV_SET_HDR(&cmd->tlv_header,
21426 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21427 WMITLV_GET_STRUCT_TLVLEN(
21428 wmi_11k_offload_report_fixed_param));
21429
21430 cmd->vdev_id = params->vdev_id;
21431 cmd->offload_11k = params->offload_11k_bitmask;
21432
21433 if (params->offload_11k_bitmask &
21434 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21435 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21436
21437 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21438 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21439 buf_ptr += WMI_TLV_HDR_SIZE;
21440
21441 neighbor_report_offload_params =
21442 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21443 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21444 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21445 WMITLV_GET_STRUCT_TLVLEN(
21446 wmi_neighbor_report_11k_offload_tlv_param));
21447
21448 neighbor_report_offload = &neighbor_report_offload_params->
21449 neighbor_rep_ofld_params;
21450
21451 neighbor_report_offload->time_offset =
21452 params->neighbor_report_params.time_offset;
21453 neighbor_report_offload->low_rssi_offset =
21454 params->neighbor_report_params.low_rssi_offset;
21455 neighbor_report_offload->bmiss_count_trigger =
21456 params->neighbor_report_params.bmiss_count_trigger;
21457 neighbor_report_offload->per_threshold_offset =
21458 params->neighbor_report_params.per_threshold_offset;
21459 neighbor_report_offload->neighbor_report_cache_timeout =
21460 params->neighbor_report_params.
21461 neighbor_report_cache_timeout;
21462 neighbor_report_offload->max_neighbor_report_req_cap =
21463 params->neighbor_report_params.
21464 max_neighbor_report_req_cap;
21465 neighbor_report_offload->ssid.ssid_len =
21466 params->neighbor_report_params.ssid.length;
21467 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21468 &params->neighbor_report_params.ssid.mac_ssid,
21469 neighbor_report_offload->ssid.ssid_len);
21470 }
21471
21472 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21473 WMI_11K_OFFLOAD_REPORT_CMDID);
21474 if (status != QDF_STATUS_SUCCESS) {
21475 WMI_LOGE("%s: failed to send 11k offload command %d",
21476 __func__, status);
21477 wmi_buf_free(buf);
21478 }
21479
21480 return status;
21481}
21482
21483/**
21484 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21485 * command
21486 * @wmi_handle: wmi handler
21487 * @params: pointer to neighbor report invoke params
21488 *
21489 * Return: 0 for success and non zero for failure
21490 */
21491static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21492 struct wmi_invoke_neighbor_report_params *params)
21493{
21494 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21495 wmi_buf_t buf;
21496 QDF_STATUS status;
21497 uint8_t *buf_ptr;
21498 uint32_t len = sizeof(*cmd);
21499
21500 buf = wmi_buf_alloc(wmi_handle, len);
21501 if (!buf) {
21502 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21503 __func__);
21504 return QDF_STATUS_E_NOMEM;
21505 }
21506
21507 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21508 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21509
21510 WMITLV_SET_HDR(&cmd->tlv_header,
21511 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21512 WMITLV_GET_STRUCT_TLVLEN(
21513 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21514
21515 cmd->vdev_id = params->vdev_id;
21516 cmd->flags = params->send_resp_to_host;
21517
21518 cmd->ssid.ssid_len = params->ssid.length;
21519 qdf_mem_copy(cmd->ssid.ssid,
21520 &params->ssid.mac_ssid,
21521 cmd->ssid.ssid_len);
21522
21523 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21524 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21525 if (status != QDF_STATUS_SUCCESS) {
21526 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21527 __func__, status);
21528 wmi_buf_free(buf);
21529 }
21530
21531 return status;
21532}
21533
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021534#ifdef WLAN_SUPPORT_GREEN_AP
21535static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21536 uint8_t *evt_buf,
21537 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21538{
21539 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21540 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21541 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21542
21543 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21544 if (!param_buf) {
21545 WMI_LOGE("Invalid EGAP Info status event buffer");
21546 return QDF_STATUS_E_INVAL;
21547 }
21548
21549 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21550 param_buf->fixed_param;
21551 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21552 param_buf->chainmask_list;
21553
21554 egap_status_info_params->status = egap_info_event->status;
21555 egap_status_info_params->mac_id = chainmask_event->mac_id;
21556 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21557 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21558
21559 return QDF_STATUS_SUCCESS;
21560}
21561#endif
21562
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021563/*
21564 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21565 * updating bss color change within firmware when AP announces bss color change.
21566 * @wmi_handle: wmi handle
21567 * @vdev_id: vdev ID
21568 * @enable: enable bss color change within firmware
21569 *
21570 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21571 *
21572 * Return: QDF_STATUS
21573 */
21574static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21575 uint32_t vdev_id,
21576 bool enable)
21577{
21578 wmi_buf_t buf;
21579 wmi_bss_color_change_enable_fixed_param *cmd;
21580 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21581
21582 buf = wmi_buf_alloc(wmi_handle, len);
21583 if (!buf) {
21584 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21585 return QDF_STATUS_E_NOMEM;
21586 }
21587
21588 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21589 WMITLV_SET_HDR(&cmd->tlv_header,
21590 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21591 WMITLV_GET_STRUCT_TLVLEN
21592 (wmi_bss_color_change_enable_fixed_param));
21593 cmd->vdev_id = vdev_id;
21594 cmd->enable = enable;
21595 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21596 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21597 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21598 wmi_buf_free(buf);
21599 return QDF_STATUS_E_FAILURE;
21600 }
21601
21602 return QDF_STATUS_SUCCESS;
21603}
21604
21605/**
21606 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21607 * configurations to firmware.
21608 * @wmi_handle: wmi handle
21609 * @cfg_param: obss detection configurations
21610 *
21611 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21612 *
21613 * Return: QDF_STATUS
21614 */
21615static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21616 wmi_unified_t wmi_handle,
21617 struct wmi_obss_color_collision_cfg_param *cfg_param)
21618{
21619 wmi_buf_t buf;
21620 wmi_obss_color_collision_det_config_fixed_param *cmd;
21621 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21622
21623 buf = wmi_buf_alloc(wmi_handle, len);
21624 if (!buf) {
21625 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21626 return QDF_STATUS_E_NOMEM;
21627 }
21628
21629 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21630 buf);
21631 WMITLV_SET_HDR(&cmd->tlv_header,
21632 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21633 WMITLV_GET_STRUCT_TLVLEN
21634 (wmi_obss_color_collision_det_config_fixed_param));
21635 cmd->vdev_id = cfg_param->vdev_id;
21636 cmd->flags = cfg_param->flags;
21637 cmd->current_bss_color = cfg_param->current_bss_color;
21638 cmd->detection_period_ms = cfg_param->detection_period_ms;
21639 cmd->scan_period_ms = cfg_param->scan_period_ms;
21640 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21641
21642 switch (cfg_param->evt_type) {
21643 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21644 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21645 break;
21646 case OBSS_COLOR_COLLISION_DETECTION:
21647 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21648 break;
21649 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21650 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21651 break;
21652 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21653 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21654 break;
21655 default:
21656 WMI_LOGE("%s: invalid event type: %d",
21657 __func__, cfg_param->evt_type);
21658 wmi_buf_free(buf);
21659 return QDF_STATUS_E_FAILURE;
21660 }
21661
21662 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21663 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21664 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21665 __func__, cfg_param->vdev_id);
21666 wmi_buf_free(buf);
21667 return QDF_STATUS_E_FAILURE;
21668 }
21669
21670 return QDF_STATUS_SUCCESS;
21671}
21672
21673/**
21674 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21675 * received from firmware.
21676 * @evt_buf: pointer to event buffer
21677 * @info: Pointer to hold bss collision info
21678 *
21679 * Return: QDF_STATUS
21680 */
21681static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21682 struct wmi_obss_color_collision_info *info)
21683{
21684 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21685 wmi_obss_color_collision_evt_fixed_param *fix_param;
21686
21687 if (!info) {
21688 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21689 return QDF_STATUS_E_INVAL;
21690 }
21691
21692 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21693 evt_buf;
21694 if (!param_buf) {
21695 WMI_LOGE("%s: Invalid evt_buf", __func__);
21696 return QDF_STATUS_E_INVAL;
21697 }
21698
21699 fix_param = param_buf->fixed_param;
21700 info->vdev_id = fix_param->vdev_id;
21701 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21702 info->obss_color_bitmap_bit32to63 =
21703 fix_param->bss_color_bitmap_bit32to63;
21704
21705 switch (fix_param->evt_type) {
21706 case WMI_BSS_COLOR_COLLISION_DISABLE:
21707 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21708 break;
21709 case WMI_BSS_COLOR_COLLISION_DETECTION:
21710 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21711 break;
21712 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21713 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21714 break;
21715 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21716 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21717 break;
21718 default:
21719 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21720 __func__, fix_param->evt_type, fix_param->vdev_id);
21721 return QDF_STATUS_E_FAILURE;
21722 }
21723
21724 return QDF_STATUS_SUCCESS;
21725}
21726
Arif Hussaine0eb7302018-03-01 14:40:59 -080021727/*
21728 * extract_comb_phyerr_tlv() - extract comb phy error from event
21729 * @wmi_handle: wmi handle
21730 * @evt_buf: pointer to event buffer
21731 * @datalen: data length of event buffer
21732 * @buf_offset: Pointer to hold value of current event buffer offset
21733 * post extraction
21734 * @phyerr: Pointer to hold phyerr
21735 *
21736 * Return: QDF_STATUS
21737 */
21738static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21739 void *evt_buf,
21740 uint16_t datalen,
21741 uint16_t *buf_offset,
21742 wmi_host_phyerr_t *phyerr)
21743{
21744 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21745 wmi_comb_phyerr_rx_hdr *pe_hdr;
21746
21747 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21748 if (!param_tlvs) {
21749 WMI_LOGD("%s: Received null data from FW", __func__);
21750 return QDF_STATUS_E_FAILURE;
21751 }
21752
21753 pe_hdr = param_tlvs->hdr;
21754 if (!pe_hdr) {
21755 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21756 return QDF_STATUS_E_FAILURE;
21757 }
21758
21759 /* Ensure it's at least the size of the header */
21760 if (datalen < sizeof(*pe_hdr)) {
21761 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21762 __func__, sizeof(*pe_hdr), datalen);
21763 return QDF_STATUS_E_FAILURE;
21764 }
21765
21766 phyerr->pdev_id = wmi_handle->ops->
21767 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21768 phyerr->tsf64 = pe_hdr->tsf_l32;
21769 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21770 phyerr->bufp = param_tlvs->bufp;
21771 phyerr->buf_len = pe_hdr->buf_len;
21772 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21773 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21774 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21775
21776 return QDF_STATUS_SUCCESS;
21777}
21778
21779/**
21780 * extract_single_phyerr_tlv() - extract single phy error from event
21781 * @wmi_handle: wmi handle
21782 * @evt_buf: pointer to event buffer
21783 * @datalen: data length of event buffer
21784 * @buf_offset: Pointer to hold value of current event buffer offset
21785 * post extraction
21786 * @phyerr: Pointer to hold phyerr
21787 *
21788 * Return: QDF_STATUS
21789 */
21790static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21791 void *evt_buf,
21792 uint16_t datalen,
21793 uint16_t *buf_offset,
21794 wmi_host_phyerr_t *phyerr)
21795{
21796 wmi_single_phyerr_rx_event *ev;
21797 uint16_t n = *buf_offset;
21798 uint8_t *data = (uint8_t *)evt_buf;
21799
21800 if (n < datalen) {
21801 if ((datalen - n) < sizeof(ev->hdr)) {
21802 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21803 __func__, datalen, n, sizeof(ev->hdr));
21804 return QDF_STATUS_E_FAILURE;
21805 }
21806
21807 /*
21808 * Obtain a pointer to the beginning of the current event.
21809 * data[0] is the beginning of the WMI payload.
21810 */
21811 ev = (wmi_single_phyerr_rx_event *)&data[n];
21812
21813 /*
21814 * Sanity check the buffer length of the event against
21815 * what we currently have.
21816 *
21817 * Since buf_len is 32 bits, we check if it overflows
21818 * a large 32 bit value. It's not 0x7fffffff because
21819 * we increase n by (buf_len + sizeof(hdr)), which would
21820 * in itself cause n to overflow.
21821 *
21822 * If "int" is 64 bits then this becomes a moot point.
21823 */
21824 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21825 WMI_LOGD("%s: buf_len is garbage 0x%x",
21826 __func__, ev->hdr.buf_len);
21827 return QDF_STATUS_E_FAILURE;
21828 }
21829
21830 if ((n + ev->hdr.buf_len) > datalen) {
21831 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21832 __func__, n, ev->hdr.buf_len, datalen);
21833 return QDF_STATUS_E_FAILURE;
21834 }
21835
21836 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21837 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21838 phyerr->bufp = &ev->bufp[0];
21839 phyerr->buf_len = ev->hdr.buf_len;
21840 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21841
21842 /*
21843 * Advance the buffer pointer to the next PHY error.
21844 * buflen is the length of this payload, so we need to
21845 * advance past the current header _AND_ the payload.
21846 */
21847 n += sizeof(*ev) + ev->hdr.buf_len;
21848 }
21849 *buf_offset = n;
21850
21851 return QDF_STATUS_SUCCESS;
21852}
21853
Govind Singh5eb51532016-03-09 11:34:12 +053021854struct wmi_ops tlv_ops = {
21855 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21856 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21857 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021858 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21859 .send_hidden_ssid_vdev_restart_cmd =
21860 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021861 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21862 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21863 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021864 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021865 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021866 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021867 .send_peer_rx_reorder_queue_setup_cmd =
21868 send_peer_rx_reorder_queue_setup_cmd_tlv,
21869 .send_peer_rx_reorder_queue_remove_cmd =
21870 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021871 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21872 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21873 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021874 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21875 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021876 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021877 .send_suspend_cmd = send_suspend_cmd_tlv,
21878 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021879#ifdef FEATURE_WLAN_D0WOW
21880 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21881 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21882#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021883 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21884 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21885 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21886 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021887#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021888 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021889#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021890 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21891 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21892 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021893 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021894 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021895 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021896 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021897 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21898 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21899 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21900 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021901 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021902 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021903 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21904 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021905 .send_set_sta_uapsd_auto_trig_cmd =
21906 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021907 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21908 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21909 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021910#ifdef CONVERGED_P2P_ENABLE
21911 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21912 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21913#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021914 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21915 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021916#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021917 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21918 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21919 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21920 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21921 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21922 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21923 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021924 .send_ocb_start_timing_advert_cmd =
21925 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021926 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21927 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21928 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21929 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21930#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021931 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21932 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21933 .send_set_mcc_channel_time_latency_cmd =
21934 send_set_mcc_channel_time_latency_cmd_tlv,
21935 .send_set_mcc_channel_time_quota_cmd =
21936 send_set_mcc_channel_time_quota_cmd_tlv,
21937 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21938 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021939 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021940 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21941 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21942 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021943 .send_probe_rsp_tmpl_send_cmd =
21944 send_probe_rsp_tmpl_send_cmd_tlv,
21945 .send_p2p_go_set_beacon_ie_cmd =
21946 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021947 .send_setup_install_key_cmd =
21948 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021949 .send_set_gateway_params_cmd =
21950 send_set_gateway_params_cmd_tlv,
21951 .send_set_rssi_monitoring_cmd =
21952 send_set_rssi_monitoring_cmd_tlv,
21953 .send_scan_probe_setoui_cmd =
21954 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021955 .send_roam_scan_offload_rssi_thresh_cmd =
21956 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021957 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021958 .send_roam_scan_filter_cmd =
21959 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021960#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053021961 .send_ipa_offload_control_cmd =
21962 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021963#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053021964 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21965 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21966 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21967 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021968 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021969 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021970#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053021971 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21972 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21973 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021974#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021975 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021976 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21977 .send_snr_cmd = send_snr_cmd_tlv,
21978 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021979#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021980 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21981 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21982 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21983 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021984 .send_multiple_add_clear_mcbc_filter_cmd =
21985 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021986 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021987 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21988 .send_process_gtk_offload_getinfo_cmd =
21989 send_process_gtk_offload_getinfo_cmd_tlv,
21990 .send_enable_enhance_multicast_offload_cmd =
21991 send_enable_enhance_multicast_offload_tlv,
21992 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21993#ifdef FEATURE_WLAN_RA_FILTERING
21994 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21995#endif
21996 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021997 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21998 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021999 .send_lphb_config_tcp_pkt_filter_cmd =
22000 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022001 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22002 .send_lphb_config_udp_pkt_filter_cmd =
22003 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022004 .send_enable_disable_packet_filter_cmd =
22005 send_enable_disable_packet_filter_cmd_tlv,
22006 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022007#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022008#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022009 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22010 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022011 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022012 .send_roam_scan_offload_mode_cmd =
22013 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022014#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053022015 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022016#endif
Govind Singh87542482016-06-08 19:40:11 +053022017 .send_roam_scan_offload_ap_profile_cmd =
22018 send_roam_scan_offload_ap_profile_cmd_tlv,
22019#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022020#ifdef WLAN_SUPPORT_GREEN_AP
22021 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22022 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022023 .extract_green_ap_egap_status_info =
22024 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022025#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022026 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22027 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022028 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022029 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022030 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022031#ifdef WLAN_FEATURE_CIF_CFR
22032 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22033#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022034 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022035 .send_dfs_phyerr_filter_offload_en_cmd =
22036 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022037 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22038 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22039 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22040 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22041 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022042 .send_process_add_periodic_tx_ptrn_cmd =
22043 send_process_add_periodic_tx_ptrn_cmd_tlv,
22044 .send_process_del_periodic_tx_ptrn_cmd =
22045 send_process_del_periodic_tx_ptrn_cmd_tlv,
22046 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22047 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22048 .send_set_app_type2_params_in_fw_cmd =
22049 send_set_app_type2_params_in_fw_cmd_tlv,
22050 .send_set_auto_shutdown_timer_cmd =
22051 send_set_auto_shutdown_timer_cmd_tlv,
22052 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22053 .send_process_dhcpserver_offload_cmd =
22054 send_process_dhcpserver_offload_cmd_tlv,
22055 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22056 .send_process_ch_avoid_update_cmd =
22057 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022058 .send_pdev_set_regdomain_cmd =
22059 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022060 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22061 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22062 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22063 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022064 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022065 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022066 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022067 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022068 .send_set_base_macaddr_indicate_cmd =
22069 send_set_base_macaddr_indicate_cmd_tlv,
22070 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22071 .send_enable_specific_fw_logs_cmd =
22072 send_enable_specific_fw_logs_cmd_tlv,
22073 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022074 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022075 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022076#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022077 .send_pdev_set_dual_mac_config_cmd =
22078 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022079#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022080 .send_app_type1_params_in_fw_cmd =
22081 send_app_type1_params_in_fw_cmd_tlv,
22082 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22083 .send_process_roam_synch_complete_cmd =
22084 send_process_roam_synch_complete_cmd_tlv,
22085 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22086 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22087 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022088 .send_roam_scan_offload_scan_period_cmd =
22089 send_roam_scan_offload_scan_period_cmd_tlv,
22090 .send_roam_scan_offload_chan_list_cmd =
22091 send_roam_scan_offload_chan_list_cmd_tlv,
22092 .send_roam_scan_offload_rssi_change_cmd =
22093 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022094#ifdef FEATURE_WLAN_APF
22095 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22096 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22097 .send_apf_write_work_memory_cmd =
22098 wmi_send_apf_write_work_memory_cmd_tlv,
22099 .send_apf_read_work_memory_cmd =
22100 wmi_send_apf_read_work_memory_cmd_tlv,
22101 .extract_apf_read_memory_resp_event =
22102 wmi_extract_apf_read_memory_resp_event_tlv,
22103#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022104 .send_adapt_dwelltime_params_cmd =
22105 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022106 .send_dbs_scan_sel_params_cmd =
22107 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022108 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022109 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22110 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22111 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22112 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22113 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22114 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022115 .send_vdev_set_custom_aggr_size_cmd =
22116 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022117 .send_vdev_set_qdepth_thresh_cmd =
22118 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022119 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22120 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22121 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022122 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22123 .send_smart_ant_set_training_info_cmd =
22124 send_smart_ant_set_training_info_cmd_tlv,
22125 .send_smart_ant_set_node_config_cmd =
22126 send_smart_ant_set_node_config_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022127#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053022128 .send_set_atf_cmd = send_set_atf_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022129#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053022130 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22131 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022132 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22133 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22134 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22135 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022136 .send_periodic_chan_stats_config_cmd =
22137 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022138 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22139 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22140 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022141 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22142 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22143 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22144 .send_vdev_spectral_configure_cmd =
22145 send_vdev_spectral_configure_cmd_tlv,
22146 .send_vdev_spectral_enable_cmd =
22147 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022148 .send_thermal_mitigation_param_cmd =
22149 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022150 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22151 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022152 .send_process_update_edca_param_cmd =
22153 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022154 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022155 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022156 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022157 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22158 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022159 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022160 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22161 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22162 .extract_host_mem_req = extract_host_mem_req_tlv,
22163 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022164 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022165 .is_service_enabled = is_service_enabled_tlv,
22166 .save_fw_version = save_fw_version_in_service_ready_tlv,
22167 .ready_extract_init_status = ready_extract_init_status_tlv,
22168 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022169 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022170 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022171 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22172 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022173 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022174 .extract_tbttoffset_update_params =
22175 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022176 .extract_ext_tbttoffset_update_params =
22177 extract_ext_tbttoffset_update_params_tlv,
22178 .extract_tbttoffset_num_vdevs =
22179 extract_tbttoffset_num_vdevs_tlv,
22180 .extract_ext_tbttoffset_num_vdevs =
22181 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022182 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22183 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22184 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22185 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022186#ifdef CONVERGED_TDLS_ENABLE
22187 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22188#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022189 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022190 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022191 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22192 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022193#ifdef CONVERGED_P2P_ENABLE
22194 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22195 .extract_p2p_lo_stop_ev_param =
22196 extract_p2p_lo_stop_ev_param_tlv,
22197#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022198 .extract_offchan_data_tx_compl_param =
22199 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022200 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22201 .extract_all_stats_count = extract_all_stats_counts_tlv,
22202 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022203 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022204 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22205 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022206 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022207 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022208 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022209 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22210 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22211 .extract_chan_stats = extract_chan_stats_tlv,
22212 .extract_profile_ctx = extract_profile_ctx_tlv,
22213 .extract_profile_data = extract_profile_data_tlv,
22214 .extract_chan_info_event = extract_chan_info_event_tlv,
22215 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022216 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022217#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022218 .send_encrypt_decrypt_send_cmd =
22219 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022220 .extract_encrypt_decrypt_resp_event =
22221 extract_encrypt_decrypt_resp_event_tlv,
22222#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022223 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022224 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22225 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022226 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022227 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022228 .send_multiple_vdev_restart_req_cmd =
22229 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022230 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22231 .extract_hw_mode_cap_service_ready_ext =
22232 extract_hw_mode_cap_service_ready_ext_tlv,
22233 .extract_mac_phy_cap_service_ready_ext =
22234 extract_mac_phy_cap_service_ready_ext_tlv,
22235 .extract_reg_cap_service_ready_ext =
22236 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022237 .extract_dbr_ring_cap_service_ready_ext =
22238 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022239 .extract_sar_cap_service_ready_ext =
22240 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022241 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22242 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022243 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022244 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022245 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022246 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22247 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22248 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022249 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022250 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022251 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022252 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022253 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022254 .extract_pdev_csa_switch_count_status =
22255 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022256 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022257 .extract_pdev_tpc_config_ev_param =
22258 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022259 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022260 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22261 .extract_peer_sta_ps_statechange_ev =
22262 extract_peer_sta_ps_statechange_ev_tlv,
22263 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022264 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022265#ifdef WLAN_FEATURE_ACTION_OUI
22266 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22267#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022268 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22269 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022270 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022271 extract_reg_chan_list_update_event_tlv,
22272 .extract_chainmask_tables =
22273 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022274 .extract_thermal_stats = extract_thermal_stats_tlv,
22275 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022276 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22277 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022278#ifdef DFS_COMPONENT_ENABLE
22279 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22280 .extract_dfs_radar_detection_event =
22281 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022282 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022283#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022284 .convert_pdev_id_host_to_target =
22285 convert_host_pdev_id_to_target_pdev_id_legacy,
22286 .convert_pdev_id_target_to_host =
22287 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022288
22289 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22290 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22291 .extract_reg_11d_new_country_event =
22292 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022293 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022294 .send_limit_off_chan_cmd =
22295 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022296 .extract_reg_ch_avoid_event =
22297 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022298 .send_pdev_caldata_version_check_cmd =
22299 send_pdev_caldata_version_check_cmd_tlv,
22300 .extract_pdev_caldata_version_check_ev_param =
22301 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022302 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22303 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022304 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22305#if defined(WLAN_FEATURE_FILS_SK)
22306 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22307#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022308 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022309#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22310 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22311 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22312 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22313 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22314 .extract_ndp_ind = extract_ndp_ind_tlv,
22315 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22316 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22317 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22318 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022319 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022320#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022321 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022322 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022323 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022324#ifdef WLAN_SUPPORT_FILS
22325 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22326 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22327 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22328#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022329 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22330 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022331 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22332 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22333 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22334 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022335 .send_bss_color_change_enable_cmd =
22336 send_bss_color_change_enable_cmd_tlv,
22337 .send_obss_color_collision_cfg_cmd =
22338 send_obss_color_collision_cfg_cmd_tlv,
22339 .extract_obss_color_collision_info =
22340 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022341 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22342 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022343#ifdef QCA_SUPPORT_CP_STATS
22344 .extract_cca_stats = extract_cca_stats_tlv,
22345#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022346};
22347
Govind Singhe7f2f342016-05-23 12:12:52 +053022348/**
22349 * populate_tlv_event_id() - populates wmi event ids
22350 *
22351 * @param event_ids: Pointer to hold event ids
22352 * Return: None
22353 */
22354static void populate_tlv_events_id(uint32_t *event_ids)
22355{
22356 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22357 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22358 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22359 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22360 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22361 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22362 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22363 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22364 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22365 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22366 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22367 event_ids[wmi_service_ready_ext_event_id] =
22368 WMI_SERVICE_READY_EXT_EVENTID;
22369 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22370 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22371 event_ids[wmi_vdev_install_key_complete_event_id] =
22372 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22373 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22374 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22375
22376 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22377 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22378 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22379 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22380 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22381 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22382 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22383 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022384 event_ids[wmi_peer_delete_response_event_id] =
22385 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022386 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22387 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22388 event_ids[wmi_tbttoffset_update_event_id] =
22389 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022390 event_ids[wmi_ext_tbttoffset_update_event_id] =
22391 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022392 event_ids[wmi_offload_bcn_tx_status_event_id] =
22393 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22394 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22395 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22396 event_ids[wmi_mgmt_tx_completion_event_id] =
22397 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022398 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22399 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022400 event_ids[wmi_tx_delba_complete_event_id] =
22401 WMI_TX_DELBA_COMPLETE_EVENTID;
22402 event_ids[wmi_tx_addba_complete_event_id] =
22403 WMI_TX_ADDBA_COMPLETE_EVENTID;
22404 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22405
22406 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22407
22408 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22409 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22410
22411 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022412 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022413
22414 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22415
22416 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022417 event_ids[wmi_p2p_lo_stop_event_id] =
22418 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022419 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22420 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022421 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022422 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22423 event_ids[wmi_wow_initial_wakeup_event_id] =
22424 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22425
22426 event_ids[wmi_rtt_meas_report_event_id] =
22427 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22428 event_ids[wmi_tsf_meas_report_event_id] =
22429 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22430 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22431 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22432 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22433 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22434 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022435 event_ids[wmi_diag_event_id_log_supported_event_id] =
22436 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22437 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22438 event_ids[wmi_nlo_scan_complete_event_id] =
22439 WMI_NLO_SCAN_COMPLETE_EVENTID;
22440 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22441 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22442
22443 event_ids[wmi_gtk_offload_status_event_id] =
22444 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22445 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22446 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22447 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22448
22449 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22450
22451 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22452
22453 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22454 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22455 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22456 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22457 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22458 event_ids[wmi_wlan_profile_data_event_id] =
22459 WMI_WLAN_PROFILE_DATA_EVENTID;
22460 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22461 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22462 event_ids[wmi_vdev_get_keepalive_event_id] =
22463 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22464 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22465
22466 event_ids[wmi_diag_container_event_id] =
22467 WMI_DIAG_DATA_CONTAINER_EVENTID;
22468
22469 event_ids[wmi_host_auto_shutdown_event_id] =
22470 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22471
22472 event_ids[wmi_update_whal_mib_stats_event_id] =
22473 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22474
22475 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22476 event_ids[wmi_update_vdev_rate_stats_event_id] =
22477 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22478
22479 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022480 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022481
22482 /** Set OCB Sched Response, deprecated */
22483 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22484
22485 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22486 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22487 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22488
22489 /* GPIO Event */
22490 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22491 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22492
22493 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22494 event_ids[wmi_rfkill_state_change_event_id] =
22495 WMI_RFKILL_STATE_CHANGE_EVENTID;
22496
22497 /* TDLS Event */
22498 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22499
22500 event_ids[wmi_batch_scan_enabled_event_id] =
22501 WMI_BATCH_SCAN_ENABLED_EVENTID;
22502 event_ids[wmi_batch_scan_result_event_id] =
22503 WMI_BATCH_SCAN_RESULT_EVENTID;
22504 /* OEM Event */
22505 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22506 event_ids[wmi_oem_meas_report_event_id] =
22507 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22508 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22509
22510 /* NAN Event */
22511 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22512
22513 /* LPI Event */
22514 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22515 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22516 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22517
22518 /* ExtScan events */
22519 event_ids[wmi_extscan_start_stop_event_id] =
22520 WMI_EXTSCAN_START_STOP_EVENTID;
22521 event_ids[wmi_extscan_operation_event_id] =
22522 WMI_EXTSCAN_OPERATION_EVENTID;
22523 event_ids[wmi_extscan_table_usage_event_id] =
22524 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22525 event_ids[wmi_extscan_cached_results_event_id] =
22526 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22527 event_ids[wmi_extscan_wlan_change_results_event_id] =
22528 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22529 event_ids[wmi_extscan_hotlist_match_event_id] =
22530 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22531 event_ids[wmi_extscan_capabilities_event_id] =
22532 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22533 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22534 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22535
22536 /* mDNS offload events */
22537 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22538
22539 /* SAP Authentication offload events */
22540 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22541 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22542
22543 /** Out-of-context-of-bss (OCB) events */
22544 event_ids[wmi_ocb_set_config_resp_event_id] =
22545 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22546 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22547 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22548 event_ids[wmi_dcc_get_stats_resp_event_id] =
22549 WMI_DCC_GET_STATS_RESP_EVENTID;
22550 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22551 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22552 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22553 /* System-On-Chip events */
22554 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22555 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22556 event_ids[wmi_soc_hw_mode_transition_event_id] =
22557 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22558 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22559 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022560 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022561 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22562 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022563 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022564 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22565 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22566 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22567 WMI_PEER_STA_PS_STATECHG_EVENTID;
22568 event_ids[wmi_pdev_channel_hopping_event_id] =
22569 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022570 event_ids[wmi_offchan_data_tx_completion_event] =
22571 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022572 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22573 event_ids[wmi_dfs_radar_detection_event_id] =
22574 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022575 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022576 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022577 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022578 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022579 event_ids[wmi_service_available_event_id] =
22580 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022581 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022582 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022583 /* NDP events */
22584 event_ids[wmi_ndp_initiator_rsp_event_id] =
22585 WMI_NDP_INITIATOR_RSP_EVENTID;
22586 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22587 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22588 event_ids[wmi_ndp_responder_rsp_event_id] =
22589 WMI_NDP_RESPONDER_RSP_EVENTID;
22590 event_ids[wmi_ndp_end_indication_event_id] =
22591 WMI_NDP_END_INDICATION_EVENTID;
22592 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022593 event_ids[wmi_ndl_schedule_update_event_id] =
22594 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022595
22596 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22597 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22598 event_ids[wmi_pdev_chip_power_stats_event_id] =
22599 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22600 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22601 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22602 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022603 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022604 WMI_BPF_CAPABILIY_INFO_EVENTID;
22605 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22606 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22607 event_ids[wmi_report_rx_aggr_failure_event_id] =
22608 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22609 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22610 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22611 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22612 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22613 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22614 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22615 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22616 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22617 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22618 event_ids[wmi_coex_bt_activity_event_id] =
22619 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22620 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22621 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22622 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22623 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22624 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022625 event_ids[wmi_dma_buf_release_event_id] =
22626 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022627 event_ids[wmi_sap_obss_detection_report_event_id] =
22628 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022629 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022630 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022631 event_ids[wmi_obss_color_collision_report_event_id] =
22632 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022633 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22634 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022635 event_ids[wmi_twt_enable_complete_event_id] =
22636 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022637 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22638 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022639 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022640}
22641
Soumya Bhat488092d2017-03-22 14:41:01 +053022642/**
22643 * populate_tlv_service() - populates wmi services
22644 *
22645 * @param wmi_service: Pointer to hold wmi_service
22646 * Return: None
22647 */
22648static void populate_tlv_service(uint32_t *wmi_service)
22649{
22650 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022651 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022652 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22653 wmi_service[wmi_service_roam_scan_offload] =
22654 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22655 wmi_service[wmi_service_bcn_miss_offload] =
22656 WMI_SERVICE_BCN_MISS_OFFLOAD;
22657 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22658 wmi_service[wmi_service_sta_advanced_pwrsave] =
22659 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22660 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22661 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22662 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22663 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22664 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22665 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22666 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22667 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22668 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22669 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22670 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22671 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22672 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22673 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22674 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22675 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22676 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22677 wmi_service[wmi_service_packet_power_save] =
22678 WMI_SERVICE_PACKET_POWER_SAVE;
22679 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22680 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22681 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22682 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22683 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22684 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22685 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22686 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22687 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22688 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22689 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22690 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22691 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22692 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22693 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22694 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22695 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22696 wmi_service[wmi_service_mcc_bcn_interval_change] =
22697 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22698 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22699 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22700 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22701 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22702 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22703 wmi_service[wmi_service_lte_ant_share_support] =
22704 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22705 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22706 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22707 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22708 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22709 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22710 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22711 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22712 wmi_service[wmi_service_bcn_txrate_override] =
22713 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22714 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22715 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22716 wmi_service[wmi_service_estimate_linkspeed] =
22717 WMI_SERVICE_ESTIMATE_LINKSPEED;
22718 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22719 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22720 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22721 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22722 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22723 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22724 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22725 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22726 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22727 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22728 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22729 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22730 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22731 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22732 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22733 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22734 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22735 wmi_service[wmi_service_sap_auth_offload] =
22736 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22737 wmi_service[wmi_service_dual_band_simultaneous_support] =
22738 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22739 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22740 wmi_service[wmi_service_ap_arpns_offload] =
22741 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22742 wmi_service[wmi_service_per_band_chainmask_support] =
22743 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22744 wmi_service[wmi_service_packet_filter_offload] =
22745 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22746 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22747 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22748 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22749 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22750 wmi_service[wmi_service_multiple_vdev_restart] =
22751 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22752
22753 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22754 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22755 wmi_service[wmi_service_smart_antenna_sw_support] =
22756 WMI_SERVICE_UNAVAILABLE;
22757 wmi_service[wmi_service_smart_antenna_hw_support] =
22758 WMI_SERVICE_UNAVAILABLE;
22759 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022760 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022761 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022762 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22763 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22764 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22765 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22766 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22767 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22768 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22769 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022770 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22771 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22772 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022773 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022774 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22775 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22776 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22777 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22778 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22779 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022780 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22781 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22782 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22783 wmi_service[wmi_service_unified_wow_capability] =
22784 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22785 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022786 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022787 wmi_service[wmi_service_sync_delete_cmds] =
22788 WMI_SERVICE_SYNC_DELETE_CMDS;
22789 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22790 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22791 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22792 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22793 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22794 wmi_service[wmi_service_deprecated_replace] =
22795 WMI_SERVICE_DEPRECATED_REPLACE;
22796 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22797 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22798 wmi_service[wmi_service_enhanced_mcast_filter] =
22799 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22800 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22801 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22802 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22803 wmi_service[wmi_service_p2p_listen_offload_support] =
22804 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22805 wmi_service[wmi_service_mark_first_wakeup_packet] =
22806 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22807 wmi_service[wmi_service_multiple_mcast_filter_set] =
22808 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22809 wmi_service[wmi_service_host_managed_rx_reorder] =
22810 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22811 wmi_service[wmi_service_flash_rdwr_support] =
22812 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22813 wmi_service[wmi_service_wlan_stats_report] =
22814 WMI_SERVICE_WLAN_STATS_REPORT;
22815 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22816 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22817 wmi_service[wmi_service_dfs_phyerr_offload] =
22818 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22819 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22820 wmi_service[wmi_service_fw_mem_dump_support] =
22821 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22822 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22823 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22824 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22825 wmi_service[wmi_service_hw_data_filtering] =
22826 WMI_SERVICE_HW_DATA_FILTERING;
22827 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22828 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022829 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022830 wmi_service[wmi_service_extended_nss_support] =
22831 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022832 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022833 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22834 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022835 wmi_service[wmi_service_offchan_data_tid_support] =
22836 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022837 wmi_service[wmi_service_support_dma] =
22838 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022839 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22840 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22841 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022842 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22843 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022844 wmi_service[wmi_service_11k_neighbour_report_support] =
22845 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022846 wmi_service[wmi_service_ap_obss_detection_offload] =
22847 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22848 wmi_service[wmi_service_bss_color_offload] =
22849 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022850 wmi_service[wmi_service_gmac_offload_support] =
22851 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022852 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22853 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22854 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22855 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022856 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22857 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022858 wmi_service[wmi_service_listen_interval_offload_support] =
22859 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022860
Soumya Bhat488092d2017-03-22 14:41:01 +053022861}
22862
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022863#ifndef CONFIG_MCL
22864
Govind Singhe7f2f342016-05-23 12:12:52 +053022865/**
22866 * populate_pdev_param_tlv() - populates pdev params
22867 *
22868 * @param pdev_param: Pointer to hold pdev params
22869 * Return: None
22870 */
22871static void populate_pdev_param_tlv(uint32_t *pdev_param)
22872{
22873 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22874 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22875 pdev_param[wmi_pdev_param_txpower_limit2g] =
22876 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22877 pdev_param[wmi_pdev_param_txpower_limit5g] =
22878 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22879 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22880 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22881 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22882 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22883 WMI_PDEV_PARAM_BEACON_TX_MODE;
22884 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22885 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22886 pdev_param[wmi_pdev_param_protection_mode] =
22887 WMI_PDEV_PARAM_PROTECTION_MODE;
22888 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22889 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22890 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22891 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22892 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22893 pdev_param[wmi_pdev_param_sta_kickout_th] =
22894 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22895 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22896 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22897 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22898 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22899 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22900 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22901 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22902 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22903 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22904 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22905 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22906 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22907 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22908 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22909 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22910 pdev_param[wmi_pdev_param_ltr_rx_override] =
22911 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22912 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22913 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22914 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22915 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22916 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22917 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22918 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22919 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22920 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22921 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22922 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22923 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22924 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22925 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22926 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22927 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22928 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22929 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22930 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22931 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22932 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22933 pdev_param[wmi_pdev_param_arp_ac_override] =
22934 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22935 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22936 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22937 pdev_param[wmi_pdev_param_ani_poll_period] =
22938 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22939 pdev_param[wmi_pdev_param_ani_listen_period] =
22940 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22941 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22942 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22943 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22944 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22945 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22946 pdev_param[wmi_pdev_param_idle_ps_config] =
22947 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22948 pdev_param[wmi_pdev_param_power_gating_sleep] =
22949 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22950 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22951 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22952 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22953 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22954 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22955 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22956 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22957 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22958 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22959 pdev_param[wmi_pdev_param_power_collapse_enable] =
22960 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22961 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22962 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22963 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22964 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22965 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22966 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22967 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22968 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22969 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22970 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22971 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22972 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22973 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22974 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22975 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22976 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22977 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22978 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22979 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22980 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22981 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22982 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22983 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22984 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22985 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22986 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22987 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22988 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22989 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22990 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22991 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22992 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22993 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22994 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22995 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22996 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22997 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22998 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22999 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23000 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23001 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23002 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23003 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23004 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023005 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23006 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23007 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023008 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23009 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023010 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023011 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023012 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23013 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23014 WMI_PDEV_PARAM_PROXY_STA_MODE;
23015 pdev_param[wmi_pdev_param_mu_group_policy] =
23016 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23017 pdev_param[wmi_pdev_param_noise_detection] =
23018 WMI_PDEV_PARAM_NOISE_DETECTION;
23019 pdev_param[wmi_pdev_param_noise_threshold] =
23020 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23021 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23022 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23023 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023024 pdev_param[wmi_pdev_param_atf_strict_sch] =
23025 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23026 pdev_param[wmi_pdev_param_atf_sched_duration] =
23027 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023028 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23029 pdev_param[wmi_pdev_param_sensitivity_level] =
23030 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23031 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23032 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23033 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23034 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023035 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23036 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23037 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23038 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023039 pdev_param[wmi_pdev_param_cca_threshold] =
23040 WMI_PDEV_PARAM_CCA_THRESHOLD;
23041 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23042 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023043 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023044 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23045 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23046 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23047 pdev_param[wmi_pdev_param_arp_srcaddr] =
23048 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23049 pdev_param[wmi_pdev_param_arp_dstaddr] =
23050 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23051 pdev_param[wmi_pdev_param_txpower_decr_db] =
23052 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023053 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23054 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023055 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23056 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023057 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023058 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023059 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23060 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023061 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23062 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023063 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23064 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023065 pdev_param[wmi_pdev_param_igmpmld_override] =
23066 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23067 pdev_param[wmi_pdev_param_igmpmld_tid] =
23068 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023069 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23070 pdev_param[wmi_pdev_param_block_interbss] =
23071 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023072 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023073 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23074 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23075 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023076 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023077 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023078 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23079 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023080 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023081 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23082 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023083 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23084 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23085 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23086 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023087 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23088 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23089 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23090 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23091 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23092 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23093 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23094 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23095 pdev_param[wmi_pdev_param_fast_channel_reset] =
23096 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23097 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023098 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023099 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023100 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23101 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023102}
23103
23104/**
23105 * populate_vdev_param_tlv() - populates vdev params
23106 *
23107 * @param vdev_param: Pointer to hold vdev params
23108 * Return: None
23109 */
23110static void populate_vdev_param_tlv(uint32_t *vdev_param)
23111{
23112 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23113 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23114 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23115 vdev_param[wmi_vdev_param_beacon_interval] =
23116 WMI_VDEV_PARAM_BEACON_INTERVAL;
23117 vdev_param[wmi_vdev_param_listen_interval] =
23118 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23119 vdev_param[wmi_vdev_param_multicast_rate] =
23120 WMI_VDEV_PARAM_MULTICAST_RATE;
23121 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23122 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23123 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23124 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23125 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23126 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23127 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23128 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23129 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23130 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23131 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23132 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23133 vdev_param[wmi_vdev_param_bmiss_count_max] =
23134 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23135 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23136 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23137 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23138 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23139 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23140 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23141 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23142 vdev_param[wmi_vdev_param_disable_htprotection] =
23143 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23144 vdev_param[wmi_vdev_param_sta_quickkickout] =
23145 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23146 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23147 vdev_param[wmi_vdev_param_protection_mode] =
23148 WMI_VDEV_PARAM_PROTECTION_MODE;
23149 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23150 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23151 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23152 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23153 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23154 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23155 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23156 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23157 vdev_param[wmi_vdev_param_bcast_data_rate] =
23158 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23159 vdev_param[wmi_vdev_param_mcast_data_rate] =
23160 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23161 vdev_param[wmi_vdev_param_mcast_indicate] =
23162 WMI_VDEV_PARAM_MCAST_INDICATE;
23163 vdev_param[wmi_vdev_param_dhcp_indicate] =
23164 WMI_VDEV_PARAM_DHCP_INDICATE;
23165 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23166 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23167 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23168 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23169 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23170 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23171 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23172 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23173 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23174 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23175 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23176 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23177 vdev_param[wmi_vdev_param_packet_powersave] =
23178 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23179 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23180 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23181 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23182 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23183 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23184 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23185 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23186 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23187 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23188 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23189 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23190 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23191 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23192 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23193 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23194 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23195 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23196 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23197 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23198 vdev_param[wmi_vdev_param_roam_fw_offload] =
23199 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23200 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23201 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23202 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23203 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23204 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23205 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23206 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23207 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23208 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23209 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23210 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23211 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23212 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23213 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23214 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23215 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23216 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23217 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23218 vdev_param[wmi_vdev_param_inactivity_cnt] =
23219 WMI_VDEV_PARAM_INACTIVITY_CNT;
23220 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23221 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23222 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23223 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23224 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23225 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23226 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23227 vdev_param[wmi_vdev_param_rx_leak_window] =
23228 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23229 vdev_param[wmi_vdev_param_stats_avg_factor] =
23230 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23231 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23232 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23233 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23234 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23235 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23236 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023237 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23238 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023239 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023240 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23241 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23242 WMI_VDEV_PARAM_HE_RANGE_EXT;
23243 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23244 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023245 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23246 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023247 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023248 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23249 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23250 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23251 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23252 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23253 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23254 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023255 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23256 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23257 vdev_param[wmi_vdev_param_rc_num_retries] =
23258 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23259 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23260 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23261 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23262 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23263 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23264 vdev_param[wmi_vdev_param_vht80_ratemask] =
23265 WMI_VDEV_PARAM_VHT80_RATEMASK;
23266 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23267 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23268 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023269 vdev_param[wmi_vdev_param_set_he_ltf] =
23270 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023271 vdev_param[wmi_vdev_param_disable_cabq] =
23272 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023273 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23274 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023275 vdev_param[wmi_vdev_param_set_ba_mode] =
23276 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023277 vdev_param[wmi_vdev_param_capabilities] =
23278 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023279 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23280 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023281}
23282#endif
23283
Govind Singh5eb51532016-03-09 11:34:12 +053023284/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023285 * populate_target_defines_tlv() - Populate target defines and params
23286 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023287 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023288 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023289 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023290#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023291static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023292{
Govind Singhe7f2f342016-05-23 12:12:52 +053023293 populate_pdev_param_tlv(wmi_handle->pdev_param);
23294 populate_vdev_param_tlv(wmi_handle->vdev_param);
23295}
23296#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023297static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23298{ }
23299#endif
23300
23301/**
Zhang Qian537fca62018-01-03 16:33:24 +080023302 * wmi_ocb_ut_attach() - Attach OCB test framework
23303 * @wmi_handle: wmi handle
23304 *
23305 * Return: None
23306 */
23307#ifdef WLAN_OCB_UT
23308void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23309#else
23310static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23311{
23312 return;
23313}
23314#endif
23315
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023316/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023317 * wmi_tlv_attach() - Attach TLV APIs
23318 *
23319 * Return: None
23320 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023321void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023322{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023323 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023324 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023325 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023326#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023327 /* Skip saving WMI_CMD_HDR and TLV HDR */
23328 wmi_handle->log_info.buf_offset_command = 8;
23329 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023330 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023331#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023332 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023333 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023334 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023335 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023336 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023337}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023338qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023339
23340/**
23341 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23342 *
23343 * Return: None
23344 */
23345void wmi_tlv_init(void)
23346{
23347 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23348}