blob: cecf75b5f99910ea6399e514ffce3e747f6680c6 [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}
666#else
667static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
668 uint32_t *targ_paramid,
669 uint32_t peer_param_id)
670{
671 switch (peer_param_id) {
672 case WMI_HOST_PEER_MIMO_PS_STATE:
673 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
674 break;
675 case WMI_HOST_PEER_AMPDU:
676 *targ_paramid = WMI_PEER_AMPDU;
677 break;
678 case WMI_HOST_PEER_AUTHORIZE:
679 *targ_paramid = WMI_PEER_AUTHORIZE;
680 break;
681 case WMI_HOST_PEER_CHWIDTH:
682 *targ_paramid = WMI_PEER_CHWIDTH;
683 break;
684 case WMI_HOST_PEER_NSS:
685 *targ_paramid = WMI_PEER_NSS;
686 break;
687 case WMI_HOST_PEER_USE_4ADDR:
688 *targ_paramid = WMI_PEER_USE_4ADDR;
689 break;
690 case WMI_HOST_PEER_MEMBERSHIP:
691 *targ_paramid = WMI_PEER_MEMBERSHIP;
692 break;
693 case WMI_HOST_PEER_USERPOS:
694 *targ_paramid = WMI_PEER_USERPOS;
695 break;
696 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
697 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
698 break;
699 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
700 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
701 break;
702 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
703 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
704 break;
705 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
706 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
707 break;
708 case WMI_HOST_PEER_PHYMODE:
709 *targ_paramid = WMI_PEER_PHYMODE;
710 break;
711 case WMI_HOST_PEER_USE_FIXED_PWR:
712 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
713 break;
714 case WMI_HOST_PEER_PARAM_FIXED_RATE:
715 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
716 break;
717 case WMI_HOST_PEER_SET_MU_WHITELIST:
718 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
719 break;
720 case WMI_HOST_PEER_SET_MAC_TX_RATE:
721 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
722 break;
723 case WMI_HOST_PEER_SET_MIN_TX_RATE:
724 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
725 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530726 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
727 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
728 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530729 case WMI_HOST_PEER_NSS_VHT160:
730 *targ_paramid = WMI_PEER_NSS_VHT160;
731 break;
732 case WMI_HOST_PEER_NSS_VHT80_80:
733 *targ_paramid = WMI_PEER_NSS_VHT80_80;
734 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530735 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
736 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
737 break;
738 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
739 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
740 break;
741 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
742 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
743 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530744 case WMI_HOST_PEER_PARAM_MU_ENABLE:
745 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
746 break;
747 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
748 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
749 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530750 default:
751 return QDF_STATUS_E_NOSUPPORT;
752 }
753
754 return QDF_STATUS_SUCCESS;
755}
756#endif
757/**
Govind Singh5eb51532016-03-09 11:34:12 +0530758 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530759 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530760 * @peer_addr: peer mac address
761 * @param : pointer to hold peer set parameter
762 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530763 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530764 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530765static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530766 uint8_t peer_addr[IEEE80211_ADDR_LEN],
767 struct peer_set_params *param)
768{
769 wmi_peer_set_param_cmd_fixed_param *cmd;
770 wmi_buf_t buf;
771 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530772 uint32_t param_id;
773
774 if (convert_host_peer_id_to_target_id_tlv(&param_id,
775 param->param_id) != QDF_STATUS_SUCCESS)
776 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530777
778 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
779 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530780 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530781 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530782 }
783 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
784 WMITLV_SET_HDR(&cmd->tlv_header,
785 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
786 WMITLV_GET_STRUCT_TLVLEN
787 (wmi_peer_set_param_cmd_fixed_param));
788 cmd->vdev_id = param->vdev_id;
789 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530790 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530791 cmd->param_value = param->param_value;
792 err = wmi_unified_cmd_send(wmi, buf,
793 sizeof(wmi_peer_set_param_cmd_fixed_param),
794 WMI_PEER_SET_PARAM_CMDID);
795 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530796 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530797 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530798 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530799 }
800
801 return 0;
802}
803
804/**
805 * send_vdev_up_cmd_tlv() - send vdev up command in fw
806 * @wmi: wmi handle
807 * @bssid: bssid
808 * @vdev_up_params: pointer to hold vdev up parameter
809 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530810 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530811 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530812static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530813 uint8_t bssid[IEEE80211_ADDR_LEN],
814 struct vdev_up_params *params)
815{
816 wmi_vdev_up_cmd_fixed_param *cmd;
817 wmi_buf_t buf;
818 int32_t len = sizeof(*cmd);
819
Govind Singhb53420c2016-03-09 14:32:57 +0530820 WMI_LOGD("%s: VDEV_UP", __func__);
821 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530822 params->vdev_id, params->assoc_id, bssid);
823 buf = wmi_buf_alloc(wmi, len);
824 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530825 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530826 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530827 }
828 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
829 WMITLV_SET_HDR(&cmd->tlv_header,
830 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
831 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
832 cmd->vdev_id = params->vdev_id;
833 cmd->vdev_assoc_id = params->assoc_id;
834 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
835 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530836 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530837 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530838 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530839 }
840
841 return 0;
842}
843
844/**
845 * send_peer_create_cmd_tlv() - send peer create command to fw
846 * @wmi: wmi handle
847 * @peer_addr: peer mac address
848 * @peer_type: peer type
849 * @vdev_id: vdev id
850 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530851 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530852 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530853static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530854 struct peer_create_params *param)
855{
856 wmi_peer_create_cmd_fixed_param *cmd;
857 wmi_buf_t buf;
858 int32_t len = sizeof(*cmd);
859
860 buf = wmi_buf_alloc(wmi, len);
861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530862 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530863 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530864 }
865 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
866 WMITLV_SET_HDR(&cmd->tlv_header,
867 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
868 WMITLV_GET_STRUCT_TLVLEN
869 (wmi_peer_create_cmd_fixed_param));
870 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
871 cmd->peer_type = param->peer_type;
872 cmd->vdev_id = param->vdev_id;
873
874 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530875 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530876 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530877 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530878 }
Govind Singhb53420c2016-03-09 14:32:57 +0530879 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530880 param->vdev_id);
881
882 return 0;
883}
884
885/**
Leo Changeee40872016-09-28 13:43:36 -0700886 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
887 * command to fw
888 * @wmi: wmi handle
889 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
890 *
891 * Return: 0 for success or error code
892 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700893static
Leo Changeee40872016-09-28 13:43:36 -0700894QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
895 struct rx_reorder_queue_setup_params *param)
896{
897 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
898 wmi_buf_t buf;
899 int32_t len = sizeof(*cmd);
900
901 buf = wmi_buf_alloc(wmi, len);
902 if (!buf) {
903 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
904 return QDF_STATUS_E_NOMEM;
905 }
906 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
907 WMITLV_SET_HDR(&cmd->tlv_header,
908 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
909 WMITLV_GET_STRUCT_TLVLEN
910 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
911 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
912 cmd->vdev_id = param->vdev_id;
913 cmd->tid = param->tid;
914 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
915 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
916 cmd->queue_no = param->queue_no;
917
918 if (wmi_unified_cmd_send(wmi, buf, len,
919 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
920 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
921 __func__);
922 qdf_nbuf_free(buf);
923 return QDF_STATUS_E_FAILURE;
924 }
925 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
926 param->peer_macaddr, param->vdev_id, param->tid);
927
928 return QDF_STATUS_SUCCESS;
929}
930
931/**
932 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
933 * command to fw
934 * @wmi: wmi handle
935 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
936 *
937 * Return: 0 for success or error code
938 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700939static
Leo Changeee40872016-09-28 13:43:36 -0700940QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
941 struct rx_reorder_queue_remove_params *param)
942{
943 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
944 wmi_buf_t buf;
945 int32_t len = sizeof(*cmd);
946
947 buf = wmi_buf_alloc(wmi, len);
948 if (!buf) {
949 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
950 return QDF_STATUS_E_NOMEM;
951 }
952 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
953 wmi_buf_data(buf);
954 WMITLV_SET_HDR(&cmd->tlv_header,
955 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
956 WMITLV_GET_STRUCT_TLVLEN
957 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
958 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
959 cmd->vdev_id = param->vdev_id;
960 cmd->tid_mask = param->peer_tid_bitmap;
961
962 if (wmi_unified_cmd_send(wmi, buf, len,
963 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
964 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
965 __func__);
966 qdf_nbuf_free(buf);
967 return QDF_STATUS_E_FAILURE;
968 }
969 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
970 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
971
972 return QDF_STATUS_SUCCESS;
973}
974
975/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530976 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
977 * @wmi_handle: wmi handle
978 * @param: pointer holding peer details
979 *
980 * Return: 0 for success or error code
981 */
982static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
983 struct peer_add_wds_entry_params *param)
984{
985 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
986 wmi_buf_t buf;
987 int len = sizeof(*cmd);
988
989 buf = wmi_buf_alloc(wmi_handle, len);
990 if (!buf) {
991 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
992 return QDF_STATUS_E_FAILURE;
993 }
994 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
995 WMITLV_SET_HDR(&cmd->tlv_header,
996 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
997 WMITLV_GET_STRUCT_TLVLEN
998 (wmi_peer_add_wds_entry_cmd_fixed_param));
999 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
1000 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001001 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1002 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301003
1004 return wmi_unified_cmd_send(wmi_handle, buf, len,
1005 WMI_PEER_ADD_WDS_ENTRY_CMDID);
1006}
1007
1008/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05301009 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301010 * @wmi_handle: wmi handle
1011 * @param: pointer holding peer details
1012 *
1013 * Return: 0 for success or error code
1014 */
1015static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1016 struct peer_del_wds_entry_params *param)
1017{
1018 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
1019 wmi_buf_t buf;
1020 int len = sizeof(*cmd);
1021
1022 buf = wmi_buf_alloc(wmi_handle, len);
1023 if (!buf) {
1024 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
1025 return QDF_STATUS_E_NOMEM;
1026 }
1027 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1028 WMITLV_SET_HDR(&cmd->tlv_header,
1029 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
1030 WMITLV_GET_STRUCT_TLVLEN
1031 (wmi_peer_remove_wds_entry_cmd_fixed_param));
1032 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001033 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301034 return wmi_unified_cmd_send(wmi_handle, buf, len,
1035 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
1036}
1037
1038/**
1039 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
1040 * @wmi_handle: wmi handle
1041 * @param: pointer holding peer details
1042 *
1043 * Return: 0 for success or error code
1044 */
1045static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1046 struct peer_update_wds_entry_params *param)
1047{
1048 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
1049 wmi_buf_t buf;
1050 int len = sizeof(*cmd);
1051
1052 buf = wmi_buf_alloc(wmi_handle, len);
1053 if (!buf) {
1054 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
1055 return QDF_STATUS_E_NOMEM;
1056 }
1057
1058 /* wmi_buf_alloc returns zeroed command buffer */
1059 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1060 WMITLV_SET_HDR(&cmd->tlv_header,
1061 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1062 WMITLV_GET_STRUCT_TLVLEN
1063 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001064 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1065 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301066 if (param->wds_macaddr)
1067 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1068 &cmd->wds_macaddr);
1069 if (param->peer_macaddr)
1070 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1071 &cmd->peer_macaddr);
1072 return wmi_unified_cmd_send(wmi_handle, buf, len,
1073 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1074}
1075
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001076/**
1077 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1078 * @wmi_handle: wmi handle
1079 * @param: pointer to get tpc config params
1080 *
1081 * Return: 0 for success or error code
1082 */
1083static QDF_STATUS
1084send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1085 uint32_t param)
1086{
1087 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1088 wmi_buf_t buf;
1089 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1090
1091 buf = wmi_buf_alloc(wmi_handle, len);
1092 if (!buf) {
1093 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1094 return QDF_STATUS_E_NOMEM;
1095 }
1096 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1097 WMITLV_SET_HDR(&cmd->tlv_header,
1098 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1099 WMITLV_GET_STRUCT_TLVLEN
1100 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1101
1102 cmd->param = param;
1103 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1104 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1105 WMI_LOGE("Send pdev get tpc config cmd failed");
1106 wmi_buf_free(buf);
1107 return QDF_STATUS_E_FAILURE;
1108
1109 }
1110 WMI_LOGD("%s:send success", __func__);
1111
1112 return QDF_STATUS_SUCCESS;
1113}
1114
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301115#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301116/**
Govind Singh5eb51532016-03-09 11:34:12 +05301117 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1118 * @wmi_handle: wmi handle
1119 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301120 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301121 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301122 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301123 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301124static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301125 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301126{
1127 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1128 wmi_buf_t buf;
1129 int32_t len = sizeof(*cmd);
1130
Govind Singhb53420c2016-03-09 14:32:57 +05301131 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301132
1133 buf = wmi_buf_alloc(wmi_handle, len);
1134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301135 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301136 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301137 }
1138
1139 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1140 WMITLV_SET_HDR(&cmd->tlv_header,
1141 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1142 WMITLV_GET_STRUCT_TLVLEN
1143 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301144 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301145 cmd->enable = value;
1146
1147 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1148 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301149 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301150 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301151 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301152 }
1153
1154 return 0;
1155}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301156#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301157
1158/**
1159 * send_pdev_utf_cmd_tlv() - send utf command to fw
1160 * @wmi_handle: wmi handle
1161 * @param: pointer to pdev_utf_params
1162 * @mac_id: mac id to have radio context
1163 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301164 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301165 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301166static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301167send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1168 struct pdev_utf_params *param,
1169 uint8_t mac_id)
1170{
1171 wmi_buf_t buf;
1172 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001173 /* if param->len is 0 no data is sent, return error */
1174 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301175 static uint8_t msgref = 1;
1176 uint8_t segNumber = 0, segInfo, numSegments;
1177 uint16_t chunk_len, total_bytes;
1178 uint8_t *bufpos;
1179 struct seg_hdr_info segHdrInfo;
1180
1181 bufpos = param->utf_payload;
1182 total_bytes = param->len;
1183 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1184 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1185 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1186
1187 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1188 numSegments++;
1189
1190 while (param->len) {
1191 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001192 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301193 else
1194 chunk_len = param->len;
1195
1196 buf = wmi_buf_alloc(wmi_handle,
1197 (chunk_len + sizeof(segHdrInfo) +
1198 WMI_TLV_HDR_SIZE));
1199 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301200 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301201 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301202 }
1203
1204 cmd = (uint8_t *) wmi_buf_data(buf);
1205
1206 segHdrInfo.len = total_bytes;
1207 segHdrInfo.msgref = msgref;
1208 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1209 segHdrInfo.segmentInfo = segInfo;
1210 segHdrInfo.pad = 0;
1211
Govind Singhb53420c2016-03-09 14:32:57 +05301212 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301213 " segHdrInfo.segmentInfo = %d",
1214 __func__, segHdrInfo.len, segHdrInfo.msgref,
1215 segHdrInfo.segmentInfo);
1216
Govind Singhb53420c2016-03-09 14:32:57 +05301217 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301218 "chunk len %d", __func__, total_bytes, segNumber,
1219 numSegments, chunk_len);
1220
1221 segNumber++;
1222
1223 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1224 (chunk_len + sizeof(segHdrInfo)));
1225 cmd += WMI_TLV_HDR_SIZE;
1226 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1227 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1228
1229 ret = wmi_unified_cmd_send(wmi_handle, buf,
1230 (chunk_len + sizeof(segHdrInfo) +
1231 WMI_TLV_HDR_SIZE),
1232 WMI_PDEV_UTF_CMDID);
1233
Govind Singh67922e82016-04-01 16:48:57 +05301234 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301235 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301236 wmi_buf_free(buf);
1237 break;
1238 }
1239
1240 param->len -= chunk_len;
1241 bufpos += chunk_len;
1242 }
1243
1244 msgref++;
1245
1246 return ret;
1247}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301248#ifdef CONFIG_MCL
1249static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1250 uint32_t host_param)
1251{
1252 return host_param;
1253}
1254#else
1255static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1256 uint32_t host_param)
1257{
1258 if (host_param < wmi_pdev_param_max)
1259 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301260
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301261 return WMI_UNAVAILABLE_PARAM;
1262}
1263#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301264/**
1265 * send_pdev_param_cmd_tlv() - set pdev parameters
1266 * @wmi_handle: wmi handle
1267 * @param: pointer to pdev parameter
1268 * @mac_id: radio context
1269 *
1270 * Return: 0 on success, errno on failure
1271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301272static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301273send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1274 struct pdev_params *param,
1275 uint8_t mac_id)
1276{
Govind Singh67922e82016-04-01 16:48:57 +05301277 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301278 wmi_pdev_set_param_cmd_fixed_param *cmd;
1279 wmi_buf_t buf;
1280 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301281 uint32_t pdev_param;
1282
1283 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1284 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1285 WMI_LOGW("%s: Unavailable param %d\n",
1286 __func__, param->param_id);
1287 return QDF_STATUS_E_INVAL;
1288 }
Govind Singh5eb51532016-03-09 11:34:12 +05301289
1290 buf = wmi_buf_alloc(wmi_handle, len);
1291 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301292 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301293 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301294 }
1295 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1296 WMITLV_SET_HDR(&cmd->tlv_header,
1297 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1298 WMITLV_GET_STRUCT_TLVLEN
1299 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301300 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301301 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301302 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301303 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301304 param->param_value);
1305 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1306 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301307 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301308 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301309 wmi_buf_free(buf);
1310 }
1311 return ret;
1312}
1313
1314/**
1315 * send_suspend_cmd_tlv() - WMI suspend function
1316 * @param wmi_handle : handle to WMI.
1317 * @param param : pointer to hold suspend parameter
1318 * @mac_id: radio context
1319 *
1320 * Return 0 on success and -ve on failure.
1321 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301322static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301323 struct suspend_params *param,
1324 uint8_t mac_id)
1325{
1326 wmi_pdev_suspend_cmd_fixed_param *cmd;
1327 wmi_buf_t wmibuf;
1328 uint32_t len = sizeof(*cmd);
1329 int32_t ret;
1330
1331 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001332 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301333 * PCIE reset so as to ensure that Host and target
1334 * states are in sync
1335 */
1336 wmibuf = wmi_buf_alloc(wmi_handle, len);
1337 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301338 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301339
1340 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1341 WMITLV_SET_HDR(&cmd->tlv_header,
1342 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1343 WMITLV_GET_STRUCT_TLVLEN
1344 (wmi_pdev_suspend_cmd_fixed_param));
1345 if (param->disable_target_intr)
1346 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1347 else
1348 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301349
1350 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1351
Govind Singh5eb51532016-03-09 11:34:12 +05301352 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1353 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301354 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301355 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301356 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301357 }
1358
1359 return ret;
1360}
1361
1362/**
1363 * send_resume_cmd_tlv() - WMI resume function
1364 * @param wmi_handle : handle to WMI.
1365 * @mac_id: radio context
1366 *
1367 * Return: 0 on success and -ve on failure.
1368 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301369static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301370 uint8_t mac_id)
1371{
1372 wmi_buf_t wmibuf;
1373 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301374 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301375
1376 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1377 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301378 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301379 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1380 WMITLV_SET_HDR(&cmd->tlv_header,
1381 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1382 WMITLV_GET_STRUCT_TLVLEN
1383 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301384 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301385 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1386 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301387 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301388 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301389 wmi_buf_free(wmibuf);
1390 }
1391
1392 return ret;
1393}
1394
Will Huang422ac9a2017-11-17 13:19:16 +08001395#ifdef FEATURE_WLAN_D0WOW
1396/**
1397 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1398 * @param wmi_handle: handle to WMI.
1399 * @mac_id: radio context
1400 *
1401 * Return: 0 on success and error code on failure.
1402 */
1403static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1404 uint8_t mac_id)
1405{
1406 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1407 wmi_buf_t buf;
1408 int32_t len;
1409 QDF_STATUS status;
1410
1411 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1412
1413 buf = wmi_buf_alloc(wmi_handle, len);
1414 if (!buf) {
1415 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1416 return QDF_STATUS_E_NOMEM;
1417 }
1418 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1419 WMITLV_SET_HDR(&cmd->tlv_header,
1420 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1421 WMITLV_GET_STRUCT_TLVLEN
1422 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1423
1424 cmd->enable = true;
1425
1426 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1427 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1428 if (QDF_IS_STATUS_ERROR(status))
1429 wmi_buf_free(buf);
1430
1431 return status;
1432}
1433
1434/**
1435 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1436 * @param wmi_handle: handle to WMI.
1437 * @mac_id: radio context
1438 *
1439 * Return: 0 on success and error code on failure.
1440 */
1441static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1442 uint8_t mac_id)
1443{
1444 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1445 wmi_buf_t buf;
1446 int32_t len;
1447 QDF_STATUS status;
1448
1449 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1450
1451 buf = wmi_buf_alloc(wmi_handle, len);
1452 if (!buf) {
1453 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1454 return QDF_STATUS_E_NOMEM;
1455 }
1456 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1457 WMITLV_SET_HDR(&cmd->tlv_header,
1458 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1459 WMITLV_GET_STRUCT_TLVLEN
1460 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1461
1462 cmd->enable = false;
1463
1464 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1465 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1466 if (QDF_IS_STATUS_ERROR(status))
1467 wmi_buf_free(buf);
1468
1469 return status;
1470}
1471#endif
1472
Govind Singh5eb51532016-03-09 11:34:12 +05301473/**
1474 * send_wow_enable_cmd_tlv() - WMI wow enable function
1475 * @param wmi_handle : handle to WMI.
1476 * @param param : pointer to hold wow enable parameter
1477 * @mac_id: radio context
1478 *
1479 * Return: 0 on success and -ve on failure.
1480 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301481static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301482 struct wow_cmd_params *param,
1483 uint8_t mac_id)
1484{
1485 wmi_wow_enable_cmd_fixed_param *cmd;
1486 wmi_buf_t buf;
1487 int32_t len;
1488 int32_t ret;
1489
1490 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1491
1492 buf = wmi_buf_alloc(wmi_handle, len);
1493 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301494 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1495 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301496 }
1497 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1498 WMITLV_SET_HDR(&cmd->tlv_header,
1499 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1500 WMITLV_GET_STRUCT_TLVLEN
1501 (wmi_wow_enable_cmd_fixed_param));
1502 cmd->enable = param->enable;
1503 if (param->can_suspend_link)
1504 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1505 else
1506 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001507 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301508
Govind Singhb53420c2016-03-09 14:32:57 +05301509 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301510 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1511 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1512
1513 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1514 WMI_WOW_ENABLE_CMDID);
1515 if (ret)
1516 wmi_buf_free(buf);
1517
1518 return ret;
1519}
1520
1521/**
1522 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301523 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301524 * @peer_addr: peer mac address
1525 * @param: pointer to ap_ps parameter structure
1526 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301527 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301528 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301529static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301530 uint8_t *peer_addr,
1531 struct ap_ps_params *param)
1532{
1533 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1534 wmi_buf_t buf;
1535 int32_t err;
1536
1537 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1538 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301539 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301540 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301541 }
1542 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1543 WMITLV_SET_HDR(&cmd->tlv_header,
1544 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1545 WMITLV_GET_STRUCT_TLVLEN
1546 (wmi_ap_ps_peer_cmd_fixed_param));
1547 cmd->vdev_id = param->vdev_id;
1548 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1549 cmd->param = param->param;
1550 cmd->value = param->value;
1551 err = wmi_unified_cmd_send(wmi_handle, buf,
1552 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1553 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301554 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301555 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301556 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301557 }
1558
1559 return 0;
1560}
1561
1562/**
1563 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301564 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301565 * @peer_addr: peer mac address
1566 * @param: pointer to sta_ps parameter structure
1567 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301568 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301569 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301570static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301571 struct sta_ps_params *param)
1572{
1573 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1574 wmi_buf_t buf;
1575 int32_t len = sizeof(*cmd);
1576
1577 buf = wmi_buf_alloc(wmi_handle, len);
1578 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301579 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301580 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301581 }
1582
1583 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1584 WMITLV_SET_HDR(&cmd->tlv_header,
1585 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1586 WMITLV_GET_STRUCT_TLVLEN
1587 (wmi_sta_powersave_param_cmd_fixed_param));
1588 cmd->vdev_id = param->vdev_id;
1589 cmd->param = param->param;
1590 cmd->value = param->value;
1591
1592 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1593 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301594 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301595 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301596 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301597 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301598 }
1599
1600 return 0;
1601}
1602
1603/**
1604 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301605 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001606 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301607 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301608 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301609 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301610static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301611 struct crash_inject *param)
1612{
1613 int32_t ret = 0;
1614 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1615 uint16_t len = sizeof(*cmd);
1616 wmi_buf_t buf;
1617
1618 buf = wmi_buf_alloc(wmi_handle, len);
1619 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301620 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301621 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301622 }
1623
1624 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1625 WMITLV_SET_HDR(&cmd->tlv_header,
1626 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1627 WMITLV_GET_STRUCT_TLVLEN
1628 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1629 cmd->type = param->type;
1630 cmd->delay_time_ms = param->delay_time_ms;
1631
1632 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1633 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301634 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301635 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301636 __func__, ret);
1637 wmi_buf_free(buf);
1638 }
1639
1640 return ret;
1641}
1642
Wen Gongca174012018-04-20 16:56:28 +08001643#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301644/**
1645 * send_dbglog_cmd_tlv() - set debug log level
1646 * @param wmi_handle : handle to WMI.
1647 * @param param : pointer to hold dbglog level parameter
1648 *
1649 * Return: 0 on success and -ve on failure.
1650 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301651 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301652send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1653 struct dbglog_params *dbglog_param)
1654{
1655 wmi_buf_t buf;
1656 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001657 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301658 int32_t i;
1659 int32_t len;
1660 int8_t *buf_ptr;
1661 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1662
Alok Kumar240afea2017-08-30 14:45:34 +05301663 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301664
1665 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1666 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1667 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1668 buf = wmi_buf_alloc(wmi_handle, len);
1669 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001670 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301671
1672 configmsg =
1673 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1674 buf_ptr = (int8_t *) configmsg;
1675 WMITLV_SET_HDR(&configmsg->tlv_header,
1676 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1677 WMITLV_GET_STRUCT_TLVLEN
1678 (wmi_debug_log_config_cmd_fixed_param));
1679 configmsg->dbg_log_param = dbglog_param->param;
1680 configmsg->value = dbglog_param->val;
1681 /* Filling in the data part of second tlv -- should
1682 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301683 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301684 sizeof
1685 (wmi_debug_log_config_cmd_fixed_param)
1686 + WMI_TLV_HDR_SIZE);
1687 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1688 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301689 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301690 if (dbglog_param->module_id_bitmap) {
1691 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1692 module_id_bitmap_array[i] =
1693 dbglog_param->module_id_bitmap[i];
1694 }
1695 }
1696
1697 status = wmi_unified_cmd_send(wmi_handle, buf,
1698 len, WMI_DBGLOG_CFG_CMDID);
1699
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001700 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301701 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301702
1703 return status;
1704}
Wen Gongca174012018-04-20 16:56:28 +08001705#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301706
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301707#ifdef CONFIG_MCL
1708static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1709 uint32_t host_param)
1710{
1711 return host_param;
1712}
1713#else
1714static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1715 uint32_t host_param)
1716{
1717 if (host_param < wmi_vdev_param_max)
1718 return wmi_handle->vdev_param[host_param];
1719
1720 return WMI_UNAVAILABLE_PARAM;
1721}
1722#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301723/**
1724 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1725 * @param wmi_handle : handle to WMI.
1726 * @param macaddr : MAC address
1727 * @param param : pointer to hold vdev set parameter
1728 *
1729 * Return: 0 on success and -ve on failure.
1730 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301731static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301732 struct vdev_set_params *param)
1733{
Govind Singh67922e82016-04-01 16:48:57 +05301734 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301735 wmi_vdev_set_param_cmd_fixed_param *cmd;
1736 wmi_buf_t buf;
1737 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301738 uint32_t vdev_param;
1739
1740 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1741 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1742 WMI_LOGW("%s:Vdev param %d not available", __func__,
1743 param->param_id);
1744 return QDF_STATUS_E_INVAL;
1745
1746 }
Govind Singh5eb51532016-03-09 11:34:12 +05301747
1748 buf = wmi_buf_alloc(wmi_handle, len);
1749 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301750 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301751 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301752 }
1753 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1754 WMITLV_SET_HDR(&cmd->tlv_header,
1755 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1756 WMITLV_GET_STRUCT_TLVLEN
1757 (wmi_vdev_set_param_cmd_fixed_param));
1758 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301759 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301760 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301761 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001762 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301763 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1764 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301765 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301766 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301767 wmi_buf_free(buf);
1768 }
1769
1770 return ret;
1771}
1772
1773/**
1774 * send_stats_request_cmd_tlv() - WMI request stats function
1775 * @param wmi_handle : handle to WMI.
1776 * @param macaddr : MAC address
1777 * @param param : pointer to hold stats request parameter
1778 *
1779 * Return: 0 on success and -ve on failure.
1780 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301781static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301782 uint8_t macaddr[IEEE80211_ADDR_LEN],
1783 struct stats_request_params *param)
1784{
Govind Singhd3156eb2016-02-26 17:50:39 +05301785 int32_t ret;
1786 wmi_request_stats_cmd_fixed_param *cmd;
1787 wmi_buf_t buf;
1788 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1789
1790 buf = wmi_buf_alloc(wmi_handle, len);
1791 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301792 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1793 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301794 }
1795
1796 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1797 WMITLV_SET_HDR(&cmd->tlv_header,
1798 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1799 WMITLV_GET_STRUCT_TLVLEN
1800 (wmi_request_stats_cmd_fixed_param));
1801 cmd->stats_id = param->stats_id;
1802 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301803 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1804 param->pdev_id);
1805 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001806
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301807 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1808 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001809
1810 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1811 WMI_REQUEST_STATS_CMDID);
1812
Govind Singhd3156eb2016-02-26 17:50:39 +05301813 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301814 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301815 wmi_buf_free(buf);
1816 }
1817
1818 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301819}
1820
Govind Singh87542482016-06-08 19:40:11 +05301821#ifdef CONFIG_WIN
1822/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001823 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301824 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001825 * @param PKTLOG_EVENT : packet log event
1826 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301827 *
1828 * Return: 0 on success and -ve on failure.
1829 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301830static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001831 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301832{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001833 int32_t ret;
1834 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1835 wmi_buf_t buf;
1836 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1837
1838 buf = wmi_buf_alloc(wmi_handle, len);
1839 if (!buf) {
1840 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1841 return -QDF_STATUS_E_NOMEM;
1842 }
1843
1844 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1845 WMITLV_SET_HDR(&cmd->tlv_header,
1846 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1847 WMITLV_GET_STRUCT_TLVLEN
1848 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1849 cmd->evlist = PKTLOG_EVENT;
1850 cmd->pdev_id = mac_id;
1851 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1852 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1853 if (ret) {
1854 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1855 wmi_buf_free(buf);
1856 }
1857
1858 return ret;
1859}
1860
1861/**
1862 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1863 * @param wmi_handle : handle to WMI.
1864 * @mac_id: mac id to have radio context
1865 *
1866 * Return: 0 on success and -ve on failure.
1867 */
1868static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001869 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001870{
1871 int32_t ret;
1872 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1873 wmi_buf_t buf;
1874 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1875
1876 buf = wmi_buf_alloc(wmi_handle, len);
1877 if (!buf) {
1878 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1879 return -QDF_STATUS_E_NOMEM;
1880 }
1881
1882 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1883 WMITLV_SET_HDR(&cmd->tlv_header,
1884 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1885 WMITLV_GET_STRUCT_TLVLEN
1886 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1887 cmd->pdev_id = mac_id;
1888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1889 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1890 if (ret) {
1891 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1892 wmi_buf_free(buf);
1893 }
1894
1895 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301896}
1897#else
Govind Singh5eb51532016-03-09 11:34:12 +05301898/**
Keyur Parekhde522342017-08-18 14:01:05 -07001899 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1900 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301901 * @param wmi_handle : handle to WMI.
1902 * @param macaddr : MAC address
1903 * @param param : pointer to hold stats request parameter
1904 *
1905 * Return: 0 on success and -ve on failure.
1906 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301907static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301908 uint8_t macaddr[IEEE80211_ADDR_LEN],
1909 struct packet_enable_params *param)
1910{
1911 return 0;
1912}
Keyur Parekhde522342017-08-18 14:01:05 -07001913/**
1914 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1915 * packet-log
1916 * @param wmi_handle : handle to WMI.
1917 * @mac_id: mac id to have radio context
1918 *
1919 * Return: 0 on success and -ve on failure.
1920 */
1921static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1922 uint8_t mac_id)
1923{
1924 return 0;
1925}
Govind Singh87542482016-06-08 19:40:11 +05301926#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301927
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301928#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1929/**
1930 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1931 * sync time between bwtween host and firmware
1932 * @param wmi_handle : handle to WMI.
1933 *
1934 * Return: None
1935 */
1936static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1937{
1938 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001939 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301940 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1941 int32_t len;
1942 qdf_time_t time_ms;
1943
1944 len = sizeof(*time_stamp);
1945 buf = wmi_buf_alloc(wmi_handle, len);
1946
1947 if (!buf) {
1948 WMI_LOGP(FL("wmi_buf_alloc failed"));
1949 return;
1950 }
1951 time_stamp =
1952 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1953 (wmi_buf_data(buf));
1954 WMITLV_SET_HDR(&time_stamp->tlv_header,
1955 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1956 WMITLV_GET_STRUCT_TLVLEN(
1957 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1958
1959 time_ms = qdf_get_time_of_the_day_ms();
1960 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1961 time_stamp->time_stamp_low = time_ms &
1962 WMI_FW_TIME_STAMP_LOW_MASK;
1963 /*
1964 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1965 * wont exceed 27 bit
1966 */
1967 time_stamp->time_stamp_high = 0;
1968 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1969 time_stamp->mode, time_stamp->time_stamp_low,
1970 time_stamp->time_stamp_high);
1971
1972 status = wmi_unified_cmd_send(wmi_handle, buf,
1973 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1974 if (status) {
1975 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1976 wmi_buf_free(buf);
1977 }
1978
1979}
1980
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301981#ifdef WLAN_SUPPORT_FILS
1982/**
1983 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1984 * @wmi_handle: wmi handle
1985 * @evt_buf: pointer to event buffer
1986 * @vdev_id: pointer to hold vdev id
1987 *
1988 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1989 */
1990static QDF_STATUS
1991extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1992 void *evt_buf, uint32_t *vdev_id)
1993{
1994 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1995 wmi_host_swfda_event_fixed_param *swfda_event;
1996
1997 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1998 if (!param_buf) {
1999 WMI_LOGE("Invalid swfda event buffer");
2000 return QDF_STATUS_E_INVAL;
2001 }
2002 swfda_event = param_buf->fixed_param;
2003 *vdev_id = swfda_event->vdev_id;
2004
2005 return QDF_STATUS_SUCCESS;
2006}
2007
2008/**
2009 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
2010 * @wmi_handle: wmi handle
2011 * @param: pointer to hold FILS discovery enable param
2012 *
2013 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
2014 */
2015static QDF_STATUS
2016send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
2017 struct config_fils_params *param)
2018{
2019 wmi_enable_fils_cmd_fixed_param *cmd;
2020 wmi_buf_t buf;
2021 QDF_STATUS status;
2022 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
2023
2024 buf = wmi_buf_alloc(wmi_handle, len);
2025 if (!buf) {
2026 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2027 return QDF_STATUS_E_NOMEM;
2028 }
2029 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
2030 WMITLV_SET_HDR(&cmd->tlv_header,
2031 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
2032 WMITLV_GET_STRUCT_TLVLEN(
2033 wmi_enable_fils_cmd_fixed_param));
2034 cmd->vdev_id = param->vdev_id;
2035 cmd->fd_period = param->fd_period;
2036 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
2037 param->fd_period, param->vdev_id);
2038
2039 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2040 WMI_ENABLE_FILS_CMDID);
2041 if (status != QDF_STATUS_SUCCESS) {
2042 wmi_buf_free(buf);
2043 return QDF_STATUS_E_FAILURE;
2044 }
2045
2046 return QDF_STATUS_SUCCESS;
2047}
2048
2049/**
2050 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
2051 * @wmi_handle: wmi handle
2052 * @param: pointer to hold FD send cmd parameter
2053 *
2054 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
2055 */
2056static QDF_STATUS
2057send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
2058 struct fd_params *param)
2059{
2060 QDF_STATUS ret;
2061 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2062 wmi_buf_t wmi_buf;
2063 qdf_dma_addr_t dma_addr;
2064
2065 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2066 if (!wmi_buf) {
2067 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2068 return QDF_STATUS_E_NOMEM;
2069 }
2070 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2071 WMITLV_SET_HDR(&cmd->tlv_header,
2072 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2073 WMITLV_GET_STRUCT_TLVLEN(
2074 wmi_fd_send_from_host_cmd_fixed_param));
2075 cmd->vdev_id = param->vdev_id;
2076 cmd->data_len = qdf_nbuf_len(param->wbuf);
2077 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2078 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2079 cmd->frame_ctrl = param->frame_ctrl;
2080
2081 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2082 WMI_PDEV_SEND_FD_CMDID);
2083 if (ret != QDF_STATUS_SUCCESS) {
2084 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2085 __func__, ret);
2086 wmi_buf_free(wmi_buf);
2087 }
2088
2089 return ret;
2090}
2091#endif /* WLAN_SUPPORT_FILS */
2092
Sathish Kumarfd347372017-02-13 12:29:09 +05302093static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302094 struct beacon_params *param)
2095{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302096 QDF_STATUS ret;
2097 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2098 wmi_buf_t wmi_buf;
2099 qdf_dma_addr_t dma_addr;
2100 uint32_t dtim_flag = 0;
2101
2102 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2103 if (!wmi_buf) {
2104 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2105 return QDF_STATUS_E_NOMEM;
2106 }
2107 if (param->is_dtim_count_zero) {
2108 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2109 if (param->is_bitctl_reqd) {
2110 /* deliver CAB traffic in next DTIM beacon */
2111 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2112 }
2113 }
2114 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2115 WMITLV_SET_HDR(&cmd->tlv_header,
2116 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2117 WMITLV_GET_STRUCT_TLVLEN
2118 (wmi_bcn_send_from_host_cmd_fixed_param));
2119 cmd->vdev_id = param->vdev_id;
2120 cmd->data_len = qdf_nbuf_len(param->wbuf);
2121 cmd->frame_ctrl = param->frame_ctrl;
2122 cmd->dtim_flag = dtim_flag;
2123 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2124 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2125#if defined(HTT_PADDR64)
2126 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2127#endif
2128 cmd->bcn_antenna = param->bcn_txant;
2129
2130 ret = wmi_unified_cmd_send(wmi_handle,
2131 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2132 if (ret != QDF_STATUS_SUCCESS) {
2133 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2134 wmi_buf_free(wmi_buf);
2135 }
2136
2137 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302138}
2139
2140/**
2141 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2142 * @param wmi_handle : handle to WMI.
2143 * @param param : pointer to hold beacon send cmd parameter
2144 *
2145 * Return: 0 on success and -ve on failure.
2146 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302147static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302148 struct beacon_tmpl_params *param)
2149{
2150 int32_t ret;
2151 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2152 wmi_bcn_prb_info *bcn_prb_info;
2153 wmi_buf_t wmi_buf;
2154 uint8_t *buf_ptr;
2155 uint32_t wmi_buf_len;
2156
2157 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2158 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2159 param->tmpl_len_aligned;
2160 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2161 if (!wmi_buf) {
2162 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2163 return QDF_STATUS_E_NOMEM;
2164 }
2165 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2166 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2167 WMITLV_SET_HDR(&cmd->tlv_header,
2168 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2169 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2170 cmd->vdev_id = param->vdev_id;
2171 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302172 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2173 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302174 cmd->buf_len = param->tmpl_len;
2175 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2176
2177 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2178 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2179 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2180 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2181 bcn_prb_info->caps = 0;
2182 bcn_prb_info->erp = 0;
2183 buf_ptr += sizeof(wmi_bcn_prb_info);
2184
2185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2186 buf_ptr += WMI_TLV_HDR_SIZE;
2187 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2188
2189 ret = wmi_unified_cmd_send(wmi_handle,
2190 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2191 if (ret) {
2192 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2193 wmi_buf_free(wmi_buf);
2194 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302195
Govind Singh87542482016-06-08 19:40:11 +05302196 return 0;
2197}
Govind Singh5eb51532016-03-09 11:34:12 +05302198
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302199#ifdef CONFIG_MCL
2200static inline void copy_peer_flags_tlv(
2201 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2202 struct peer_assoc_params *param)
2203{
2204 cmd->peer_flags = param->peer_flags;
2205}
2206#else
2207static inline void copy_peer_flags_tlv(
2208 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2209 struct peer_assoc_params *param)
2210{
2211 /*
2212 * The target only needs a subset of the flags maintained in the host.
2213 * Just populate those flags and send it down
2214 */
2215 cmd->peer_flags = 0;
2216
2217 /*
2218 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2219 */
2220 if (param->is_wme_set) {
2221
2222 if (param->qos_flag)
2223 cmd->peer_flags |= WMI_PEER_QOS;
2224 if (param->apsd_flag)
2225 cmd->peer_flags |= WMI_PEER_APSD;
2226 if (param->ht_flag)
2227 cmd->peer_flags |= WMI_PEER_HT;
2228 if (param->bw_40)
2229 cmd->peer_flags |= WMI_PEER_40MHZ;
2230 if (param->bw_80)
2231 cmd->peer_flags |= WMI_PEER_80MHZ;
2232 if (param->bw_160)
2233 cmd->peer_flags |= WMI_PEER_160MHZ;
2234
2235 /* Typically if STBC is enabled for VHT it should be enabled
2236 * for HT as well
2237 **/
2238 if (param->stbc_flag)
2239 cmd->peer_flags |= WMI_PEER_STBC;
2240
2241 /* Typically if LDPC is enabled for VHT it should be enabled
2242 * for HT as well
2243 **/
2244 if (param->ldpc_flag)
2245 cmd->peer_flags |= WMI_PEER_LDPC;
2246
2247 if (param->static_mimops_flag)
2248 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2249 if (param->dynamic_mimops_flag)
2250 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2251 if (param->spatial_mux_flag)
2252 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2253 if (param->vht_flag)
2254 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002255 if (param->he_flag)
2256 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302257 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002258
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302259 if (param->is_pmf_enabled)
2260 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302261 /*
2262 * Suppress authorization for all AUTH modes that need 4-way handshake
2263 * (during re-association).
2264 * Authorization will be done for these modes on key installation.
2265 */
2266 if (param->auth_flag)
2267 cmd->peer_flags |= WMI_PEER_AUTH;
2268 if (param->need_ptk_4_way)
2269 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2270 else
2271 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2272 if (param->need_gtk_2_way)
2273 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2274 /* safe mode bypass the 4-way handshake */
2275 if (param->safe_mode_enabled)
2276 cmd->peer_flags &=
2277 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2278 /* Disable AMSDU for station transmit, if user configures it */
2279 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2280 * it
2281 * if (param->amsdu_disable) Add after FW support
2282 **/
2283
2284 /* Target asserts if node is marked HT and all MCS is set to 0.
2285 * Mark the node as non-HT if all the mcs rates are disabled through
2286 * iwpriv
2287 **/
2288 if (param->peer_ht_rates.num_rates == 0)
2289 cmd->peer_flags &= ~WMI_PEER_HT;
2290}
2291#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302292
2293#ifdef CONFIG_MCL
2294static inline void copy_peer_mac_addr_tlv(
2295 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2296 struct peer_assoc_params *param)
2297{
2298 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2299 sizeof(param->peer_macaddr));
2300}
2301#else
2302static inline void copy_peer_mac_addr_tlv(
2303 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2304 struct peer_assoc_params *param)
2305{
2306 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2307}
2308#endif
2309
Govind Singh5eb51532016-03-09 11:34:12 +05302310/**
2311 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2312 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302313 * @param param : pointer to peer assoc parameter
2314 *
2315 * Return: 0 on success and -ve on failure.
2316 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302317static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302318 struct peer_assoc_params *param)
2319{
Govind Singhd3156eb2016-02-26 17:50:39 +05302320 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2321 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002322 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302323 wmi_buf_t buf;
2324 int32_t len;
2325 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302326 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302327 uint32_t peer_legacy_rates_align;
2328 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002329 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302330
2331
2332 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2333 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302334
2335 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002336 (peer_legacy_rates_align * sizeof(uint8_t)) +
2337 WMI_TLV_HDR_SIZE +
2338 (peer_ht_rates_align * sizeof(uint8_t)) +
2339 sizeof(wmi_vht_rate_set) +
2340 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2341 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302342
2343 buf = wmi_buf_alloc(wmi_handle, len);
2344 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302345 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302346 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302347 }
2348
2349 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2350 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2351 WMITLV_SET_HDR(&cmd->tlv_header,
2352 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2353 WMITLV_GET_STRUCT_TLVLEN
2354 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302355
Govind Singhd3156eb2016-02-26 17:50:39 +05302356 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302357
Govind Singhd3156eb2016-02-26 17:50:39 +05302358 cmd->peer_new_assoc = param->peer_new_assoc;
2359 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302360
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302361 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302362 copy_peer_mac_addr_tlv(cmd, param);
2363
Govind Singhd3156eb2016-02-26 17:50:39 +05302364 cmd->peer_rate_caps = param->peer_rate_caps;
2365 cmd->peer_caps = param->peer_caps;
2366 cmd->peer_listen_intval = param->peer_listen_intval;
2367 cmd->peer_ht_caps = param->peer_ht_caps;
2368 cmd->peer_max_mpdu = param->peer_max_mpdu;
2369 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302370 cmd->peer_vht_caps = param->peer_vht_caps;
2371 cmd->peer_phymode = param->peer_phymode;
2372
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002373 /* Update 11ax capabilities */
2374 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2375 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002376 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2377 sizeof(param->peer_he_cap_phyinfo));
2378 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2379 sizeof(param->peer_ppet));
2380
Govind Singhd3156eb2016-02-26 17:50:39 +05302381 /* Update peer legacy rate information */
2382 buf_ptr += sizeof(*cmd);
2383 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302384 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302385 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302386 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302387 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302388 param->peer_legacy_rates.num_rates);
2389
2390 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002391 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302392 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302393 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302394 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302395 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302396 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302397 param->peer_ht_rates.num_rates);
2398
2399 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002400 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2402 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2403
2404 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302405
2406 /* Update bandwidth-NSS mapping */
2407 cmd->peer_bw_rxnss_override = 0;
2408 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2409
Govind Singhd3156eb2016-02-26 17:50:39 +05302410 mcs = (wmi_vht_rate_set *) buf_ptr;
2411 if (param->vht_capable) {
2412 mcs->rx_max_rate = param->rx_max_rate;
2413 mcs->rx_mcs_set = param->rx_mcs_set;
2414 mcs->tx_max_rate = param->tx_max_rate;
2415 mcs->tx_mcs_set = param->tx_mcs_set;
2416 }
2417
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002418 /* HE Rates */
2419 cmd->peer_he_mcs = param->peer_he_mcs_count;
2420 buf_ptr += sizeof(wmi_vht_rate_set);
2421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2422 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2423 buf_ptr += WMI_TLV_HDR_SIZE;
2424
2425 /* Loop through the HE rate set */
2426 for (i = 0; i < param->peer_he_mcs_count; i++) {
2427 he_mcs = (wmi_he_rate_set *) buf_ptr;
2428 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2429 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2430
2431 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2432 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2433 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2434 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2435 buf_ptr += sizeof(wmi_he_rate_set);
2436 }
2437
2438
Govind Singhb53420c2016-03-09 14:32:57 +05302439 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302440 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2441 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002442 "cmd->peer_vht_caps %x "
2443 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302444 "HE phy %x %x %x "
2445 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302446 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2447 cmd->peer_rate_caps, cmd->peer_caps,
2448 cmd->peer_listen_intval, cmd->peer_ht_caps,
2449 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2450 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002451 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2452 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302453 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2454 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302455
2456 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2457 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302458 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302459 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302460 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302461 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302462 }
2463
2464 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302465}
2466
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302467/* copy_scan_notify_events() - Helper routine to copy scan notify events
2468 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302469static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302470 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302471 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302472{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302473
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302474 /* Scan events subscription */
2475 if (param->scan_ev_started)
2476 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2477 if (param->scan_ev_completed)
2478 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2479 if (param->scan_ev_bss_chan)
2480 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2481 if (param->scan_ev_foreign_chan)
2482 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2483 if (param->scan_ev_dequeued)
2484 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2485 if (param->scan_ev_preempted)
2486 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2487 if (param->scan_ev_start_failed)
2488 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2489 if (param->scan_ev_restarted)
2490 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2491 if (param->scan_ev_foreign_chn_exit)
2492 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2493 if (param->scan_ev_suspended)
2494 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2495 if (param->scan_ev_resumed)
2496 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302497
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302498 /** Set scan control flags */
2499 cmd->scan_ctrl_flags = 0;
2500 if (param->scan_f_passive)
2501 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2502 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302503 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302504 if (param->scan_f_promisc_mode)
2505 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2506 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302507 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302508 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302509 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302510 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302511 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302512 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302513 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302514 if (param->scan_f_ofdm_rates)
2515 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2516 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302517 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302518 if (param->scan_f_filter_prb_req)
2519 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2520 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302521 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302522 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302523 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302524 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302525 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302526 if (param->scan_f_force_active_dfs_chn)
2527 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2528 if (param->scan_f_add_tpc_ie_in_probe)
2529 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2530 if (param->scan_f_add_ds_ie_in_probe)
2531 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2532 if (param->scan_f_add_spoofed_mac_in_probe)
2533 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2534 if (param->scan_f_add_rand_seq_in_probe)
2535 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2536 if (param->scan_f_en_ie_whitelist_in_probe)
2537 cmd->scan_ctrl_flags |=
2538 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302539
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302540 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2541 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2542 param->adaptive_dwell_time_mode);
2543}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302544
2545/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302546static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302547 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302548{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302549 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302550}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302551
Govind Singh5eb51532016-03-09 11:34:12 +05302552/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302553 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2554 * @mac: random mac addr
2555 * @mask: random mac mask
2556 * @mac_addr: wmi random mac
2557 * @mac_mask: wmi random mac mask
2558 *
2559 * Return None.
2560 */
2561static inline
2562void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2563 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2564{
2565 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2566 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2567}
2568
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302569/*
2570 * wmi_fill_vendor_oui() - fill vendor OUIs
2571 * @buf_ptr: pointer to wmi tlv buffer
2572 * @num_vendor_oui: number of vendor OUIs to be filled
2573 * @param_voui: pointer to OUI buffer
2574 *
2575 * This function populates the wmi tlv buffer when vendor specific OUIs are
2576 * present.
2577 *
2578 * Return: None
2579 */
2580static inline
2581void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2582 uint32_t *pvoui)
2583{
2584 wmi_vendor_oui *voui = NULL;
2585 uint32_t i;
2586
2587 voui = (wmi_vendor_oui *)buf_ptr;
2588
2589 for (i = 0; i < num_vendor_oui; i++) {
2590 WMITLV_SET_HDR(&voui[i].tlv_header,
2591 WMITLV_TAG_STRUC_wmi_vendor_oui,
2592 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2593 voui[i].oui_type_subtype = pvoui[i];
2594 }
2595}
2596
2597/*
2598 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2599 * @ie_bitmap: output pointer to ie bit map in cmd
2600 * @num_vendor_oui: output pointer to num vendor OUIs
2601 * @ie_whitelist: input parameter
2602 *
2603 * This function populates the IE whitelist attrs of scan, pno and
2604 * scan oui commands for ie_whitelist parameter.
2605 *
2606 * Return: None
2607 */
2608static inline
2609void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2610 uint32_t *num_vendor_oui,
2611 struct probe_req_whitelist_attr *ie_whitelist)
2612{
2613 uint32_t i = 0;
2614
2615 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2616 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2617
2618 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2619}
2620
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302621/**
Govind Singh5eb51532016-03-09 11:34:12 +05302622 * send_scan_start_cmd_tlv() - WMI scan start function
2623 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302624 * @param param : pointer to hold scan start cmd parameter
2625 *
2626 * Return: 0 on success and -ve on failure.
2627 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302628static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302629 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302630{
Govind Singhd3156eb2016-02-26 17:50:39 +05302631 int32_t ret = 0;
2632 int32_t i;
2633 wmi_buf_t wmi_buf;
2634 wmi_start_scan_cmd_fixed_param *cmd;
2635 uint8_t *buf_ptr;
2636 uint32_t *tmp_ptr;
2637 wmi_ssid *ssid = NULL;
2638 wmi_mac_addr *bssid;
2639 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302640 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302641 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302642 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302643
2644 /* Length TLV placeholder for array of uint32_t */
2645 len += WMI_TLV_HDR_SIZE;
2646 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302647 if (params->chan_list.num_chan)
2648 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302649
2650 /* Length TLV placeholder for array of wmi_ssid structures */
2651 len += WMI_TLV_HDR_SIZE;
2652 if (params->num_ssids)
2653 len += params->num_ssids * sizeof(wmi_ssid);
2654
2655 /* Length TLV placeholder for array of wmi_mac_addr structures */
2656 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302657 if (params->num_bssid)
2658 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302659
2660 /* Length TLV placeholder for array of bytes */
2661 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302662 if (params->extraie.len)
2663 extraie_len_with_pad =
2664 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002665 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302666
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302667 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2668 if (ie_whitelist->num_vendor_oui)
2669 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2670
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302671 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2672 if (params->scan_f_wide_band)
2673 phymode_roundup =
2674 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2675 sizeof(uint32_t));
2676 len += phymode_roundup;
2677
Govind Singhd3156eb2016-02-26 17:50:39 +05302678 /* Allocate the memory */
2679 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2680 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302681 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302682 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302683 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302684 }
2685 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2686 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2687 WMITLV_SET_HDR(&cmd->tlv_header,
2688 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2689 WMITLV_GET_STRUCT_TLVLEN
2690 (wmi_start_scan_cmd_fixed_param));
2691
2692 cmd->scan_id = params->scan_id;
2693 cmd->scan_req_id = params->scan_req_id;
2694 cmd->vdev_id = params->vdev_id;
2695 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302696
2697 copy_scan_event_cntrl_flags(cmd, params);
2698
Govind Singhd3156eb2016-02-26 17:50:39 +05302699 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002700 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302701 cmd->dwell_time_passive = params->dwell_time_passive;
2702 cmd->min_rest_time = params->min_rest_time;
2703 cmd->max_rest_time = params->max_rest_time;
2704 cmd->repeat_probe_time = params->repeat_probe_time;
2705 cmd->probe_spacing_time = params->probe_spacing_time;
2706 cmd->idle_time = params->idle_time;
2707 cmd->max_scan_time = params->max_scan_time;
2708 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302709 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302710 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302711 cmd->num_bssid = params->num_bssid;
2712 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302713 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302714 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302715 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2716
2717 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2718
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302719 if (params->scan_random.randomize)
2720 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2721 params->scan_random.mac_mask,
2722 &cmd->mac_addr,
2723 &cmd->mac_mask);
2724
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302725 if (ie_whitelist->white_list)
2726 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2727 &cmd->num_vendor_oui,
2728 ie_whitelist);
2729
Govind Singhd3156eb2016-02-26 17:50:39 +05302730 buf_ptr += sizeof(*cmd);
2731 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302732 for (i = 0; i < params->chan_list.num_chan; ++i)
2733 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302734
2735 WMITLV_SET_HDR(buf_ptr,
2736 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302737 (params->chan_list.num_chan * sizeof(uint32_t)));
2738 buf_ptr += WMI_TLV_HDR_SIZE +
2739 (params->chan_list.num_chan * sizeof(uint32_t));
2740
Govind Singh4eacd2b2016-03-07 14:24:22 +05302741 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302742 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302743 goto error;
2744 }
2745
2746 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2747 (params->num_ssids * sizeof(wmi_ssid)));
2748
2749 if (params->num_ssids) {
2750 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2751 for (i = 0; i < params->num_ssids; ++i) {
2752 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302753 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302754 params->ssid[i].length);
2755 ssid++;
2756 }
2757 }
2758 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2759
2760 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2761 (params->num_bssid * sizeof(wmi_mac_addr)));
2762 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302763
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302764 if (params->num_bssid) {
2765 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302766 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2767 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302768 bssid++;
2769 }
2770 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302771
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302772 buf_ptr += WMI_TLV_HDR_SIZE +
2773 (params->num_bssid * sizeof(wmi_mac_addr));
2774
2775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2776 if (params->extraie.len)
2777 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2778 params);
2779
2780 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302781
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302782 /* probe req ie whitelisting */
2783 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2784 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2785
2786 buf_ptr += WMI_TLV_HDR_SIZE;
2787
2788 if (cmd->num_vendor_oui) {
2789 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2790 ie_whitelist->voui);
2791 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2792 }
2793
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302794 /* Add phy mode TLV if it's a wide band scan */
2795 if (params->scan_f_wide_band) {
2796 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2797 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2798 for (i = 0; i < params->chan_list.num_chan; ++i)
2799 buf_ptr[i] =
2800 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2801 buf_ptr += phymode_roundup;
2802 } else {
2803 /* Add ZERO legth phy mode TLV */
2804 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2805 }
2806
Santosh Anbu1e11b472018-03-07 15:33:27 +05302807 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002808 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302809 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302810 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302811 wmi_buf_free(wmi_buf);
2812 }
2813 return ret;
2814error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302815 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302816 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302817}
2818
2819/**
2820 * send_scan_stop_cmd_tlv() - WMI scan start function
2821 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302822 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302823 *
2824 * Return: 0 on success and -ve on failure.
2825 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302826static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302827 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302828{
Govind Singhd3156eb2016-02-26 17:50:39 +05302829 wmi_stop_scan_cmd_fixed_param *cmd;
2830 int ret;
2831 int len = sizeof(*cmd);
2832 wmi_buf_t wmi_buf;
2833
2834 /* Allocate the memory */
2835 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2836 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302837 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302838 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302839 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302840 goto error;
2841 }
2842
2843 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2844 WMITLV_SET_HDR(&cmd->tlv_header,
2845 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2846 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2847 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302848 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302849 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302850 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2851 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302852 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302853 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2854 /* Cancelling all scans */
2855 cmd->req_type = WMI_SCAN_STOP_ALL;
2856 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2857 /* Cancelling VAP scans */
2858 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2859 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2860 /* Cancelling specific scan */
2861 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302862 } else {
2863 WMI_LOGE("%s: Invalid Command : ", __func__);
2864 wmi_buf_free(wmi_buf);
2865 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302866 }
2867
Santosh Anbu1e11b472018-03-07 15:33:27 +05302868 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002869 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302870 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302871 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302872 wmi_buf_free(wmi_buf);
2873 }
2874
2875error:
2876 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302877}
2878
Govind Singh87542482016-06-08 19:40:11 +05302879#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302880/**
2881 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2882 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302883 * @param param : pointer to hold scan channel list parameter
2884 *
2885 * Return: 0 on success and -ve on failure.
2886 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302887static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302888 struct scan_chan_list_params *chan_list)
2889{
2890 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302891 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302892 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302893 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302894 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302895 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302896 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2897
2898 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2899 buf = wmi_buf_alloc(wmi_handle, len);
2900 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302901 WMI_LOGE("Failed to allocate memory");
2902 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302903 goto end;
2904 }
2905
2906 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2907 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2908 WMITLV_SET_HDR(&cmd->tlv_header,
2909 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2910 WMITLV_GET_STRUCT_TLVLEN
2911 (wmi_scan_chan_list_cmd_fixed_param));
2912
Govind Singhb53420c2016-03-09 14:32:57 +05302913 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302914
2915 cmd->num_scan_chans = chan_list->num_scan_chans;
2916 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2917 WMITLV_TAG_ARRAY_STRUC,
2918 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302919 chan_info = (wmi_channel_param *)
2920 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302921 tchan_info = chan_list->chan_info;
2922
2923 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2924 WMITLV_SET_HDR(&chan_info->tlv_header,
2925 WMITLV_TAG_STRUC_wmi_channel,
2926 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2927 chan_info->mhz = tchan_info->mhz;
2928 chan_info->band_center_freq1 =
2929 tchan_info->band_center_freq1;
2930 chan_info->band_center_freq2 =
2931 tchan_info->band_center_freq2;
2932 chan_info->info = tchan_info->info;
2933 chan_info->reg_info_1 = tchan_info->reg_info_1;
2934 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302935 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302936
2937 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2938 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2939 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2940 tchan_info++;
2941 chan_info++;
2942 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302943 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2944 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302945
Anish Natarajdd855152017-03-20 12:49:08 +05302946 qdf_status = wmi_unified_cmd_send(wmi_handle,
2947 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302948
Govind Singh67922e82016-04-01 16:48:57 +05302949 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302950 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302951 wmi_buf_free(buf);
2952 }
Govind Singh67922e82016-04-01 16:48:57 +05302953
Govind Singhd3156eb2016-02-26 17:50:39 +05302954end:
Govind Singhb53420c2016-03-09 14:32:57 +05302955 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302956}
Govind Singh87542482016-06-08 19:40:11 +05302957#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302958static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302959 struct scan_chan_list_params *chan_list)
2960{
2961 wmi_buf_t buf;
2962 QDF_STATUS qdf_status;
2963 wmi_scan_chan_list_cmd_fixed_param *cmd;
2964 int i;
2965 uint8_t *buf_ptr;
2966 wmi_channel *chan_info;
2967 struct channel_param *tchan_info;
2968 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302969
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302970 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302971 buf = wmi_buf_alloc(wmi_handle, len);
2972 if (!buf) {
2973 WMI_LOGE("Failed to allocate memory");
2974 qdf_status = QDF_STATUS_E_NOMEM;
2975 goto end;
2976 }
2977
2978 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2979 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2980 WMITLV_SET_HDR(&cmd->tlv_header,
2981 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2982 WMITLV_GET_STRUCT_TLVLEN
2983 (wmi_scan_chan_list_cmd_fixed_param));
2984
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302985 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302986
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302987 if (chan_list->append)
2988 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2989
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302990 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2991 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302992 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302993 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2994 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302995 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302996 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2997 tchan_info = &(chan_list->ch_param[0]);
2998
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302999 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05303000 WMITLV_SET_HDR(&chan_info->tlv_header,
3001 WMITLV_TAG_STRUC_wmi_channel,
3002 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3003 chan_info->mhz = tchan_info->mhz;
3004 chan_info->band_center_freq1 =
3005 tchan_info->cfreq1;
3006 chan_info->band_center_freq2 =
3007 tchan_info->cfreq2;
3008
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303009 if (tchan_info->is_chan_passive)
3010 WMI_SET_CHANNEL_FLAG(chan_info,
3011 WMI_CHAN_FLAG_PASSIVE);
3012
3013 if (tchan_info->allow_vht)
3014 WMI_SET_CHANNEL_FLAG(chan_info,
3015 WMI_CHAN_FLAG_ALLOW_VHT);
3016 else if (tchan_info->allow_ht)
3017 WMI_SET_CHANNEL_FLAG(chan_info,
3018 WMI_CHAN_FLAG_ALLOW_HT);
3019 WMI_SET_CHANNEL_MODE(chan_info,
3020 tchan_info->phy_mode);
3021
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303022 if (tchan_info->half_rate)
3023 WMI_SET_CHANNEL_FLAG(chan_info,
3024 WMI_CHAN_FLAG_HALF_RATE);
3025
3026 if (tchan_info->quarter_rate)
3027 WMI_SET_CHANNEL_FLAG(chan_info,
3028 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303029
3030 /* also fill in power information */
3031 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3032 tchan_info->minpower);
3033 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3034 tchan_info->maxpower);
3035 WMI_SET_CHANNEL_REG_POWER(chan_info,
3036 tchan_info->maxregpower);
3037 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3038 tchan_info->antennamax);
3039 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3040 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003041 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3042 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303043
Govind Singh87542482016-06-08 19:40:11 +05303044 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3045
Govind Singh87542482016-06-08 19:40:11 +05303046 tchan_info++;
3047 chan_info++;
3048 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303049 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3050 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303051
Anish Natarajdd855152017-03-20 12:49:08 +05303052 qdf_status = wmi_unified_cmd_send(
3053 wmi_handle,
3054 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303055
3056 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3057 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3058 wmi_buf_free(buf);
3059 }
3060
3061end:
3062 return qdf_status;
3063}
3064#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303065
3066/**
3067 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3068 *
3069 * @bufp: Pointer to buffer
3070 * @param: Pointer to tx param
3071 *
3072 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3073 */
3074static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3075 struct tx_send_params param)
3076{
3077 wmi_tx_send_params *tx_param;
3078 QDF_STATUS status = QDF_STATUS_SUCCESS;
3079
3080 if (!bufp) {
3081 status = QDF_STATUS_E_FAILURE;
3082 return status;
3083 }
3084 tx_param = (wmi_tx_send_params *)bufp;
3085 WMITLV_SET_HDR(&tx_param->tlv_header,
3086 WMITLV_TAG_STRUC_wmi_tx_send_params,
3087 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3088 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3089 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3090 param.mcs_mask);
3091 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3092 param.nss_mask);
3093 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3094 param.retry_limit);
3095 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3096 param.chain_mask);
3097 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3098 param.bw_mask);
3099 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3100 param.preamble_type);
3101 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3102 param.frame_type);
3103
3104 return status;
3105}
3106
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303107#ifdef CONFIG_HL_SUPPORT
3108/**
3109 * send_mgmt_cmd_tlv() - WMI scan start function
3110 * @wmi_handle : handle to WMI.
3111 * @param : pointer to hold mgmt cmd parameter
3112 *
3113 * Return: 0 on success and -ve on failure.
3114 */
3115static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3116 struct wmi_mgmt_params *param)
3117{
3118 wmi_buf_t buf;
3119 uint8_t *bufp;
3120 int32_t cmd_len;
3121 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3122 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3123 mgmt_tx_dl_frm_len;
3124
3125 if (param->frm_len > mgmt_tx_dl_frm_len) {
3126 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3127 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3128 return QDF_STATUS_E_INVAL;
3129 }
3130
3131 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3132 WMI_TLV_HDR_SIZE +
3133 roundup(bufp_len, sizeof(uint32_t));
3134
3135 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3136 if (!buf) {
3137 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3138 return QDF_STATUS_E_NOMEM;
3139 }
3140
3141 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3142 bufp = (uint8_t *) cmd;
3143 WMITLV_SET_HDR(&cmd->tlv_header,
3144 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3145 WMITLV_GET_STRUCT_TLVLEN
3146 (wmi_mgmt_tx_send_cmd_fixed_param));
3147
3148 cmd->vdev_id = param->vdev_id;
3149
3150 cmd->desc_id = param->desc_id;
3151 cmd->chanfreq = param->chanfreq;
3152 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3153 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3154 sizeof(uint32_t)));
3155 bufp += WMI_TLV_HDR_SIZE;
3156 qdf_mem_copy(bufp, param->pdata, bufp_len);
3157
3158 cmd->frame_len = param->frm_len;
3159 cmd->buf_len = bufp_len;
3160 cmd->tx_params_valid = param->tx_params_valid;
3161
3162 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3163 bufp, cmd->vdev_id, cmd->chanfreq);
3164
3165 bufp += roundup(bufp_len, sizeof(uint32_t));
3166 if (param->tx_params_valid) {
3167 if (populate_tx_send_params(bufp, param->tx_param) !=
3168 QDF_STATUS_SUCCESS) {
3169 WMI_LOGE("%s: Populate TX send params failed",
3170 __func__);
3171 goto free_buf;
3172 }
3173 cmd_len += sizeof(wmi_tx_send_params);
3174 }
3175
3176 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3177 WMI_MGMT_TX_SEND_CMDID)) {
3178 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3179 goto free_buf;
3180 }
3181 return QDF_STATUS_SUCCESS;
3182
3183free_buf:
3184 wmi_buf_free(buf);
3185 return QDF_STATUS_E_FAILURE;
3186}
3187#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303188/**
3189 * send_mgmt_cmd_tlv() - WMI scan start function
3190 * @wmi_handle : handle to WMI.
3191 * @param : pointer to hold mgmt cmd parameter
3192 *
3193 * Return: 0 on success and -ve on failure.
3194 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303195static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303196 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303197{
Govind Singh427ee5a2016-02-26 18:09:36 +05303198 wmi_buf_t buf;
3199 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3200 int32_t cmd_len;
3201 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303202 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303203 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303204 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303205 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3206 mgmt_tx_dl_frm_len;
3207
3208 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303209 WMI_TLV_HDR_SIZE +
3210 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303211
Sathish Kumar5b636932017-06-28 14:40:32 +05303212 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303213 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303214 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3215 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303216 }
3217
3218 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3219 bufp = (uint8_t *) cmd;
3220 WMITLV_SET_HDR(&cmd->tlv_header,
3221 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3222 WMITLV_GET_STRUCT_TLVLEN
3223 (wmi_mgmt_tx_send_cmd_fixed_param));
3224
3225 cmd->vdev_id = param->vdev_id;
3226
Govind Singh224a7312016-06-21 14:33:26 +05303227 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303228 cmd->chanfreq = param->chanfreq;
3229 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3230 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3231 sizeof(uint32_t)));
3232 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303233 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303234
3235 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3236 QDF_DMA_TO_DEVICE);
3237 if (status != QDF_STATUS_SUCCESS) {
3238 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303239 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303240 }
3241
Govind Singhb53420c2016-03-09 14:32:57 +05303242 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303243 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003244#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303245 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3246#endif
3247 cmd->frame_len = param->frm_len;
3248 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303249 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303250
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003251 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003252 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003253
Sathish Kumar5b636932017-06-28 14:40:32 +05303254 bufp += roundup(bufp_len, sizeof(uint32_t));
3255 if (param->tx_params_valid) {
3256 status = populate_tx_send_params(bufp, param->tx_param);
3257 if (status != QDF_STATUS_SUCCESS) {
3258 WMI_LOGE("%s: Populate TX send params failed",
3259 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303260 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303261 }
3262 cmd_len += sizeof(wmi_tx_send_params);
3263 }
3264
Govind Singh427ee5a2016-02-26 18:09:36 +05303265 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3266 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303267 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303268 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303269 }
Govind Singhb53420c2016-03-09 14:32:57 +05303270 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303271
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303272unmap_tx_frame:
3273 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3274 QDF_DMA_TO_DEVICE);
3275free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303276 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303277 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303278}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303279#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303280
3281/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303282 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3283 * @wmi_handle : handle to WMI.
3284 * @param : pointer to offchan data tx cmd parameter
3285 *
3286 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3287 */
3288static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3289 struct wmi_offchan_data_tx_params *param)
3290{
3291 wmi_buf_t buf;
3292 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3293 int32_t cmd_len;
3294 uint64_t dma_addr;
3295 void *qdf_ctx = param->qdf_ctx;
3296 uint8_t *bufp;
3297 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3298 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303299 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303300
3301 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303302 WMI_TLV_HDR_SIZE +
3303 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303304
Sathish Kumar5b636932017-06-28 14:40:32 +05303305 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303306 if (!buf) {
3307 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3308 return QDF_STATUS_E_NOMEM;
3309 }
3310
3311 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3312 bufp = (uint8_t *) cmd;
3313 WMITLV_SET_HDR(&cmd->tlv_header,
3314 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3315 WMITLV_GET_STRUCT_TLVLEN
3316 (wmi_offchan_data_tx_send_cmd_fixed_param));
3317
3318 cmd->vdev_id = param->vdev_id;
3319
3320 cmd->desc_id = param->desc_id;
3321 cmd->chanfreq = param->chanfreq;
3322 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3323 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3324 sizeof(uint32_t)));
3325 bufp += WMI_TLV_HDR_SIZE;
3326 qdf_mem_copy(bufp, param->pdata, bufp_len);
3327 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3328 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3329 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3330#if defined(HTT_PADDR64)
3331 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3332#endif
3333 cmd->frame_len = param->frm_len;
3334 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303335 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303336
3337 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3338 bufp, cmd->vdev_id, cmd->chanfreq);
3339
Sathish Kumar5b636932017-06-28 14:40:32 +05303340 bufp += roundup(bufp_len, sizeof(uint32_t));
3341 if (param->tx_params_valid) {
3342 status = populate_tx_send_params(bufp, param->tx_param);
3343 if (status != QDF_STATUS_SUCCESS) {
3344 WMI_LOGE("%s: Populate TX send params failed",
3345 __func__);
3346 goto err1;
3347 }
3348 cmd_len += sizeof(wmi_tx_send_params);
3349 }
3350
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303351 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3352 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3353 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303354 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303355 }
3356
3357 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303358
3359err1:
3360 wmi_buf_free(buf);
3361 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303362}
3363
3364/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303365 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3366 * @wmi_handle: wmi handle
3367 * @param_value: parameter value
3368 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303369 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303370 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303371static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303372 uint32_t param_value)
3373{
Govind Singh67922e82016-04-01 16:48:57 +05303374 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303375 wmi_modem_power_state_cmd_param *cmd;
3376 wmi_buf_t buf;
3377 uint16_t len = sizeof(*cmd);
3378
3379 buf = wmi_buf_alloc(wmi_handle, len);
3380 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303381 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303382 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303383 }
3384 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3385 WMITLV_SET_HDR(&cmd->tlv_header,
3386 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3387 WMITLV_GET_STRUCT_TLVLEN
3388 (wmi_modem_power_state_cmd_param));
3389 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303390 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303391 param_value);
3392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3393 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303394 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303395 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303396 wmi_buf_free(buf);
3397 }
Govind Singh67922e82016-04-01 16:48:57 +05303398
Govind Singh427ee5a2016-02-26 18:09:36 +05303399 return ret;
3400}
3401
3402/**
3403 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3404 * @wmi_handle: wmi handle
3405 * @vdev_id: vdev id
3406 * @val: value
3407 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303408 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303410static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 uint32_t vdev_id, uint8_t val)
3412{
3413 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3414 wmi_buf_t buf;
3415 int32_t len = sizeof(*cmd);
3416
Govind Singhb53420c2016-03-09 14:32:57 +05303417 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303418
3419 buf = wmi_buf_alloc(wmi_handle, len);
3420 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303421 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303422 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303423 }
3424 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3425 WMITLV_SET_HDR(&cmd->tlv_header,
3426 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3427 WMITLV_GET_STRUCT_TLVLEN
3428 (wmi_sta_powersave_mode_cmd_fixed_param));
3429 cmd->vdev_id = vdev_id;
3430 if (val)
3431 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3432 else
3433 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3434
3435 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3436 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303437 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303438 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303439 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303440 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303441 }
Govind Singh5eb51532016-03-09 11:34:12 +05303442 return 0;
3443}
3444
Govind Singh427ee5a2016-02-26 18:09:36 +05303445/**
3446 * send_set_mimops_cmd_tlv() - set MIMO powersave
3447 * @wmi_handle: wmi handle
3448 * @vdev_id: vdev id
3449 * @value: value
3450 *
Govind Singhb53420c2016-03-09 14:32:57 +05303451 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303452 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303453static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303454 uint8_t vdev_id, int value)
3455{
Govind Singh67922e82016-04-01 16:48:57 +05303456 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303457 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3458 wmi_buf_t buf;
3459 uint16_t len = sizeof(*cmd);
3460
3461 buf = wmi_buf_alloc(wmi_handle, len);
3462 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303463 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303464 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303465 }
3466 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3467 WMITLV_SET_HDR(&cmd->tlv_header,
3468 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3469 WMITLV_GET_STRUCT_TLVLEN
3470 (wmi_sta_smps_force_mode_cmd_fixed_param));
3471
3472 cmd->vdev_id = vdev_id;
3473
Houston Hoffmanb5168052016-04-14 02:18:01 -07003474 /* WMI_SMPS_FORCED_MODE values do not directly map
3475 * to SM power save values defined in the specification.
3476 * Make sure to send the right mapping.
3477 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303478 switch (value) {
3479 case 0:
3480 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3481 break;
3482 case 1:
3483 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3484 break;
3485 case 2:
3486 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3487 break;
3488 case 3:
3489 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3490 break;
3491 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303492 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303493 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303494 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303495 }
3496
Govind Singhb53420c2016-03-09 14:32:57 +05303497 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303498
3499 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3500 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303501 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303502 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303503 wmi_buf_free(buf);
3504 }
3505
3506 return ret;
3507}
3508
3509/**
3510 * send_set_smps_params_cmd_tlv() - set smps params
3511 * @wmi_handle: wmi handle
3512 * @vdev_id: vdev id
3513 * @value: value
3514 *
Govind Singhb53420c2016-03-09 14:32:57 +05303515 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303516 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303517static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303518 int value)
3519{
Govind Singh67922e82016-04-01 16:48:57 +05303520 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303521 wmi_sta_smps_param_cmd_fixed_param *cmd;
3522 wmi_buf_t buf;
3523 uint16_t len = sizeof(*cmd);
3524
3525 buf = wmi_buf_alloc(wmi_handle, len);
3526 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303527 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303528 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303529 }
3530 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3531 WMITLV_SET_HDR(&cmd->tlv_header,
3532 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3533 WMITLV_GET_STRUCT_TLVLEN
3534 (wmi_sta_smps_param_cmd_fixed_param));
3535
3536 cmd->vdev_id = vdev_id;
3537 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3538 cmd->param =
3539 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3540
Govind Singhb53420c2016-03-09 14:32:57 +05303541 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303542 cmd->param);
3543
3544 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3545 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303546 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303547 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303548 wmi_buf_free(buf);
3549 }
3550
3551 return ret;
3552}
3553
3554/**
3555 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3556 * @wmi_handle: wmi handle
3557 * @noa: p2p power save parameters
3558 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303559 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303560 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303561static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303562 struct p2p_ps_params *noa)
3563{
3564 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3565 wmi_p2p_noa_descriptor *noa_discriptor;
3566 wmi_buf_t buf;
3567 uint8_t *buf_ptr;
3568 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303569 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303570 uint32_t duration;
3571
Govind Singhb53420c2016-03-09 14:32:57 +05303572 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303573 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3574 buf = wmi_buf_alloc(wmi_handle, len);
3575 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303576 WMI_LOGE("Failed to allocate memory");
3577 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303578 goto end;
3579 }
3580
3581 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3582 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3583 WMITLV_SET_HDR(&cmd->tlv_header,
3584 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3585 WMITLV_GET_STRUCT_TLVLEN
3586 (wmi_p2p_set_noa_cmd_fixed_param));
3587 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3588 cmd->vdev_id = noa->session_id;
3589 cmd->enable = (duration) ? true : false;
3590 cmd->num_noa = 1;
3591
3592 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3593 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3594 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3595 sizeof
3596 (wmi_p2p_set_noa_cmd_fixed_param)
3597 + WMI_TLV_HDR_SIZE);
3598 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3599 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3600 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3601 noa_discriptor->type_count = noa->count;
3602 noa_discriptor->duration = duration;
3603 noa_discriptor->interval = noa->interval;
3604 noa_discriptor->start_time = 0;
3605
Govind Singhb53420c2016-03-09 14:32:57 +05303606 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303607 cmd->vdev_id, noa->count, noa_discriptor->duration,
3608 noa->interval);
3609 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3610 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303611 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303612 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303613 wmi_buf_free(buf);
3614 }
3615
3616end:
Govind Singhb53420c2016-03-09 14:32:57 +05303617 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303618 return status;
3619}
3620
3621
3622/**
3623 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3624 * @wmi_handle: wmi handle
3625 * @noa: p2p opp power save parameters
3626 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303627 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303629static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303630 struct p2p_ps_params *oppps)
3631{
3632 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3633 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303634 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303635
Govind Singhb53420c2016-03-09 14:32:57 +05303636 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303637 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3638 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303639 WMI_LOGE("Failed to allocate memory");
3640 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303641 goto end;
3642 }
3643
3644 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3645 WMITLV_SET_HDR(&cmd->tlv_header,
3646 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3647 WMITLV_GET_STRUCT_TLVLEN
3648 (wmi_p2p_set_oppps_cmd_fixed_param));
3649 cmd->vdev_id = oppps->session_id;
3650 if (oppps->ctwindow)
3651 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3652
3653 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303654 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303655 cmd->vdev_id, oppps->ctwindow);
3656 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3657 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303658 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303659 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303660 wmi_buf_free(buf);
3661 }
3662
3663end:
Govind Singhb53420c2016-03-09 14:32:57 +05303664 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303665 return status;
3666}
3667
Wu Gaocd3a8512017-03-13 20:17:34 +08003668#ifdef CONVERGED_P2P_ENABLE
3669/**
3670 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3671 * @wmi_handle: wmi handle
3672 * @param: p2p listen offload start parameters
3673 *
3674 * Return: QDF status
3675 */
3676static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3677 struct p2p_lo_start *param)
3678{
3679 wmi_buf_t buf;
3680 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3681 int32_t len = sizeof(*cmd);
3682 uint8_t *buf_ptr;
3683 QDF_STATUS status;
3684 int device_types_len_aligned;
3685 int probe_resp_len_aligned;
3686
3687 if (!param) {
3688 WMI_LOGE("lo start param is null");
3689 return QDF_STATUS_E_INVAL;
3690 }
3691
3692 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3693
3694 device_types_len_aligned =
3695 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303696 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003697 probe_resp_len_aligned =
3698 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303699 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003700
3701 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3702 probe_resp_len_aligned;
3703
3704 buf = wmi_buf_alloc(wmi_handle, len);
3705 if (!buf) {
3706 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3707 __func__);
3708 return QDF_STATUS_E_NOMEM;
3709 }
3710
3711 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3712 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3713
3714 WMITLV_SET_HDR(&cmd->tlv_header,
3715 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3716 WMITLV_GET_STRUCT_TLVLEN(
3717 wmi_p2p_lo_start_cmd_fixed_param));
3718
3719 cmd->vdev_id = param->vdev_id;
3720 cmd->ctl_flags = param->ctl_flags;
3721 cmd->channel = param->freq;
3722 cmd->period = param->period;
3723 cmd->interval = param->interval;
3724 cmd->count = param->count;
3725 cmd->device_types_len = param->dev_types_len;
3726 cmd->prob_resp_len = param->probe_resp_len;
3727
3728 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3730 device_types_len_aligned);
3731 buf_ptr += WMI_TLV_HDR_SIZE;
3732 qdf_mem_copy(buf_ptr, param->device_types,
3733 param->dev_types_len);
3734
3735 buf_ptr += device_types_len_aligned;
3736 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3737 probe_resp_len_aligned);
3738 buf_ptr += WMI_TLV_HDR_SIZE;
3739 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3740 param->probe_resp_len);
3741
3742 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3743 cmd->channel, cmd->period, cmd->interval, cmd->count);
3744
3745 status = wmi_unified_cmd_send(wmi_handle,
3746 buf, len,
3747 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3748 if (status != QDF_STATUS_SUCCESS) {
3749 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3750 __func__, status);
3751 wmi_buf_free(buf);
3752 return status;
3753 }
3754
3755 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3756
3757 return QDF_STATUS_SUCCESS;
3758}
3759
3760/**
3761 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3762 * @wmi_handle: wmi handle
3763 * @param: p2p listen offload stop parameters
3764 *
3765 * Return: QDF status
3766 */
3767static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3768 uint8_t vdev_id)
3769{
3770 wmi_buf_t buf;
3771 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3772 int32_t len;
3773 QDF_STATUS status;
3774
3775 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3776
3777 len = sizeof(*cmd);
3778 buf = wmi_buf_alloc(wmi_handle, len);
3779 if (!buf) {
3780 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3781 __func__);
3782 return QDF_STATUS_E_NOMEM;
3783 }
3784 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3785
3786 WMITLV_SET_HDR(&cmd->tlv_header,
3787 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3788 WMITLV_GET_STRUCT_TLVLEN(
3789 wmi_p2p_lo_stop_cmd_fixed_param));
3790
3791 cmd->vdev_id = vdev_id;
3792
3793 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3794
3795 status = wmi_unified_cmd_send(wmi_handle,
3796 buf, len,
3797 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3798 if (status != QDF_STATUS_SUCCESS) {
3799 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3800 __func__, status);
3801 wmi_buf_free(buf);
3802 return status;
3803 }
3804
3805 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3806
3807 return QDF_STATUS_SUCCESS;
3808}
3809#endif /* End of CONVERGED_P2P_ENABLE */
3810
Govind Singh427ee5a2016-02-26 18:09:36 +05303811/**
3812 * send_get_temperature_cmd_tlv() - get pdev temperature req
3813 * @wmi_handle: wmi handle
3814 *
Govind Singhb53420c2016-03-09 14:32:57 +05303815 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303816 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303817static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303818{
3819 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3820 wmi_buf_t wmi_buf;
3821 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3822 uint8_t *buf_ptr;
3823
3824 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303825 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3826 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303827 }
3828
3829 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3830 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303831 WMI_LOGE(FL("wmi_buf_alloc failed"));
3832 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303833 }
3834
3835 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3836
3837 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3838 WMITLV_SET_HDR(&cmd->tlv_header,
3839 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3840 WMITLV_GET_STRUCT_TLVLEN
3841 (wmi_pdev_get_temperature_cmd_fixed_param));
3842
3843 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3844 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303845 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303846 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303847 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303848 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303849
Govind Singhb53420c2016-03-09 14:32:57 +05303850 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303851}
3852
3853/**
3854 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3855 * @wmi_handle: wmi handle
3856 * @vdevid: vdev id
3857 * @peer_addr: peer mac address
3858 * @auto_triggerparam: auto trigger parameters
3859 * @num_ac: number of access category
3860 *
3861 * This function sets the trigger
3862 * uapsd params such as service interval, delay interval
3863 * and suspend interval which will be used by the firmware
3864 * to send trigger frames periodically when there is no
3865 * traffic on the transmit side.
3866 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303867 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303868 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303869static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303870 struct sta_uapsd_trig_params *param)
3871{
3872 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303873 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303874 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3875 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3876 uint32_t i;
3877 wmi_buf_t buf;
3878 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003879 struct sta_uapsd_params *uapsd_param;
3880 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303881
3882 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303884 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303885 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303886 }
3887
3888 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3889 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3890 WMITLV_SET_HDR(&cmd->tlv_header,
3891 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3892 WMITLV_GET_STRUCT_TLVLEN
3893 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3894 cmd->vdev_id = param->vdevid;
3895 cmd->num_ac = param->num_ac;
3896 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3897
3898 /* TLV indicating array of structures to follow */
3899 buf_ptr += sizeof(*cmd);
3900 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3901
3902 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303903
3904 /*
3905 * Update tag and length for uapsd auto trigger params (this will take
3906 * care of updating tag and length if it is not pre-filled by caller).
3907 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003908 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3909 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303910 for (i = 0; i < param->num_ac; i++) {
3911 WMITLV_SET_HDR((buf_ptr +
3912 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3913 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3914 WMITLV_GET_STRUCT_TLVLEN
3915 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003916 trig_param->wmm_ac = uapsd_param->wmm_ac;
3917 trig_param->user_priority = uapsd_param->user_priority;
3918 trig_param->service_interval = uapsd_param->service_interval;
3919 trig_param->suspend_interval = uapsd_param->suspend_interval;
3920 trig_param->delay_interval = uapsd_param->delay_interval;
3921 trig_param++;
3922 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303923 }
3924
3925 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3926 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303927 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303928 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303929 wmi_buf_free(buf);
3930 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303931
Govind Singh427ee5a2016-02-26 18:09:36 +05303932 return ret;
3933}
3934
Zhang Qian11c0de32018-01-05 16:50:53 +08003935#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303936/**
3937 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3938 * @wmi_handle: pointer to the wmi handle
3939 * @utc: pointer to the UTC time struct
3940 *
3941 * Return: 0 on succes
3942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303943static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303944 struct ocb_utc_param *utc)
3945{
Govind Singh67922e82016-04-01 16:48:57 +05303946 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303947 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3948 uint8_t *buf_ptr;
3949 uint32_t len, i;
3950 wmi_buf_t buf;
3951
3952 len = sizeof(*cmd);
3953 buf = wmi_buf_alloc(wmi_handle, len);
3954 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303955 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303956 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303957 }
3958
3959 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3960 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3961 WMITLV_SET_HDR(&cmd->tlv_header,
3962 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3963 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3964 cmd->vdev_id = utc->vdev_id;
3965
3966 for (i = 0; i < SIZE_UTC_TIME; i++)
3967 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3968
3969 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3970 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3971
3972 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3973 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303974 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303975 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303976 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303977 }
3978
Govind Singh67922e82016-04-01 16:48:57 +05303979 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303980}
3981
3982/**
3983 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3984 * frames on a channel
3985 * @wmi_handle: pointer to the wmi handle
3986 * @timing_advert: pointer to the timing advertisement struct
3987 *
3988 * Return: 0 on succes
3989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303990static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303991 struct ocb_timing_advert_param *timing_advert)
3992{
Govind Singh67922e82016-04-01 16:48:57 +05303993 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303994 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3995 uint8_t *buf_ptr;
3996 uint32_t len, len_template;
3997 wmi_buf_t buf;
3998
3999 len = sizeof(*cmd) +
4000 WMI_TLV_HDR_SIZE;
4001
4002 len_template = timing_advert->template_length;
4003 /* Add padding to the template if needed */
4004 if (len_template % 4 != 0)
4005 len_template += 4 - (len_template % 4);
4006 len += len_template;
4007
4008 buf = wmi_buf_alloc(wmi_handle, len);
4009 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304010 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304011 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304012 }
4013
4014 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4015 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4016 WMITLV_SET_HDR(&cmd->tlv_header,
4017 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4018 WMITLV_GET_STRUCT_TLVLEN(
4019 wmi_ocb_start_timing_advert_cmd_fixed_param));
4020 cmd->vdev_id = timing_advert->vdev_id;
4021 cmd->repeat_rate = timing_advert->repeat_rate;
4022 cmd->channel_freq = timing_advert->chan_freq;
4023 cmd->timestamp_offset = timing_advert->timestamp_offset;
4024 cmd->time_value_offset = timing_advert->time_value_offset;
4025 cmd->timing_advert_template_length = timing_advert->template_length;
4026 buf_ptr += sizeof(*cmd);
4027
4028 /* Add the timing advert template */
4029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4030 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304031 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304032 (uint8_t *)timing_advert->template_value,
4033 timing_advert->template_length);
4034
4035 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4036 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304037 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304038 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304039 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304040 }
4041
Govind Singh67922e82016-04-01 16:48:57 +05304042 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304043}
4044
4045/**
4046 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4047 * on a channel
4048 * @wmi_handle: pointer to the wmi handle
4049 * @timing_advert: pointer to the timing advertisement struct
4050 *
4051 * Return: 0 on succes
4052 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304053static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304054 struct ocb_timing_advert_param *timing_advert)
4055{
Govind Singh67922e82016-04-01 16:48:57 +05304056 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304057 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4058 uint8_t *buf_ptr;
4059 uint32_t len;
4060 wmi_buf_t buf;
4061
4062 len = sizeof(*cmd);
4063 buf = wmi_buf_alloc(wmi_handle, len);
4064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304065 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304066 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304067 }
4068
4069 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4070 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4071 WMITLV_SET_HDR(&cmd->tlv_header,
4072 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4073 WMITLV_GET_STRUCT_TLVLEN(
4074 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4075 cmd->vdev_id = timing_advert->vdev_id;
4076 cmd->channel_freq = timing_advert->chan_freq;
4077
4078 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4079 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304080 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304081 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304082 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304083 }
4084
Govind Singh67922e82016-04-01 16:48:57 +05304085 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304086}
4087
4088/**
4089 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4090 * @wmi_handle: pointer to the wmi handle
4091 * @request: pointer to the request
4092 *
4093 * Return: 0 on succes
4094 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304095static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304096 uint8_t vdev_id)
4097{
Govind Singhb53420c2016-03-09 14:32:57 +05304098 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304099 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4100 uint8_t *buf_ptr;
4101 wmi_buf_t buf;
4102 int32_t len;
4103
4104 len = sizeof(*cmd);
4105 buf = wmi_buf_alloc(wmi_handle, len);
4106 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304107 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304108 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304109 }
4110 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4111
4112 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304113 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304114 WMITLV_SET_HDR(&cmd->tlv_header,
4115 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4116 WMITLV_GET_STRUCT_TLVLEN(
4117 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4118 cmd->vdev_id = vdev_id;
4119
4120 /* Send the WMI command */
4121 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4122 WMI_OCB_GET_TSF_TIMER_CMDID);
4123 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304124 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304125 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304126 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304127 }
4128
Govind Singh67922e82016-04-01 16:48:57 +05304129 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304130}
4131
4132/**
4133 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4134 * @wmi_handle: pointer to the wmi handle
4135 * @get_stats_param: pointer to the dcc stats
4136 *
4137 * Return: 0 on succes
4138 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304139static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004140 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304141{
Govind Singh67922e82016-04-01 16:48:57 +05304142 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304143 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4144 wmi_dcc_channel_stats_request *channel_stats_array;
4145 wmi_buf_t buf;
4146 uint8_t *buf_ptr;
4147 uint32_t len;
4148 uint32_t i;
4149
4150 /* Validate the input */
4151 if (get_stats_param->request_array_len !=
4152 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304153 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304154 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304155 }
4156
4157 /* Allocate memory for the WMI command */
4158 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4159 get_stats_param->request_array_len;
4160
4161 buf = wmi_buf_alloc(wmi_handle, len);
4162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304163 WMI_LOGE(FL("wmi_buf_alloc failed"));
4164 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304165 }
4166
4167 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304168 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304169
4170 /* Populate the WMI command */
4171 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4172 buf_ptr += sizeof(*cmd);
4173
4174 WMITLV_SET_HDR(&cmd->tlv_header,
4175 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4176 WMITLV_GET_STRUCT_TLVLEN(
4177 wmi_dcc_get_stats_cmd_fixed_param));
4178 cmd->vdev_id = get_stats_param->vdev_id;
4179 cmd->num_channels = get_stats_param->channel_count;
4180
4181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4182 get_stats_param->request_array_len);
4183 buf_ptr += WMI_TLV_HDR_SIZE;
4184
4185 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304186 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304187 get_stats_param->request_array_len);
4188 for (i = 0; i < cmd->num_channels; i++)
4189 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4190 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4191 WMITLV_GET_STRUCT_TLVLEN(
4192 wmi_dcc_channel_stats_request));
4193
4194 /* Send the WMI command */
4195 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4196 WMI_DCC_GET_STATS_CMDID);
4197
Govind Singh67922e82016-04-01 16:48:57 +05304198 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304199 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304200 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304201 }
4202
Govind Singh67922e82016-04-01 16:48:57 +05304203 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304204}
4205
4206/**
4207 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4208 * @wmi_handle: pointer to the wmi handle
4209 * @vdev_id: vdev id
4210 * @dcc_stats_bitmap: dcc status bitmap
4211 *
4212 * Return: 0 on succes
4213 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304214static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304215 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4216{
Govind Singh67922e82016-04-01 16:48:57 +05304217 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304218 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4219 wmi_buf_t buf;
4220 uint8_t *buf_ptr;
4221 uint32_t len;
4222
4223 /* Allocate memory for the WMI command */
4224 len = sizeof(*cmd);
4225
4226 buf = wmi_buf_alloc(wmi_handle, len);
4227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304228 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304229 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304230 }
4231
4232 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304233 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304234
4235 /* Populate the WMI command */
4236 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4237
4238 WMITLV_SET_HDR(&cmd->tlv_header,
4239 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4240 WMITLV_GET_STRUCT_TLVLEN(
4241 wmi_dcc_clear_stats_cmd_fixed_param));
4242 cmd->vdev_id = vdev_id;
4243 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4244
4245 /* Send the WMI command */
4246 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4247 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304248 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304249 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304250 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304251 }
4252
Govind Singh67922e82016-04-01 16:48:57 +05304253 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304254}
4255
4256/**
4257 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4258 * @wmi_handle: pointer to the wmi handle
4259 * @update_ndl_param: pointer to the request parameters
4260 *
4261 * Return: 0 on success
4262 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304263static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004264 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304265{
Govind Singhb53420c2016-03-09 14:32:57 +05304266 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304267 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4268 wmi_dcc_ndl_chan *ndl_chan_array;
4269 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4270 uint32_t active_state_count;
4271 wmi_buf_t buf;
4272 uint8_t *buf_ptr;
4273 uint32_t len;
4274 uint32_t i;
4275
4276 /* validate the input */
4277 if (update_ndl_param->dcc_ndl_chan_list_len !=
4278 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304279 WMI_LOGE(FL("Invalid parameter"));
4280 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304281 }
4282 active_state_count = 0;
4283 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4284 for (i = 0; i < update_ndl_param->channel_count; i++)
4285 active_state_count +=
4286 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4287 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4288 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304289 WMI_LOGE(FL("Invalid parameter"));
4290 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304291 }
4292
4293 /* Allocate memory for the WMI command */
4294 len = sizeof(*cmd) +
4295 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4296 WMI_TLV_HDR_SIZE +
4297 update_ndl_param->dcc_ndl_active_state_list_len;
4298
4299 buf = wmi_buf_alloc(wmi_handle, len);
4300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304301 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304302 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304303 }
4304
4305 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304306 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304307
4308 /* Populate the WMI command */
4309 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4310 buf_ptr += sizeof(*cmd);
4311
4312 WMITLV_SET_HDR(&cmd->tlv_header,
4313 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4314 WMITLV_GET_STRUCT_TLVLEN(
4315 wmi_dcc_update_ndl_cmd_fixed_param));
4316 cmd->vdev_id = update_ndl_param->vdev_id;
4317 cmd->num_channel = update_ndl_param->channel_count;
4318
4319 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4320 update_ndl_param->dcc_ndl_chan_list_len);
4321 buf_ptr += WMI_TLV_HDR_SIZE;
4322
4323 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304324 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304325 update_ndl_param->dcc_ndl_chan_list_len);
4326 for (i = 0; i < cmd->num_channel; i++)
4327 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4328 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4329 WMITLV_GET_STRUCT_TLVLEN(
4330 wmi_dcc_ndl_chan));
4331 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4332
4333 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4334 update_ndl_param->dcc_ndl_active_state_list_len);
4335 buf_ptr += WMI_TLV_HDR_SIZE;
4336
4337 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304338 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304339 update_ndl_param->dcc_ndl_active_state_list,
4340 update_ndl_param->dcc_ndl_active_state_list_len);
4341 for (i = 0; i < active_state_count; i++) {
4342 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4343 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4344 WMITLV_GET_STRUCT_TLVLEN(
4345 wmi_dcc_ndl_active_state_config));
4346 }
4347 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4348
4349 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304350 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304351 WMI_DCC_UPDATE_NDL_CMDID);
4352 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304353 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304354 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304355 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304356 }
4357
Govind Singh67922e82016-04-01 16:48:57 +05304358 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304359}
4360
4361/**
4362 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4363 * @wmi_handle: pointer to the wmi handle
4364 * @config: the OCB configuration
4365 *
4366 * Return: 0 on success
4367 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304368static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004369 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304370{
Govind Singh67922e82016-04-01 16:48:57 +05304371 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304372 wmi_ocb_set_config_cmd_fixed_param *cmd;
4373 wmi_channel *chan;
4374 wmi_ocb_channel *ocb_chan;
4375 wmi_qos_parameter *qos_param;
4376 wmi_dcc_ndl_chan *ndl_chan;
4377 wmi_dcc_ndl_active_state_config *ndl_active_config;
4378 wmi_ocb_schedule_element *sched_elem;
4379 uint8_t *buf_ptr;
4380 wmi_buf_t buf;
4381 int32_t len;
4382 int32_t i, j, active_state_count;
4383
4384 /*
4385 * Validate the dcc_ndl_chan_list_len and count the number of active
4386 * states. Validate dcc_ndl_active_state_list_len.
4387 */
4388 active_state_count = 0;
4389 if (config->dcc_ndl_chan_list_len) {
4390 if (!config->dcc_ndl_chan_list ||
4391 config->dcc_ndl_chan_list_len !=
4392 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304393 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304394 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304395 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304396 }
4397
4398 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4399 i < config->channel_count; ++i, ++ndl_chan)
4400 active_state_count +=
4401 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4402
4403 if (active_state_count) {
4404 if (!config->dcc_ndl_active_state_list ||
4405 config->dcc_ndl_active_state_list_len !=
4406 active_state_count *
4407 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304408 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304409 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304410 }
4411 }
4412 }
4413
4414 len = sizeof(*cmd) +
4415 WMI_TLV_HDR_SIZE + config->channel_count *
4416 sizeof(wmi_channel) +
4417 WMI_TLV_HDR_SIZE + config->channel_count *
4418 sizeof(wmi_ocb_channel) +
4419 WMI_TLV_HDR_SIZE + config->channel_count *
4420 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4421 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4422 WMI_TLV_HDR_SIZE + active_state_count *
4423 sizeof(wmi_dcc_ndl_active_state_config) +
4424 WMI_TLV_HDR_SIZE + config->schedule_size *
4425 sizeof(wmi_ocb_schedule_element);
4426 buf = wmi_buf_alloc(wmi_handle, len);
4427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304428 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304429 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304430 }
4431
4432 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4433 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4434 WMITLV_SET_HDR(&cmd->tlv_header,
4435 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4436 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004437 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304438 cmd->channel_count = config->channel_count;
4439 cmd->schedule_size = config->schedule_size;
4440 cmd->flags = config->flags;
4441 buf_ptr += sizeof(*cmd);
4442
4443 /* Add the wmi_channel info */
4444 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4445 config->channel_count*sizeof(wmi_channel));
4446 buf_ptr += WMI_TLV_HDR_SIZE;
4447 for (i = 0; i < config->channel_count; i++) {
4448 chan = (wmi_channel *)buf_ptr;
4449 WMITLV_SET_HDR(&chan->tlv_header,
4450 WMITLV_TAG_STRUC_wmi_channel,
4451 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4452 chan->mhz = config->channels[i].chan_freq;
4453 chan->band_center_freq1 = config->channels[i].chan_freq;
4454 chan->band_center_freq2 = 0;
4455 chan->info = 0;
4456
Zhang Qian11c0de32018-01-05 16:50:53 +08004457 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304458 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4459 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4460 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4461 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4462 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4463 config->channels[i].antenna_max);
4464
4465 if (config->channels[i].bandwidth < 10)
4466 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4467 else if (config->channels[i].bandwidth < 20)
4468 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4469 buf_ptr += sizeof(*chan);
4470 }
4471
4472 /* Add the wmi_ocb_channel info */
4473 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4474 config->channel_count*sizeof(wmi_ocb_channel));
4475 buf_ptr += WMI_TLV_HDR_SIZE;
4476 for (i = 0; i < config->channel_count; i++) {
4477 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4478 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4479 WMITLV_TAG_STRUC_wmi_ocb_channel,
4480 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4481 ocb_chan->bandwidth = config->channels[i].bandwidth;
4482 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4483 config->channels[i].mac_address.bytes,
4484 &ocb_chan->mac_address);
4485 buf_ptr += sizeof(*ocb_chan);
4486 }
4487
4488 /* Add the wmi_qos_parameter info */
4489 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4490 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4491 buf_ptr += WMI_TLV_HDR_SIZE;
4492 /* WMI_MAX_NUM_AC parameters for each channel */
4493 for (i = 0; i < config->channel_count; i++) {
4494 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4495 qos_param = (wmi_qos_parameter *)buf_ptr;
4496 WMITLV_SET_HDR(&qos_param->tlv_header,
4497 WMITLV_TAG_STRUC_wmi_qos_parameter,
4498 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4499 qos_param->aifsn =
4500 config->channels[i].qos_params[j].aifsn;
4501 qos_param->cwmin =
4502 config->channels[i].qos_params[j].cwmin;
4503 qos_param->cwmax =
4504 config->channels[i].qos_params[j].cwmax;
4505 buf_ptr += sizeof(*qos_param);
4506 }
4507 }
4508
4509 /* Add the wmi_dcc_ndl_chan (per channel) */
4510 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4511 config->dcc_ndl_chan_list_len);
4512 buf_ptr += WMI_TLV_HDR_SIZE;
4513 if (config->dcc_ndl_chan_list_len) {
4514 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304515 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304516 config->dcc_ndl_chan_list_len);
4517 for (i = 0; i < config->channel_count; i++)
4518 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4519 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4520 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4521 buf_ptr += config->dcc_ndl_chan_list_len;
4522 }
4523
4524 /* Add the wmi_dcc_ndl_active_state_config */
4525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4526 sizeof(wmi_dcc_ndl_active_state_config));
4527 buf_ptr += WMI_TLV_HDR_SIZE;
4528 if (active_state_count) {
4529 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304530 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304531 config->dcc_ndl_active_state_list,
4532 active_state_count * sizeof(*ndl_active_config));
4533 for (i = 0; i < active_state_count; ++i)
4534 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4535 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4536 WMITLV_GET_STRUCT_TLVLEN(
4537 wmi_dcc_ndl_active_state_config));
4538 buf_ptr += active_state_count *
4539 sizeof(*ndl_active_config);
4540 }
4541
4542 /* Add the wmi_ocb_schedule_element info */
4543 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4544 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4545 buf_ptr += WMI_TLV_HDR_SIZE;
4546 for (i = 0; i < config->schedule_size; i++) {
4547 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4548 WMITLV_SET_HDR(&sched_elem->tlv_header,
4549 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4550 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4551 sched_elem->channel_freq = config->schedule[i].chan_freq;
4552 sched_elem->total_duration = config->schedule[i].total_duration;
4553 sched_elem->guard_interval = config->schedule[i].guard_interval;
4554 buf_ptr += sizeof(*sched_elem);
4555 }
4556
4557
4558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4559 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304560 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304561 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304562 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304563 }
4564
Govind Singh67922e82016-04-01 16:48:57 +05304565 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304566}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304567
4568/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004569 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4570 * @wmi_handle: wmi handle
4571 * @evt_buf: wmi event buffer
4572 * @status: status buffer
4573 *
4574 * Return: QDF_STATUS_SUCCESS on success
4575 */
4576static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4577 void *evt_buf,
4578 uint32_t *status)
4579{
4580 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4581 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4582
4583 param_tlvs = evt_buf;
4584 fix_param = param_tlvs->fixed_param;
4585
4586 *status = fix_param->status;
4587 return QDF_STATUS_SUCCESS;
4588}
4589
4590/**
4591 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4592 * @wmi_handle: wmi handle
4593 * @evt_buf: wmi event buffer
4594 * @resp: response buffer
4595 *
4596 * Return: QDF_STATUS_SUCCESS on success
4597 */
4598static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4599 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4600{
4601 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4602 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4603
4604 param_tlvs = evt_buf;
4605 fix_param = param_tlvs->fixed_param;
4606 resp->vdev_id = fix_param->vdev_id;
4607 resp->timer_high = fix_param->tsf_timer_high;
4608 resp->timer_low = fix_param->tsf_timer_low;
4609
4610 return QDF_STATUS_SUCCESS;
4611}
4612
4613/**
4614 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4615 * @wmi_handle: wmi handle
4616 * @evt_buf: wmi event buffer
4617 * @resp: response buffer
4618 *
4619 * Return: QDF_STATUS_SUCCESS on success
4620 */
4621static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4622 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4623{
4624 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4625 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4626
4627 param_tlvs = evt_buf;
4628 fix_param = param_tlvs->fixed_param;
4629 resp->vdev_id = fix_param->vdev_id;
4630 resp->status = fix_param->status;
4631 return QDF_STATUS_SUCCESS;
4632}
4633
4634/**
4635 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4636 * @wmi_handle: wmi handle
4637 * @evt_buf: wmi event buffer
4638 * @resp: response buffer
4639 *
4640 * Since length of stats is variable, buffer for DCC stats will be allocated
4641 * in this function. The caller must free the buffer.
4642 *
4643 * Return: QDF_STATUS_SUCCESS on success
4644 */
4645static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4646 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4647{
4648 struct ocb_dcc_get_stats_response *response;
4649 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4650 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4651
4652 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4653 fix_param = param_tlvs->fixed_param;
4654
4655 /* Allocate and populate the response */
4656 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4657 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4658 WMI_LOGE("%s: too many channels:%d", __func__,
4659 fix_param->num_channels);
4660 QDF_ASSERT(0);
4661 *resp = NULL;
4662 return QDF_STATUS_E_INVAL;
4663 }
4664 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4665 sizeof(wmi_dcc_ndl_stats_per_channel));
4666 *resp = response;
4667 if (!response)
4668 return QDF_STATUS_E_NOMEM;
4669
4670 response->vdev_id = fix_param->vdev_id;
4671 response->num_channels = fix_param->num_channels;
4672 response->channel_stats_array_len =
4673 fix_param->num_channels *
4674 sizeof(wmi_dcc_ndl_stats_per_channel);
4675 response->channel_stats_array = ((uint8_t *)response) +
4676 sizeof(*response);
4677 qdf_mem_copy(response->channel_stats_array,
4678 param_tlvs->stats_per_channel_list,
4679 response->channel_stats_array_len);
4680
4681 return QDF_STATUS_SUCCESS;
4682}
4683#endif
4684
4685/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304686 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4687 * @wmi_handle: wmi handle
4688 * @mcc_adaptive_scheduler: enable/disable
4689 *
4690 * This function enable/disable mcc adaptive scheduler in fw.
4691 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004692 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304693 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304694static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004695 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4696 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304697{
Govind Singh67922e82016-04-01 16:48:57 +05304698 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304699 wmi_buf_t buf = 0;
4700 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4701 uint16_t len =
4702 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4703
4704 buf = wmi_buf_alloc(wmi_handle, len);
4705 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304706 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4707 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304708 }
4709 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4710 wmi_buf_data(buf);
4711
4712 WMITLV_SET_HDR(&cmd->tlv_header,
4713 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4714 WMITLV_GET_STRUCT_TLVLEN
4715 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4716 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304717 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304718
4719 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4720 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304721 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304722 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304723 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304724 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304725 }
Govind Singh67922e82016-04-01 16:48:57 +05304726
4727 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304728}
4729
4730/**
4731 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4732 * @wmi: wmi handle
4733 * @mcc_channel: mcc channel
4734 * @mcc_channel_time_latency: MCC channel time latency.
4735 *
4736 * Currently used to set time latency for an MCC vdev/adapter using operating
4737 * channel of it and channel number. The info is provided run time using
4738 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4739 *
4740 * Return: CDF status
4741 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304742static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304743 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4744{
Govind Singh67922e82016-04-01 16:48:57 +05304745 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304746 wmi_buf_t buf = 0;
4747 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4748 uint16_t len = 0;
4749 uint8_t *buf_ptr = NULL;
4750 wmi_resmgr_chan_latency chan_latency;
4751 /* Note: we only support MCC time latency for a single channel */
4752 uint32_t num_channels = 1;
4753 uint32_t chan1_freq = mcc_channel_freq;
4754 uint32_t latency_chan1 = mcc_channel_time_latency;
4755
4756
4757 /* If 0ms latency is provided, then FW will set to a default.
4758 * Otherwise, latency must be at least 30ms.
4759 */
4760 if ((latency_chan1 > 0) &&
4761 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304762 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304763 "Minimum is 30ms (or 0 to use default value by "
4764 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304765 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304766 }
4767
4768 /* Set WMI CMD for channel time latency here */
4769 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4770 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4771 num_channels * sizeof(wmi_resmgr_chan_latency);
4772 buf = wmi_buf_alloc(wmi_handle, len);
4773 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304774 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4775 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304776 }
4777 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4778 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4779 wmi_buf_data(buf);
4780 WMITLV_SET_HDR(&cmdTL->tlv_header,
4781 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4782 WMITLV_GET_STRUCT_TLVLEN
4783 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4784 cmdTL->num_chans = num_channels;
4785 /* Update channel time latency information for home channel(s) */
4786 buf_ptr += sizeof(*cmdTL);
4787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4788 num_channels * sizeof(wmi_resmgr_chan_latency));
4789 buf_ptr += WMI_TLV_HDR_SIZE;
4790 chan_latency.chan_mhz = chan1_freq;
4791 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304792 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304793 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4794 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304795 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304796 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304797 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304798 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304799 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304800 }
Govind Singh67922e82016-04-01 16:48:57 +05304801
4802 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304803}
4804
4805/**
4806 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4807 * @wmi: wmi handle
4808 * @adapter_1_chan_number: adapter 1 channel number
4809 * @adapter_1_quota: adapter 1 quota
4810 * @adapter_2_chan_number: adapter 2 channel number
4811 *
4812 * Return: CDF status
4813 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304814static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304815 uint32_t adapter_1_chan_freq,
4816 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4817{
Govind Singh67922e82016-04-01 16:48:57 +05304818 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304819 wmi_buf_t buf = 0;
4820 uint16_t len = 0;
4821 uint8_t *buf_ptr = NULL;
4822 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4823 wmi_resmgr_chan_time_quota chan_quota;
4824 uint32_t quota_chan1 = adapter_1_quota;
4825 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4826 uint32_t quota_chan2 = 100 - quota_chan1;
4827 /* Note: setting time quota for MCC requires info for 2 channels */
4828 uint32_t num_channels = 2;
4829 uint32_t chan1_freq = adapter_1_chan_freq;
4830 uint32_t chan2_freq = adapter_2_chan_freq;
4831
Govind Singhb53420c2016-03-09 14:32:57 +05304832 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304833 "freq2:%dMHz, Quota2:%dms", __func__,
4834 chan1_freq, quota_chan1, chan2_freq,
4835 quota_chan2);
4836
4837 /*
4838 * Perform sanity check on time quota values provided.
4839 */
4840 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4841 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304842 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304843 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304844 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304845 }
4846 /* Set WMI CMD for channel time quota here */
4847 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4848 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4849 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4850 buf = wmi_buf_alloc(wmi_handle, len);
4851 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304852 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4853 QDF_ASSERT(0);
4854 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304855 }
4856 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4857 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4858 wmi_buf_data(buf);
4859 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4860 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4861 WMITLV_GET_STRUCT_TLVLEN
4862 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4863 cmdTQ->num_chans = num_channels;
4864
4865 /* Update channel time quota information for home channel(s) */
4866 buf_ptr += sizeof(*cmdTQ);
4867 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4868 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4869 buf_ptr += WMI_TLV_HDR_SIZE;
4870 chan_quota.chan_mhz = chan1_freq;
4871 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304872 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304873 /* Construct channel and quota record for the 2nd MCC mode. */
4874 buf_ptr += sizeof(chan_quota);
4875 chan_quota.chan_mhz = chan2_freq;
4876 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304877 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304878
4879 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4880 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304881 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304882 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304883 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304884 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304885 }
Govind Singh67922e82016-04-01 16:48:57 +05304886
4887 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304888}
4889
4890/**
4891 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4892 * @wmi_handle: Pointer to wmi handle
4893 * @thermal_info: Thermal command information
4894 *
4895 * This function sends the thermal management command
4896 * to the firmware
4897 *
Govind Singhb53420c2016-03-09 14:32:57 +05304898 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304899 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304900static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304901 struct thermal_cmd_params *thermal_info)
4902{
4903 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4904 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304905 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304906 uint32_t len = 0;
4907
4908 len = sizeof(*cmd);
4909
4910 buf = wmi_buf_alloc(wmi_handle, len);
4911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304912 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4913 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304914 }
4915
4916 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4917
4918 WMITLV_SET_HDR(&cmd->tlv_header,
4919 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4920 WMITLV_GET_STRUCT_TLVLEN
4921 (wmi_thermal_mgmt_cmd_fixed_param));
4922
4923 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4924 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4925 cmd->enable = thermal_info->thermal_enable;
4926
Govind Singhb53420c2016-03-09 14:32:57 +05304927 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304928 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4929
4930 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4931 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304932 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304933 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304934 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304935 }
4936
Govind Singh67922e82016-04-01 16:48:57 +05304937 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304938}
4939
4940
4941/**
4942 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304943 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304944 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4945 *
4946 * This function sends down the LRO configuration parameters to
4947 * the firmware to enable LRO, sets the TCP flags and sets the
4948 * seed values for the toeplitz hash generation
4949 *
Govind Singhb53420c2016-03-09 14:32:57 +05304950 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304951 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304952static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304953 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4954{
4955 wmi_lro_info_cmd_fixed_param *cmd;
4956 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304957 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304958
4959
4960 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304962 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4963 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304964 }
4965
4966 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4967
4968 WMITLV_SET_HDR(&cmd->tlv_header,
4969 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4970 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4971
4972 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4973 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4974 wmi_lro_cmd->tcp_flag);
4975 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4976 wmi_lro_cmd->tcp_flag_mask);
4977 cmd->toeplitz_hash_ipv4_0_3 =
4978 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4979 cmd->toeplitz_hash_ipv4_4_7 =
4980 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4981 cmd->toeplitz_hash_ipv4_8_11 =
4982 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4983 cmd->toeplitz_hash_ipv4_12_15 =
4984 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4985 cmd->toeplitz_hash_ipv4_16 =
4986 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4987
4988 cmd->toeplitz_hash_ipv6_0_3 =
4989 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4990 cmd->toeplitz_hash_ipv6_4_7 =
4991 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4992 cmd->toeplitz_hash_ipv6_8_11 =
4993 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4994 cmd->toeplitz_hash_ipv6_12_15 =
4995 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4996 cmd->toeplitz_hash_ipv6_16_19 =
4997 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4998 cmd->toeplitz_hash_ipv6_20_23 =
4999 wmi_lro_cmd->toeplitz_hash_ipv6[5];
5000 cmd->toeplitz_hash_ipv6_24_27 =
5001 wmi_lro_cmd->toeplitz_hash_ipv6[6];
5002 cmd->toeplitz_hash_ipv6_28_31 =
5003 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5004 cmd->toeplitz_hash_ipv6_32_35 =
5005 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5006 cmd->toeplitz_hash_ipv6_36_39 =
5007 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5008 cmd->toeplitz_hash_ipv6_40 =
5009 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5010
Govind Singhb53420c2016-03-09 14:32:57 +05305011 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305012 cmd->lro_enable, cmd->tcp_flag_u32);
5013
5014 status = wmi_unified_cmd_send(wmi_handle, buf,
5015 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305016 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305017 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305018 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305019 }
5020
Govind Singh67922e82016-04-01 16:48:57 +05305021 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305022}
5023
Govind Singh4eacd2b2016-03-07 14:24:22 +05305024/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305025 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5026 * @wmi_handle: Pointer to wmi handle
5027 * @rate_report_params: Pointer to peer rate report parameters
5028 *
5029 *
5030 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5031 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305032static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305033 struct wmi_peer_rate_report_params *rate_report_params)
5034{
5035 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5036 wmi_buf_t buf = NULL;
5037 QDF_STATUS status = 0;
5038 uint32_t len = 0;
5039 uint32_t i, j;
5040
5041 len = sizeof(*cmd);
5042
5043 buf = wmi_buf_alloc(wmi_handle, len);
5044 if (!buf) {
5045 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5046 return QDF_STATUS_E_FAILURE;
5047 }
5048
5049 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5050 wmi_buf_data(buf);
5051
5052 WMITLV_SET_HDR(
5053 &cmd->tlv_header,
5054 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5055 WMITLV_GET_STRUCT_TLVLEN(
5056 wmi_peer_set_rate_report_condition_fixed_param));
5057
5058 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5059 cmd->report_backoff_time = rate_report_params->backoff_time;
5060 cmd->report_timer_period = rate_report_params->timer_period;
5061 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5062 cmd->cond_per_phy[i].val_cond_flags =
5063 rate_report_params->report_per_phy[i].cond_flags;
5064 cmd->cond_per_phy[i].rate_delta.min_delta =
5065 rate_report_params->report_per_phy[i].delta.delta_min;
5066 cmd->cond_per_phy[i].rate_delta.percentage =
5067 rate_report_params->report_per_phy[i].delta.percent;
5068 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5069 cmd->cond_per_phy[i].rate_threshold[j] =
5070 rate_report_params->report_per_phy[i].
5071 report_rate_threshold[j];
5072 }
5073 }
5074
5075 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5076 cmd->enable_rate_report,
5077 cmd->report_backoff_time, cmd->report_timer_period);
5078
5079 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5080 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5081 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305082 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305083 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5084 __func__);
5085 }
5086 return status;
5087}
5088
5089/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305090 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5091 * @wmi_handle: wmi handle
5092 * @param: bcn ll cmd parameter
5093 *
Govind Singhb53420c2016-03-09 14:32:57 +05305094 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305096static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305097 wmi_bcn_send_from_host_cmd_fixed_param *param)
5098{
5099 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5100 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305101 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305102
5103 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5104 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305105 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5106 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305107 }
5108
5109 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5110 WMITLV_SET_HDR(&cmd->tlv_header,
5111 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5112 WMITLV_GET_STRUCT_TLVLEN
5113 (wmi_bcn_send_from_host_cmd_fixed_param));
5114 cmd->vdev_id = param->vdev_id;
5115 cmd->data_len = param->data_len;
5116 cmd->frame_ctrl = param->frame_ctrl;
5117 cmd->frag_ptr = param->frag_ptr;
5118 cmd->dtim_flag = param->dtim_flag;
5119
5120 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5121 WMI_PDEV_SEND_BCN_CMDID);
5122
Govind Singh67922e82016-04-01 16:48:57 +05305123 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305124 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305125 wmi_buf_free(wmi_buf);
5126 }
5127
5128 return ret;
5129}
5130
5131/**
5132 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5133 * @wmi_handle: wmi handle
5134 * @vdev_id: vdev id
5135 * @max_retries: max retries
5136 * @retry_interval: retry interval
5137 * This function sets sta query related parameters in fw.
5138 *
Govind Singhb53420c2016-03-09 14:32:57 +05305139 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305140 */
5141
Sathish Kumarfd347372017-02-13 12:29:09 +05305142static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305143 uint8_t vdev_id, uint32_t max_retries,
5144 uint32_t retry_interval)
5145{
5146 wmi_buf_t buf;
5147 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5148 int len;
5149
5150 len = sizeof(*cmd);
5151 buf = wmi_buf_alloc(wmi_handle, len);
5152 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305153 WMI_LOGE(FL("wmi_buf_alloc failed"));
5154 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305155 }
5156
5157 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5158 WMITLV_SET_HDR(&cmd->tlv_header,
5159 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5160 WMITLV_GET_STRUCT_TLVLEN
5161 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5162
5163
5164 cmd->vdev_id = vdev_id;
5165 cmd->sa_query_max_retry_count = max_retries;
5166 cmd->sa_query_retry_interval = retry_interval;
5167
Govind Singhb53420c2016-03-09 14:32:57 +05305168 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305169 vdev_id, retry_interval, max_retries);
5170
5171 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5172 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305173 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305174 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305175 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305176 }
5177
Govind Singhb53420c2016-03-09 14:32:57 +05305178 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305179 return 0;
5180}
5181
5182/**
5183 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5184 * @wmi_handle: wmi handle
5185 * @params: sta keep alive parameter
5186 *
5187 * This function sets keep alive related parameters in fw.
5188 *
5189 * Return: CDF status
5190 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305191static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 struct sta_params *params)
5193{
5194 wmi_buf_t buf;
5195 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5196 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5197 uint8_t *buf_ptr;
5198 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305199 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305200
Govind Singhb53420c2016-03-09 14:32:57 +05305201 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305202
Govind Singh4eacd2b2016-03-07 14:24:22 +05305203 len = sizeof(*cmd) + sizeof(*arp_rsp);
5204 buf = wmi_buf_alloc(wmi_handle, len);
5205 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305206 WMI_LOGE("wmi_buf_alloc failed");
5207 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305208 }
5209
5210 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5211 buf_ptr = (uint8_t *) cmd;
5212 WMITLV_SET_HDR(&cmd->tlv_header,
5213 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5214 WMITLV_GET_STRUCT_TLVLEN
5215 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5216 cmd->interval = params->timeperiod;
5217 cmd->enable = (params->timeperiod) ? 1 : 0;
5218 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305219 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 params->timeperiod, params->method);
5221 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5222 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5223 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5224 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5225
c_manjee2772b9c2017-01-23 15:14:13 +05305226 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5227 (params->method ==
5228 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305229 if ((NULL == params->hostv4addr) ||
5230 (NULL == params->destv4addr) ||
5231 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005232 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5233 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305235 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305236 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237 }
c_manjee2772b9c2017-01-23 15:14:13 +05305238 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305239 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305241 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305242 WMI_IPV4_ADDR_LEN);
5243 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5244 } else {
5245 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5246 }
5247
Govind Singh67922e82016-04-01 16:48:57 +05305248 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5249 WMI_STA_KEEPALIVE_CMDID);
5250 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305251 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305252 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 }
5254
Govind Singhb53420c2016-03-09 14:32:57 +05305255 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305256 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305257}
5258
5259/**
5260 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5261 * @wmi_handle: wmi handle
5262 * @if_id: vdev id
5263 * @gtx_info: GTX config params
5264 *
5265 * This function set GTX related params in firmware.
5266 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305267 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305268 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305269static 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 +05305270 struct wmi_gtx_config *gtx_info)
5271{
5272 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5273 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305274 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305275 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305276
Govind Singh4eacd2b2016-03-07 14:24:22 +05305277 buf = wmi_buf_alloc(wmi_handle, len);
5278 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305279 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305280 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305281 }
5282 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5283 WMITLV_SET_HDR(&cmd->tlv_header,
5284 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5285 WMITLV_GET_STRUCT_TLVLEN
5286 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5287 cmd->vdev_id = if_id;
5288
5289 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5290 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5291 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5292 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5293 cmd->gtxPERMargin = gtx_info->gtx_margin;
5294 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5295 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5296 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5297
Govind Singhb53420c2016-03-09 14:32:57 +05305298 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305299 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5300 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5301 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5302 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5303
Abhishek Singh716c46c2016-05-04 16:24:07 +05305304 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305305 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305306 if (QDF_IS_STATUS_ERROR(ret)) {
5307 WMI_LOGE("Failed to set GTX PARAMS");
5308 wmi_buf_free(buf);
5309 }
5310 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305311}
5312
5313/**
5314 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5315 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305316 * @vdev_id: vdev id.
5317 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305318 *
5319 * This function updates EDCA parameters to the target
5320 *
5321 * Return: CDF Status
5322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305323static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005324 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305325 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305326{
5327 uint8_t *buf_ptr;
5328 wmi_buf_t buf;
5329 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305330 wmi_wmm_vparams *wmm_param;
5331 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305332 int len = sizeof(*cmd);
5333 int ac;
5334
5335 buf = wmi_buf_alloc(wmi_handle, len);
5336
5337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305338 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5339 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305340 }
5341
5342 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5343 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5344 WMITLV_SET_HDR(&cmd->tlv_header,
5345 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5346 WMITLV_GET_STRUCT_TLVLEN
5347 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5348 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005349 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305350
5351 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5352 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305353 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305354 WMITLV_SET_HDR(&wmm_param->tlv_header,
5355 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5356 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5357 wmm_param->cwmin = twmm_param->cwmin;
5358 wmm_param->cwmax = twmm_param->cwmax;
5359 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005360 if (mu_edca_param)
5361 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5362 else
5363 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305364 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305365 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305366 }
5367
5368 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5369 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5370 goto fail;
5371
Govind Singhb53420c2016-03-09 14:32:57 +05305372 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305373
5374fail:
5375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305376 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5377 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305378}
5379
5380/**
5381 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5382 * @wmi_handle: wmi handle
5383 * @vdev_id: vdev id
5384 * @probe_rsp_info: probe response info
5385 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305386 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305387 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305388static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305389 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005390 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305391{
5392 wmi_prb_tmpl_cmd_fixed_param *cmd;
5393 wmi_bcn_prb_info *bcn_prb_info;
5394 wmi_buf_t wmi_buf;
5395 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5396 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305397 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305398
Govind Singhb53420c2016-03-09 14:32:57 +05305399 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305400
Krunal Soni89426862017-11-14 15:42:48 -08005401 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305402 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305403
5404 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5405 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5406 tmpl_len_aligned;
5407
5408 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305409 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305410 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305411 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305412 }
5413
5414 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5415 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305416 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305417 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305418 }
5419
5420 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5421
5422 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5423 WMITLV_SET_HDR(&cmd->tlv_header,
5424 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5425 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5426 cmd->vdev_id = vdev_id;
5427 cmd->buf_len = tmpl_len;
5428 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5429
5430 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5431 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5432 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5433 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5434 bcn_prb_info->caps = 0;
5435 bcn_prb_info->erp = 0;
5436 buf_ptr += sizeof(wmi_bcn_prb_info);
5437
5438 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5439 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005440 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305441
5442 ret = wmi_unified_cmd_send(wmi_handle,
5443 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305444 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305445 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305446 wmi_buf_free(wmi_buf);
5447 }
5448
5449 return ret;
5450}
5451
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305452#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305453#define WPI_IV_LEN 16
5454
5455/**
5456 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5457 *
5458 * @dest_tx: destination address of tsc key counter
5459 * @src_tx: source address of tsc key counter
5460 * @dest_rx: destination address of rsc key counter
5461 * @src_rx: source address of rsc key counter
5462 *
5463 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5464 *
5465 * Return: None
5466 *
5467 */
5468static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5469 uint8_t *dest_rx, uint8_t *src_rx)
5470{
5471 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5472 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5473}
5474#else
5475static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5476 uint8_t *dest_rx, uint8_t *src_rx)
5477{
5478 return;
5479}
5480#endif
5481
5482/**
5483 * send_setup_install_key_cmd_tlv() - set key parameters
5484 * @wmi_handle: wmi handle
5485 * @key_params: key parameters
5486 *
5487 * This function fills structure from information
5488 * passed in key_params.
5489 *
5490 * Return: QDF_STATUS_SUCCESS - success
5491 * QDF_STATUS_E_FAILURE - failure
5492 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305494static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305495 struct set_key_params *key_params)
5496{
5497 wmi_vdev_install_key_cmd_fixed_param *cmd;
5498 wmi_buf_t buf;
5499 uint8_t *buf_ptr;
5500 uint32_t len;
5501 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305502 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305503
5504 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5505 WMI_TLV_HDR_SIZE;
5506
5507 buf = wmi_buf_alloc(wmi_handle, len);
5508 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305509 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305510 return QDF_STATUS_E_NOMEM;
5511 }
5512
5513 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5514 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5515 WMITLV_SET_HDR(&cmd->tlv_header,
5516 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5517 WMITLV_GET_STRUCT_TLVLEN
5518 (wmi_vdev_install_key_cmd_fixed_param));
5519 cmd->vdev_id = key_params->vdev_id;
5520 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305521
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305522
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305523 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5524 cmd->key_flags |= key_params->key_flags;
5525 cmd->key_cipher = key_params->key_cipher;
5526 if ((key_params->key_txmic_len) &&
5527 (key_params->key_rxmic_len)) {
5528 cmd->key_txmic_len = key_params->key_txmic_len;
5529 cmd->key_rxmic_len = key_params->key_rxmic_len;
5530 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305531#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305532 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5533 key_params->tx_iv,
5534 cmd->wpi_key_rsc_counter,
5535 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305536#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305537 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5538 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5539 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305540 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305541 qdf_mem_copy((void *)key_data,
5542 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005543 if (key_params->key_rsc_counter)
5544 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5545 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305546 cmd->key_len = key_params->key_len;
5547
5548 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5549 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305550 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305551 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305552
Govind Singh67922e82016-04-01 16:48:57 +05305553 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305554}
5555
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305556/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005557 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5558 * @wmi_handle: wmi handle
5559 * @params: sar limit params
5560 *
5561 * Return: QDF_STATUS_SUCCESS for success or error code
5562 */
5563static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5564 struct sar_limit_cmd_params *sar_limit_params)
5565{
5566 wmi_buf_t buf;
5567 QDF_STATUS qdf_status;
5568 wmi_sar_limits_cmd_fixed_param *cmd;
5569 int i;
5570 uint8_t *buf_ptr;
5571 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5572 struct sar_limit_cmd_row *sar_rows_list;
5573 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5574
5575 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5576 buf = wmi_buf_alloc(wmi_handle, len);
5577 if (!buf) {
5578 WMI_LOGE("Failed to allocate memory");
5579 qdf_status = QDF_STATUS_E_NOMEM;
5580 goto end;
5581 }
5582
5583 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5584 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5585 WMITLV_SET_HDR(&cmd->tlv_header,
5586 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5587 WMITLV_GET_STRUCT_TLVLEN
5588 (wmi_sar_limits_cmd_fixed_param));
5589 cmd->sar_enable = sar_limit_params->sar_enable;
5590 cmd->commit_limits = sar_limit_params->commit_limits;
5591 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5592
5593 WMI_LOGD("no of sar rows = %d, len = %d",
5594 sar_limit_params->num_limit_rows, len);
5595 buf_ptr += sizeof(*cmd);
5596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5597 sizeof(wmi_sar_limit_cmd_row) *
5598 sar_limit_params->num_limit_rows);
5599 if (cmd->num_limit_rows == 0)
5600 goto send_sar_limits;
5601
5602 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5603 (buf_ptr + WMI_TLV_HDR_SIZE);
5604 sar_rows_list = sar_limit_params->sar_limit_row_list;
5605
5606 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5607 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5608 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5609 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5610 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5611 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5612 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5613 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5614 wmi_sar_rows_list->validity_bitmap =
5615 sar_rows_list->validity_bitmap;
5616 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5617 i, wmi_sar_rows_list->band_id,
5618 wmi_sar_rows_list->chain_id,
5619 wmi_sar_rows_list->mod_id,
5620 wmi_sar_rows_list->limit_value,
5621 wmi_sar_rows_list->validity_bitmap);
5622 sar_rows_list++;
5623 wmi_sar_rows_list++;
5624 }
5625send_sar_limits:
5626 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5627 WMI_SAR_LIMITS_CMDID);
5628
5629 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5630 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5631 wmi_buf_free(buf);
5632 }
5633
5634end:
5635 return qdf_status;
5636}
5637
Jeff Johnson4783f902017-12-14 15:50:16 -08005638static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5639{
5640 wmi_sar_get_limits_cmd_fixed_param *cmd;
5641 wmi_buf_t wmi_buf;
5642 uint32_t len;
5643 QDF_STATUS status;
5644
5645 WMI_LOGD(FL("Enter"));
5646
5647 len = sizeof(*cmd);
5648 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5649 if (!wmi_buf) {
5650 WMI_LOGP(FL("failed to allocate memory for msg"));
5651 return QDF_STATUS_E_NOMEM;
5652 }
5653
5654 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5655
5656 WMITLV_SET_HDR(&cmd->tlv_header,
5657 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5658 WMITLV_GET_STRUCT_TLVLEN
5659 (wmi_sar_get_limits_cmd_fixed_param));
5660
5661 cmd->reserved = 0;
5662
5663 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5664 WMI_SAR_GET_LIMITS_CMDID);
5665 if (QDF_IS_STATUS_ERROR(status)) {
5666 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5667 wmi_buf_free(wmi_buf);
5668 }
5669
5670 WMI_LOGD(FL("Exit"));
5671
5672 return status;
5673}
5674
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005675/**
5676 * wmi_sar2_result_string() - return string conversion of sar2 result
5677 * @result: sar2 result value
5678 *
5679 * This utility function helps log string conversion of sar2 result.
5680 *
5681 * Return: string conversion of sar 2 result, if match found;
5682 * "Unknown response" otherwise.
5683 */
5684static const char *wmi_sar2_result_string(uint32_t result)
5685{
5686 switch (result) {
5687 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5688 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5689 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5690 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5691 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5692 default:
5693 return "Unknown response";
5694 }
5695}
5696
5697/**
5698 * extract_sar2_result_event_tlv() - process sar response event from FW.
5699 * @handle: wma handle
5700 * @event: event buffer
5701 * @len: buffer length
5702 *
5703 * Return: 0 for success or error code
5704 */
5705static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5706 uint8_t *event,
5707 uint32_t len)
5708{
5709 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5710
5711 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5712 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5713
5714 if (!param_buf) {
5715 WMI_LOGI("Invalid sar2 result event buffer");
5716 return QDF_STATUS_E_INVAL;
5717 }
5718
5719 sar2_fixed_param = param_buf->fixed_param;
5720 if (!sar2_fixed_param) {
5721 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5722 return QDF_STATUS_E_INVAL;
5723 }
5724
5725 WMI_LOGI("SAR2 result: %s",
5726 wmi_sar2_result_string(sar2_fixed_param->result));
5727
5728 return QDF_STATUS_SUCCESS;
5729}
5730
Jeff Johnson4783f902017-12-14 15:50:16 -08005731static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5732 uint8_t *evt_buf,
5733 struct sar_limit_event *event)
5734{
5735 wmi_sar_get_limits_event_fixed_param *fixed_param;
5736 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5737 wmi_sar_get_limit_event_row *row_in;
5738 struct sar_limit_event_row *row_out;
5739 uint32_t row;
5740
5741 if (!evt_buf) {
5742 WMI_LOGE(FL("input event is NULL"));
5743 return QDF_STATUS_E_INVAL;
5744 }
5745 if (!event) {
5746 WMI_LOGE(FL("output event is NULL"));
5747 return QDF_STATUS_E_INVAL;
5748 }
5749
5750 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5751
5752 fixed_param = param_buf->fixed_param;
5753 if (!fixed_param) {
5754 WMI_LOGE(FL("Invalid fixed param"));
5755 return QDF_STATUS_E_INVAL;
5756 }
5757
5758 event->sar_enable = fixed_param->sar_enable;
5759 event->num_limit_rows = fixed_param->num_limit_rows;
5760
5761 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5762 QDF_ASSERT(0);
5763 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5764 event->num_limit_rows,
5765 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5766 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5767 }
5768
5769 row_in = param_buf->sar_get_limits;
5770 row_out = &event->sar_limit_row[0];
5771 for (row = 0; row < event->num_limit_rows; row++) {
5772 row_out->band_id = row_in->band_id;
5773 row_out->chain_id = row_in->chain_id;
5774 row_out->mod_id = row_in->mod_id;
5775 row_out->limit_value = row_in->limit_value;
5776 row_out++;
5777 row_in++;
5778 }
5779
5780 return QDF_STATUS_SUCCESS;
5781}
5782
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305783#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005784/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305785 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5786 * @wmi_handle: wmi handle
5787 * @params: encrypt/decrypt params
5788 *
5789 * Return: QDF_STATUS_SUCCESS for success or error code
5790 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005791static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305792QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305793 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305794{
5795 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5796 wmi_buf_t wmi_buf;
5797 uint8_t *buf_ptr;
5798 QDF_STATUS ret;
5799 uint32_t len;
5800
5801 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5802
5803 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305804 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305805 WMI_TLV_HDR_SIZE;
5806 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5807 if (!wmi_buf) {
5808 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5809 __func__);
5810 return QDF_STATUS_E_NOMEM;
5811 }
5812
5813 buf_ptr = wmi_buf_data(wmi_buf);
5814 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5815
5816 WMITLV_SET_HDR(&cmd->tlv_header,
5817 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5818 WMITLV_GET_STRUCT_TLVLEN(
5819 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5820
5821 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5822 cmd->key_flag = encrypt_decrypt_params->key_flag;
5823 cmd->key_idx = encrypt_decrypt_params->key_idx;
5824 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5825 cmd->key_len = encrypt_decrypt_params->key_len;
5826 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5827 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5828
5829 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5830 encrypt_decrypt_params->key_len);
5831
5832 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5833 MAX_MAC_HEADER_LEN);
5834
5835 cmd->data_len = encrypt_decrypt_params->data_len;
5836
5837 if (cmd->data_len) {
5838 buf_ptr += sizeof(*cmd);
5839 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5840 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305841 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305842 buf_ptr += WMI_TLV_HDR_SIZE;
5843 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5844 encrypt_decrypt_params->data_len);
5845 }
5846
5847 /* This conversion is to facilitate data to FW in little endian */
5848 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5849 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5850 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5851 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5852 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5853 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5854
5855 ret = wmi_unified_cmd_send(wmi_handle,
5856 wmi_buf, len,
5857 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5858 if (QDF_IS_STATUS_ERROR(ret)) {
5859 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5860 wmi_buf_free(wmi_buf);
5861 }
5862
5863 return ret;
5864}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305865
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305866/**
5867 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5868 * params from event
5869 * @wmi_handle: wmi handle
5870 * @evt_buf: pointer to event buffer
5871 * @resp: Pointer to hold resp parameters
5872 *
5873 * Return: QDF_STATUS_SUCCESS for success or error code
5874 */
5875static
5876QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5877 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5878{
5879 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5880 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5881
5882 param_buf = evt_buf;
5883 if (!param_buf) {
5884 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5885 return QDF_STATUS_E_INVAL;
5886 }
5887
5888 data_event = param_buf->fixed_param;
5889
5890 resp->vdev_id = data_event->vdev_id;
5891 resp->status = data_event->status;
5892
Yeshwanth Sriram Guntukaa79e7f22018-06-22 18:25:45 +05305893 if ((data_event->data_length > param_buf->num_enc80211_frame) ||
5894 (data_event->data_length > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE -
5895 sizeof(*data_event))) {
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305896 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5897 data_event->data_length,
5898 param_buf->num_enc80211_frame);
5899 return QDF_STATUS_E_INVAL;
5900 }
5901
5902 resp->data_len = data_event->data_length;
5903
5904 if (resp->data_len)
5905 resp->data = (uint8_t *)param_buf->enc80211_frame;
5906
5907 return QDF_STATUS_SUCCESS;
5908}
5909#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305910
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911/**
5912 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5913 * @wmi_handle: wmi handle
5914 * @vdev_id: vdev id
5915 * @p2p_ie: p2p IE
5916 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305917 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305919static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305920 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305921{
Govind Singh67922e82016-04-01 16:48:57 +05305922 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305923 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5924 wmi_buf_t wmi_buf;
5925 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5926 uint8_t *buf_ptr;
5927
5928 ie_len = (uint32_t) (p2p_ie[1] + 2);
5929
5930 /* More than one P2P IE may be included in a single frame.
5931 If multiple P2P IEs are present, the complete P2P attribute
5932 data consists of the concatenation of the P2P Attribute
5933 fields of the P2P IEs. The P2P Attributes field of each
5934 P2P IE may be any length up to the maximum (251 octets).
5935 In this case host sends one P2P IE to firmware so the length
5936 should not exceed more than 251 bytes
5937 */
5938 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305939 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305940 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305941 }
5942
Vivekc5823092018-03-22 23:27:21 +05305943 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305944
5945 wmi_buf_len =
5946 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5947 WMI_TLV_HDR_SIZE;
5948
5949 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5950 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305951 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305952 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305953 }
5954
5955 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5956
5957 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5958 WMITLV_SET_HDR(&cmd->tlv_header,
5959 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5960 WMITLV_GET_STRUCT_TLVLEN
5961 (wmi_p2p_go_set_beacon_ie_fixed_param));
5962 cmd->vdev_id = vdev_id;
5963 cmd->ie_buf_len = ie_len;
5964
5965 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5966 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5967 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305968 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305969
Govind Singhb53420c2016-03-09 14:32:57 +05305970 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971
5972 ret = wmi_unified_cmd_send(wmi_handle,
5973 wmi_buf, wmi_buf_len,
5974 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305975 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305976 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305977 wmi_buf_free(wmi_buf);
5978 }
5979
Govind Singhb53420c2016-03-09 14:32:57 +05305980 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305981 return ret;
5982}
5983
5984/**
5985 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5986 * @wmi_handle: wmi handle
5987 * @req: gateway parameter update request structure
5988 *
5989 * This function reads the incoming @req and fill in the destination
5990 * WMI structure and sends down the gateway configs down to the firmware
5991 *
Govind Singhb53420c2016-03-09 14:32:57 +05305992 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305993 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305994static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305995 struct gateway_update_req_param *req)
5996{
5997 wmi_roam_subnet_change_config_fixed_param *cmd;
5998 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305999 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306000 int len = sizeof(*cmd);
6001
6002 buf = wmi_buf_alloc(wmi_handle, len);
6003 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306004 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6005 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 }
6007
6008 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6009 WMITLV_SET_HDR(&cmd->tlv_header,
6010 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6011 WMITLV_GET_STRUCT_TLVLEN(
6012 wmi_roam_subnet_change_config_fixed_param));
6013
6014 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306015 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6016 QDF_IPV4_ADDR_SIZE);
6017 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6018 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306019 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6020 &cmd->inet_gw_mac_addr);
6021 cmd->max_retries = req->max_retries;
6022 cmd->timeout = req->timeout;
6023 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6024 cmd->flag = 0;
6025 if (req->ipv4_addr_type)
6026 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6027
6028 if (req->ipv6_addr_type)
6029 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6030
6031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6032 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306033 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306034 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306035 ret);
6036 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306037 }
6038
Govind Singh67922e82016-04-01 16:48:57 +05306039 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306040}
6041
6042/**
6043 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6044 * @wmi_handle: wmi handle
6045 * @req: rssi monitoring request structure
6046 *
6047 * This function reads the incoming @req and fill in the destination
6048 * WMI structure and send down the rssi monitoring configs down to the firmware
6049 *
6050 * Return: 0 on success; error number otherwise
6051 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306052static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053 struct rssi_monitor_param *req)
6054{
6055 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6056 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306057 QDF_STATUS ret;
6058 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306059
6060 buf = wmi_buf_alloc(wmi_handle, len);
6061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306062 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6063 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064 }
6065
6066 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6067 WMITLV_SET_HDR(&cmd->tlv_header,
6068 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6069 WMITLV_GET_STRUCT_TLVLEN(
6070 wmi_rssi_breach_monitor_config_fixed_param));
6071
6072 cmd->vdev_id = req->session_id;
6073 cmd->request_id = req->request_id;
6074 cmd->lo_rssi_reenable_hysteresis = 0;
6075 cmd->hi_rssi_reenable_histeresis = 0;
6076 cmd->min_report_interval = 0;
6077 cmd->max_num_report = 1;
6078 if (req->control) {
6079 /* enable one threshold for each min/max */
6080 cmd->enabled_bitmap = 0x09;
6081 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6082 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6083 } else {
6084 cmd->enabled_bitmap = 0;
6085 cmd->low_rssi_breach_threshold[0] = 0;
6086 cmd->hi_rssi_breach_threshold[0] = 0;
6087 }
6088
6089 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6090 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306091 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306092 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306093 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306094 }
6095
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006096 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6097
Govind Singh67922e82016-04-01 16:48:57 +05306098 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306099}
6100
6101/**
6102 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6103 * @wmi_handle: wmi handle
6104 * @psetoui: OUI parameters
6105 *
6106 * set scan probe OUI parameters in firmware
6107 *
6108 * Return: CDF status
6109 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306110static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306111 struct scan_mac_oui *psetoui)
6112{
6113 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6114 wmi_buf_t wmi_buf;
6115 uint32_t len;
6116 uint8_t *buf_ptr;
6117 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306118 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306119
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306120 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6121 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6122
Govind Singh4eacd2b2016-03-07 14:24:22 +05306123 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6124 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306125 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6126 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306127 }
6128 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6129 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6130 WMITLV_SET_HDR(&cmd->tlv_header,
6131 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6132 WMITLV_GET_STRUCT_TLVLEN
6133 (wmi_scan_prob_req_oui_cmd_fixed_param));
6134
6135 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306136 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6138 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306139 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306140 cmd->prob_req_oui);
6141
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306142 cmd->vdev_id = psetoui->vdev_id;
6143 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6144 if (psetoui->enb_probe_req_sno_randomization)
6145 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6146
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306147 if (ie_whitelist->white_list) {
6148 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6149 &cmd->num_vendor_oui,
6150 ie_whitelist);
6151 cmd->flags |=
6152 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6153 }
6154
6155 buf_ptr += sizeof(*cmd);
6156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6157 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6158 buf_ptr += WMI_TLV_HDR_SIZE;
6159
6160 if (cmd->num_vendor_oui != 0) {
6161 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6162 ie_whitelist->voui);
6163 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6164 }
6165
Govind Singh4eacd2b2016-03-07 14:24:22 +05306166 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6167 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306168 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306169 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306170 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306171 }
Govind Singhb53420c2016-03-09 14:32:57 +05306172 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306173}
6174
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306175#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306176/**
6177 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6178 * @wmi_handle: wmi handle
6179 * @roam_req: Roam scan offload params
6180 * @buf_ptr: command buffer to send
6181 * @fils_tlv_len: fils tlv length
6182 *
6183 * Return: Updated buffer pointer
6184 */
6185static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6186 struct roam_offload_scan_params *roam_req,
6187 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6188{
6189 wmi_roam_fils_offload_tlv_param *fils_tlv;
6190 wmi_erp_info *erp_info;
6191 struct roam_fils_params *roam_fils_params;
6192
6193 if (!roam_req->add_fils_tlv)
6194 return buf_ptr;
6195
6196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6197 sizeof(*fils_tlv));
6198 buf_ptr += WMI_TLV_HDR_SIZE;
6199
6200 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6201 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6202 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6203 WMITLV_GET_STRUCT_TLVLEN
6204 (wmi_roam_fils_offload_tlv_param));
6205
6206 roam_fils_params = &roam_req->roam_fils_params;
6207 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6208
6209 erp_info->username_length = roam_fils_params->username_length;
6210 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6211 erp_info->username_length);
6212
6213 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6214
6215 erp_info->rRk_length = roam_fils_params->rrk_length;
6216 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6217 erp_info->rRk_length);
6218
6219 erp_info->rIk_length = roam_fils_params->rik_length;
6220 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6221 erp_info->rIk_length);
6222
6223 erp_info->realm_len = roam_fils_params->realm_len;
6224 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6225 erp_info->realm_len);
6226
6227 buf_ptr += sizeof(*fils_tlv);
6228 return buf_ptr;
6229}
6230#else
6231static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6232 struct roam_offload_scan_params *roam_req,
6233 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6234{
6235 return buf_ptr;
6236}
6237#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306238/**
6239 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6240 * @wmi_handle: wmi handle
6241 * @scan_cmd_fp: start scan command ptr
6242 * @roam_req: roam request param
6243 *
6244 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6245 * of WMI_ROAM_SCAN_MODE.
6246 *
6247 * Return: QDF status
6248 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306249static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306250 wmi_start_scan_cmd_fixed_param *
6251 scan_cmd_fp,
6252 struct roam_offload_scan_params *roam_req)
6253{
6254 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306255 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306256 int len;
6257 uint8_t *buf_ptr;
6258 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306259
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306260#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6261 int auth_mode = roam_req->auth_mode;
6262 wmi_roam_offload_tlv_param *roam_offload_params;
6263 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6264 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6265 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306266 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306267 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306268#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6269 /* Need to create a buf with roam_scan command at
6270 * front and piggyback with scan command */
6271 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6272#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6273 (2 * WMI_TLV_HDR_SIZE) +
6274#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6275 sizeof(wmi_start_scan_cmd_fixed_param);
6276#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006277 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306278 if (roam_req->is_roam_req_valid &&
6279 roam_req->roam_offload_enabled) {
6280 len += sizeof(wmi_roam_offload_tlv_param);
6281 len += WMI_TLV_HDR_SIZE;
6282 if ((auth_mode != WMI_AUTH_NONE) &&
6283 ((auth_mode != WMI_AUTH_OPEN) ||
6284 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306285 roam_req->mdid.mdie_present &&
6286 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306287 roam_req->is_ese_assoc)) {
6288 len += WMI_TLV_HDR_SIZE;
6289 if (roam_req->is_ese_assoc)
6290 len +=
6291 sizeof(wmi_roam_ese_offload_tlv_param);
6292 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6293 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6294 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306295 roam_req->mdid.mdie_present &&
6296 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306297 len +=
6298 sizeof(wmi_roam_11r_offload_tlv_param);
6299 else
6300 len +=
6301 sizeof(wmi_roam_11i_offload_tlv_param);
6302 } else {
6303 len += WMI_TLV_HDR_SIZE;
6304 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306305
6306 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6307 + roundup(roam_req->assoc_ie_length,
6308 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306309
6310 if (roam_req->add_fils_tlv) {
6311 fils_tlv_len = sizeof(
6312 wmi_roam_fils_offload_tlv_param);
6313 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6314 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306315 } else {
6316 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306317 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306318 __func__, roam_req->roam_offload_enabled);
6319 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306320 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306321 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306322 }
6323 if (roam_req->is_roam_req_valid &&
6324 roam_req->roam_offload_enabled) {
6325 roam_req->mode = roam_req->mode |
6326 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6327 }
6328#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6329
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306330 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6331 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6332 len = sizeof(wmi_roam_scan_mode_fixed_param);
6333
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306334 buf = wmi_buf_alloc(wmi_handle, len);
6335 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306336 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306337 return QDF_STATUS_E_NOMEM;
6338 }
6339
6340 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6341 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6342 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6343 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6344 WMITLV_GET_STRUCT_TLVLEN
6345 (wmi_roam_scan_mode_fixed_param));
6346
Abhinav Kumar334355f2018-04-06 17:18:52 +05306347 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6348 roam_req->roam_trigger_reason_bitmask;
6349 roam_scan_mode_fp->min_delay_btw_scans =
6350 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306351 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6352 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306353 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6354 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6355 roam_scan_mode_fp->flags |=
6356 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306357 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306358 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306359
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306360 /* Fill in scan parameters suitable for roaming scan */
6361 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306362
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306363 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6364 sizeof(wmi_start_scan_cmd_fixed_param));
6365 /* Ensure there is no additional IEs */
6366 scan_cmd_fp->ie_len = 0;
6367 WMITLV_SET_HDR(buf_ptr,
6368 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6369 WMITLV_GET_STRUCT_TLVLEN
6370 (wmi_start_scan_cmd_fixed_param));
6371#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6372 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6373 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6375 sizeof(wmi_roam_offload_tlv_param));
6376 buf_ptr += WMI_TLV_HDR_SIZE;
6377 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6378 WMITLV_SET_HDR(buf_ptr,
6379 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6380 WMITLV_GET_STRUCT_TLVLEN
6381 (wmi_roam_offload_tlv_param));
6382 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6383 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6384 roam_offload_params->select_5g_margin =
6385 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306386 roam_offload_params->handoff_delay_for_rx =
6387 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306388 roam_offload_params->reassoc_failure_timeout =
6389 roam_req->reassoc_failure_timeout;
6390
6391 /* Fill the capabilities */
6392 roam_offload_params->capability =
6393 roam_req->roam_offload_params.capability;
6394 roam_offload_params->ht_caps_info =
6395 roam_req->roam_offload_params.ht_caps_info;
6396 roam_offload_params->ampdu_param =
6397 roam_req->roam_offload_params.ampdu_param;
6398 roam_offload_params->ht_ext_cap =
6399 roam_req->roam_offload_params.ht_ext_cap;
6400 roam_offload_params->ht_txbf =
6401 roam_req->roam_offload_params.ht_txbf;
6402 roam_offload_params->asel_cap =
6403 roam_req->roam_offload_params.asel_cap;
6404 roam_offload_params->qos_caps =
6405 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006406 roam_offload_params->qos_enabled =
6407 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306408 roam_offload_params->wmm_caps =
6409 roam_req->roam_offload_params.wmm_caps;
6410 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6411 (uint8_t *)roam_req->roam_offload_params.mcsset,
6412 ROAM_OFFLOAD_NUM_MCS_SET);
6413
6414 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6415 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6416 * they are filled in the same order.Depending on the
6417 * authentication type, the other mode TLV's are nullified
6418 * and only headers are filled.*/
6419 if ((auth_mode != WMI_AUTH_NONE) &&
6420 ((auth_mode != WMI_AUTH_OPEN) ||
6421 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306422 && roam_req->mdid.mdie_present &&
6423 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306424 roam_req->is_ese_assoc)) {
6425 if (roam_req->is_ese_assoc) {
6426 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6427 WMITLV_GET_STRUCT_TLVLEN(0));
6428 buf_ptr += WMI_TLV_HDR_SIZE;
6429 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6430 WMITLV_GET_STRUCT_TLVLEN(0));
6431 buf_ptr += WMI_TLV_HDR_SIZE;
6432 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6433 sizeof(wmi_roam_ese_offload_tlv_param));
6434 buf_ptr += WMI_TLV_HDR_SIZE;
6435 roam_offload_ese =
6436 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6437 qdf_mem_copy(roam_offload_ese->krk,
6438 roam_req->krk,
6439 sizeof(roam_req->krk));
6440 qdf_mem_copy(roam_offload_ese->btk,
6441 roam_req->btk,
6442 sizeof(roam_req->btk));
6443 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6444 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6445 WMITLV_GET_STRUCT_TLVLEN
6446 (wmi_roam_ese_offload_tlv_param));
6447 buf_ptr +=
6448 sizeof(wmi_roam_ese_offload_tlv_param);
6449 } else if (auth_mode == WMI_AUTH_FT_RSNA
6450 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6451 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306452 && roam_req->mdid.mdie_present &&
6453 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306454 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6455 0);
6456 buf_ptr += WMI_TLV_HDR_SIZE;
6457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6458 sizeof(wmi_roam_11r_offload_tlv_param));
6459 buf_ptr += WMI_TLV_HDR_SIZE;
6460 roam_offload_11r =
6461 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6462 roam_offload_11r->r0kh_id_len =
6463 roam_req->rokh_id_length;
6464 qdf_mem_copy(roam_offload_11r->r0kh_id,
6465 roam_req->rokh_id,
6466 roam_offload_11r->r0kh_id_len);
6467 qdf_mem_copy(roam_offload_11r->psk_msk,
6468 roam_req->psk_pmk,
6469 sizeof(roam_req->psk_pmk));
6470 roam_offload_11r->psk_msk_len =
6471 roam_req->pmk_len;
6472 roam_offload_11r->mdie_present =
6473 roam_req->mdid.mdie_present;
6474 roam_offload_11r->mdid =
6475 roam_req->mdid.mobility_domain;
6476 if (auth_mode == WMI_AUTH_OPEN) {
6477 /* If FT-Open ensure pmk length
6478 and r0khid len are zero */
6479 roam_offload_11r->r0kh_id_len = 0;
6480 roam_offload_11r->psk_msk_len = 0;
6481 }
6482 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6483 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6484 WMITLV_GET_STRUCT_TLVLEN
6485 (wmi_roam_11r_offload_tlv_param));
6486 buf_ptr +=
6487 sizeof(wmi_roam_11r_offload_tlv_param);
6488 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6489 WMITLV_GET_STRUCT_TLVLEN(0));
6490 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006491 WMI_LOGD("psk_msk_len = %d",
6492 roam_offload_11r->psk_msk_len);
6493 if (roam_offload_11r->psk_msk_len)
6494 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6495 QDF_TRACE_LEVEL_DEBUG,
6496 roam_offload_11r->psk_msk,
6497 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306498 } else {
6499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6500 sizeof(wmi_roam_11i_offload_tlv_param));
6501 buf_ptr += WMI_TLV_HDR_SIZE;
6502 roam_offload_11i =
6503 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006504
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006505 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006506 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306507 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6508 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006509 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306510 } else {
6511 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6512 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006513 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006514 }
6515 if (roam_req->roam_key_mgmt_offload_enabled &&
6516 roam_req->fw_pmksa_cache) {
6517 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6518 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006519 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006520 } else {
6521 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6522 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006523 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306524 }
6525
6526 qdf_mem_copy(roam_offload_11i->pmk,
6527 roam_req->psk_pmk,
6528 sizeof(roam_req->psk_pmk));
6529 roam_offload_11i->pmk_len = roam_req->pmk_len;
6530 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6531 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6532 WMITLV_GET_STRUCT_TLVLEN
6533 (wmi_roam_11i_offload_tlv_param));
6534 buf_ptr +=
6535 sizeof(wmi_roam_11i_offload_tlv_param);
6536 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6537 0);
6538 buf_ptr += WMI_TLV_HDR_SIZE;
6539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6540 0);
6541 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006542 WMI_LOGD("pmk_len = %d",
6543 roam_offload_11i->pmk_len);
6544 if (roam_offload_11i->pmk_len)
6545 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6546 QDF_TRACE_LEVEL_DEBUG,
6547 roam_offload_11i->pmk,
6548 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306549 }
6550 } else {
6551 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6552 WMITLV_GET_STRUCT_TLVLEN(0));
6553 buf_ptr += WMI_TLV_HDR_SIZE;
6554 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6555 WMITLV_GET_STRUCT_TLVLEN(0));
6556 buf_ptr += WMI_TLV_HDR_SIZE;
6557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6558 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306559 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306560 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306561
6562 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6563 sizeof(*assoc_ies));
6564 buf_ptr += WMI_TLV_HDR_SIZE;
6565
6566 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6567 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6568 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6569 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6570 assoc_ies->buf_len = roam_req->assoc_ie_length;
6571
6572 buf_ptr += sizeof(*assoc_ies);
6573
6574 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6575 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6576 buf_ptr += WMI_TLV_HDR_SIZE;
6577
6578 if (assoc_ies->buf_len != 0) {
6579 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6580 assoc_ies->buf_len);
6581 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306582 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6583 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6584 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306585 } else {
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));
6591 buf_ptr += WMI_TLV_HDR_SIZE;
6592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6593 WMITLV_GET_STRUCT_TLVLEN(0));
6594 buf_ptr += WMI_TLV_HDR_SIZE;
6595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6596 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306597 buf_ptr += WMI_TLV_HDR_SIZE;
6598 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6599 WMITLV_GET_STRUCT_TLVLEN(0));
6600 buf_ptr += WMI_TLV_HDR_SIZE;
6601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6602 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306603 }
6604#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306605
6606send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306607 status = wmi_unified_cmd_send(wmi_handle, buf,
6608 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306609 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306610 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306611 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6612 status);
6613 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306614 }
6615
Govind Singh67922e82016-04-01 16:48:57 +05306616 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306617}
6618
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006619static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6620 struct wmi_mawc_roam_params *params)
6621{
6622 wmi_buf_t buf = NULL;
6623 QDF_STATUS status;
6624 int len;
6625 uint8_t *buf_ptr;
6626 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6627
6628 len = sizeof(*wmi_roam_mawc_params);
6629 buf = wmi_buf_alloc(wmi_handle, len);
6630 if (!buf) {
6631 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6632 return QDF_STATUS_E_NOMEM;
6633 }
6634
6635 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6636 wmi_roam_mawc_params =
6637 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6638 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6639 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6640 WMITLV_GET_STRUCT_TLVLEN
6641 (wmi_roam_configure_mawc_cmd_fixed_param));
6642 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6643 if (params->enable)
6644 wmi_roam_mawc_params->enable = 1;
6645 else
6646 wmi_roam_mawc_params->enable = 0;
6647 wmi_roam_mawc_params->traffic_load_threshold =
6648 params->traffic_load_threshold;
6649 wmi_roam_mawc_params->best_ap_rssi_threshold =
6650 params->best_ap_rssi_threshold;
6651 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6652 params->rssi_stationary_high_adjust;
6653 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6654 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006655 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6656 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6657 wmi_roam_mawc_params->traffic_load_threshold,
6658 wmi_roam_mawc_params->best_ap_rssi_threshold,
6659 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6660 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006661
6662 status = wmi_unified_cmd_send(wmi_handle, buf,
6663 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6664 if (QDF_IS_STATUS_ERROR(status)) {
6665 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6666 status);
6667 wmi_buf_free(buf);
6668 return status;
6669 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006670
6671 return QDF_STATUS_SUCCESS;
6672}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306673
6674/**
6675 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6676 * rssi threashold
6677 * @wmi_handle: wmi handle
6678 * @roam_req: Roaming request buffer
6679 *
6680 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6681 *
6682 * Return: QDF status
6683 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306684static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306685 struct roam_offload_scan_rssi_params *roam_req)
6686{
6687 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306688 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306689 int len;
6690 uint8_t *buf_ptr;
6691 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6692 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6693 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306694 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006695 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306696
6697 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6698 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6699 len += sizeof(wmi_roam_scan_extended_threshold_param);
6700 len += WMI_TLV_HDR_SIZE;
6701 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306702 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6703 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006704 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6705 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306706 buf = wmi_buf_alloc(wmi_handle, len);
6707 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306708 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306709 return QDF_STATUS_E_NOMEM;
6710 }
6711
6712 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6713 rssi_threshold_fp =
6714 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6715 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6716 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6717 WMITLV_GET_STRUCT_TLVLEN
6718 (wmi_roam_scan_rssi_threshold_fixed_param));
6719 /* fill in threshold values */
6720 rssi_threshold_fp->vdev_id = roam_req->session_id;
6721 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6722 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6723 rssi_threshold_fp->hirssi_scan_max_count =
6724 roam_req->hi_rssi_scan_max_count;
6725 rssi_threshold_fp->hirssi_scan_delta =
6726 roam_req->hi_rssi_scan_rssi_delta;
6727 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006728 rssi_threshold_fp->rssi_thresh_offset_5g =
6729 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306730
6731 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6732 WMITLV_SET_HDR(buf_ptr,
6733 WMITLV_TAG_ARRAY_STRUC,
6734 sizeof(wmi_roam_scan_extended_threshold_param));
6735 buf_ptr += WMI_TLV_HDR_SIZE;
6736 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6737
6738 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6739 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6740 ext_thresholds->boost_threshold_5g =
6741 roam_req->boost_threshold_5g;
6742
6743 ext_thresholds->boost_algorithm_5g =
6744 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6745 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6746 ext_thresholds->penalty_algorithm_5g =
6747 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6748 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6749 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6750 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6751 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6752
6753 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6754 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6755 WMITLV_GET_STRUCT_TLVLEN
6756 (wmi_roam_scan_extended_threshold_param));
6757 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6758 WMITLV_SET_HDR(buf_ptr,
6759 WMITLV_TAG_ARRAY_STRUC,
6760 sizeof(wmi_roam_earlystop_rssi_thres_param));
6761 buf_ptr += WMI_TLV_HDR_SIZE;
6762 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6763 early_stop_thresholds->roam_earlystop_thres_min =
6764 roam_req->roam_earlystop_thres_min;
6765 early_stop_thresholds->roam_earlystop_thres_max =
6766 roam_req->roam_earlystop_thres_max;
6767 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6768 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6769 WMITLV_GET_STRUCT_TLVLEN
6770 (wmi_roam_earlystop_rssi_thres_param));
6771
Gupta, Kapil7e652922016-04-12 15:02:00 +05306772 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6773 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6774 sizeof(wmi_roam_dense_thres_param));
6775 buf_ptr += WMI_TLV_HDR_SIZE;
6776 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6777 dense_thresholds->roam_dense_rssi_thres_offset =
6778 roam_req->dense_rssi_thresh_offset;
6779 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6780 dense_thresholds->roam_dense_traffic_thres =
6781 roam_req->traffic_threshold;
6782 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6783 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6784 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6785 WMITLV_GET_STRUCT_TLVLEN
6786 (wmi_roam_dense_thres_param));
6787
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006788 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6789 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6790 sizeof(wmi_roam_bg_scan_roaming_param));
6791 buf_ptr += WMI_TLV_HDR_SIZE;
6792 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6793 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6794 roam_req->bg_scan_bad_rssi_thresh;
6795 bg_scan_params->roam_bg_scan_client_bitmap =
6796 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306797 bg_scan_params->bad_rssi_thresh_offset_2g =
6798 roam_req->roam_bad_rssi_thresh_offset_2g;
6799 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006800 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6801 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6802 WMITLV_GET_STRUCT_TLVLEN
6803 (wmi_roam_bg_scan_roaming_param));
6804
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306805 status = wmi_unified_cmd_send(wmi_handle, buf,
6806 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306807 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306808 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306809 status);
6810 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306811 }
6812
Govind Singh67922e82016-04-01 16:48:57 +05306813 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306814}
6815
6816/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306817 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6818 * configuration params
6819 * @wma_handle: wma handler
6820 * @dwelltime_params: pointer to dwelltime_params
6821 *
6822 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6823 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006824static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306825QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6826 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6827{
6828 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6829 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6830 wmi_buf_t buf;
6831 uint8_t *buf_ptr;
6832 int32_t err;
6833 int len;
6834
6835 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6836 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6837 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6838 buf = wmi_buf_alloc(wmi_handle, len);
6839 if (!buf) {
6840 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6841 __func__);
6842 return QDF_STATUS_E_NOMEM;
6843 }
6844 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6845 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6846 WMITLV_SET_HDR(&dwell_param->tlv_header,
6847 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6848 WMITLV_GET_STRUCT_TLVLEN
6849 (wmi_scan_adaptive_dwell_config_fixed_param));
6850
6851 dwell_param->enable = dwelltime_params->is_enabled;
6852 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6853 WMITLV_SET_HDR(buf_ptr,
6854 WMITLV_TAG_ARRAY_STRUC,
6855 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6856 buf_ptr += WMI_TLV_HDR_SIZE;
6857
6858 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6859 WMITLV_SET_HDR(&cmd->tlv_header,
6860 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6861 WMITLV_GET_STRUCT_TLVLEN(
6862 wmi_scan_adaptive_dwell_parameters_tlv));
6863
6864 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6865 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6866 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6867 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6868 err = wmi_unified_cmd_send(wmi_handle, buf,
6869 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6870 if (err) {
6871 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6872 wmi_buf_free(buf);
6873 return QDF_STATUS_E_FAILURE;
6874 }
6875
6876 return QDF_STATUS_SUCCESS;
6877}
6878
Nitesh Shah52323d02017-05-22 15:49:00 +05306879/**
6880 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6881 * configuration params
6882 * @wmi_handle: wmi handler
6883 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6884 *
6885 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6886 */
6887static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6888 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6889{
6890 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6891 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6892 wmi_buf_t buf;
6893 uint8_t *buf_ptr;
6894 QDF_STATUS err;
6895 uint32_t i;
6896 int len;
6897
6898 len = sizeof(*dbs_scan_param);
6899 len += WMI_TLV_HDR_SIZE;
6900 len += dbs_scan_params->num_clients * sizeof(*cmd);
6901
6902 buf = wmi_buf_alloc(wmi_handle, len);
6903 if (!buf) {
6904 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6905 return QDF_STATUS_E_NOMEM;
6906 }
6907
6908 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6909 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6910 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6911 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6912 WMITLV_GET_STRUCT_TLVLEN
6913 (wmi_scan_dbs_duty_cycle_fixed_param));
6914
6915 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6916 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6917 buf_ptr += sizeof(*dbs_scan_param);
6918 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6919 (sizeof(*cmd) * dbs_scan_params->num_clients));
6920 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6921
6922 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6923 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6924 WMITLV_SET_HDR(&cmd->tlv_header,
6925 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6926 WMITLV_GET_STRUCT_TLVLEN(
6927 wmi_scan_dbs_duty_cycle_tlv_param));
6928 cmd->module_id = dbs_scan_params->module_id[i];
6929 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6930 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6931 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6932 }
6933
6934 err = wmi_unified_cmd_send(wmi_handle, buf,
6935 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6936 if (QDF_IS_STATUS_ERROR(err)) {
6937 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6938 wmi_buf_free(buf);
6939 return QDF_STATUS_E_FAILURE;
6940 }
6941
6942 return QDF_STATUS_SUCCESS;
6943}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306944
6945/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306946 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6947 * @wmi_handle: wmi handle
6948 * @roam_req: Request which contains the filters
6949 *
6950 * There are filters such as whitelist, blacklist and preferred
6951 * list that need to be applied to the scan results to form the
6952 * probable candidates for roaming.
6953 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006954 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306955 * parameters to the firmware, otherwise failure.
6956 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306957static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306958 struct roam_scan_filter_params *roam_req)
6959{
6960 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306961 QDF_STATUS status;
6962 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306963 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306964 uint8_t *buf_ptr;
6965 wmi_roam_filter_fixed_param *roam_filter;
6966 uint8_t *bssid_src_ptr = NULL;
6967 wmi_mac_addr *bssid_dst_ptr = NULL;
6968 wmi_ssid *ssid_ptr = NULL;
6969 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306970 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306971 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306972
6973 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306974
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306975 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306976 if (roam_req->num_bssid_black_list)
6977 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6978 len += WMI_TLV_HDR_SIZE;
6979 if (roam_req->num_ssid_white_list)
6980 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6981 len += 2 * WMI_TLV_HDR_SIZE;
6982 if (roam_req->num_bssid_preferred_list) {
6983 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306984 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306985 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306986 len += WMI_TLV_HDR_SIZE;
6987 if (roam_req->lca_disallow_config_present) {
6988 len += sizeof(*blist_param);
6989 blist_len = sizeof(*blist_param);
6990 }
6991
6992 len += WMI_TLV_HDR_SIZE;
6993 if (roam_req->num_rssi_rejection_ap)
6994 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306995
6996 buf = wmi_buf_alloc(wmi_handle, len);
6997 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306998 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306999 return QDF_STATUS_E_NOMEM;
7000 }
7001
7002 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7003 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
7004 WMITLV_SET_HDR(&roam_filter->tlv_header,
7005 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7006 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7007 /* fill in fixed values */
7008 roam_filter->vdev_id = roam_req->session_id;
7009 roam_filter->flags = 0;
7010 roam_filter->op_bitmap = roam_req->op_bitmap;
7011 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7012 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7013 roam_filter->num_bssid_preferred_list =
7014 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307015 roam_filter->num_rssi_rejection_ap =
7016 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307017 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7018
7019 WMITLV_SET_HDR((buf_ptr),
7020 WMITLV_TAG_ARRAY_FIXED_STRUC,
7021 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7022 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7023 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7024 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7025 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7026 bssid_src_ptr += ATH_MAC_LEN;
7027 bssid_dst_ptr++;
7028 }
7029 buf_ptr += WMI_TLV_HDR_SIZE +
7030 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7031 WMITLV_SET_HDR((buf_ptr),
7032 WMITLV_TAG_ARRAY_FIXED_STRUC,
7033 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7034 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7035 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7036 qdf_mem_copy(&ssid_ptr->ssid,
7037 &roam_req->ssid_allowed_list[i].mac_ssid,
7038 roam_req->ssid_allowed_list[i].length);
7039 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7040 ssid_ptr++;
7041 }
7042 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7043 sizeof(wmi_ssid));
7044 WMITLV_SET_HDR((buf_ptr),
7045 WMITLV_TAG_ARRAY_FIXED_STRUC,
7046 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7047 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7048 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7049 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7050 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7051 (wmi_mac_addr *)bssid_dst_ptr);
7052 bssid_src_ptr += ATH_MAC_LEN;
7053 bssid_dst_ptr++;
7054 }
7055 buf_ptr += WMI_TLV_HDR_SIZE +
7056 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7057 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7058 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7059 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7060 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7061 *bssid_preferred_factor_ptr =
7062 roam_req->bssid_favored_factor[i];
7063 bssid_preferred_factor_ptr++;
7064 }
7065 buf_ptr += WMI_TLV_HDR_SIZE +
7066 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7067
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307068 WMITLV_SET_HDR(buf_ptr,
7069 WMITLV_TAG_ARRAY_STRUC, blist_len);
7070 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307071 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307072 blist_param =
7073 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7074 WMITLV_SET_HDR(&blist_param->tlv_header,
7075 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7076 WMITLV_GET_STRUCT_TLVLEN(
7077 wmi_roam_lca_disallow_config_tlv_param));
7078
7079 blist_param->disallow_duration = roam_req->disallow_duration;
7080 blist_param->rssi_channel_penalization =
7081 roam_req->rssi_channel_penalization;
7082 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307083 blist_param->disallow_lca_enable_source_bitmap =
7084 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7085 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307086 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7087 }
7088
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307089 WMITLV_SET_HDR(buf_ptr,
7090 WMITLV_TAG_ARRAY_STRUC,
7091 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7092 buf_ptr += WMI_TLV_HDR_SIZE;
7093 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7094 rssi_rej =
7095 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7096 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7097 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7098 WMITLV_GET_STRUCT_TLVLEN(
7099 wmi_roam_rssi_rejection_oce_config_param));
7100 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7101 roam_req->rssi_rejection_ap[i].bssid.bytes,
7102 &rssi_rej->bssid);
7103 rssi_rej->remaining_disallow_duration =
7104 roam_req->rssi_rejection_ap[i].remaining_duration;
7105 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307106 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307107 buf_ptr +=
7108 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7109 }
7110
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307111 status = wmi_unified_cmd_send(wmi_handle, buf,
7112 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307113 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307114 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307115 status);
7116 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307117 }
Govind Singh67922e82016-04-01 16:48:57 +05307118
7119 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307120}
7121
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307122#if defined(WLAN_FEATURE_FILS_SK)
7123static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7124 struct hlp_params *params)
7125{
7126 uint32_t len;
7127 uint8_t *buf_ptr;
7128 wmi_buf_t buf = NULL;
7129 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7130
7131 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7132 len += WMI_TLV_HDR_SIZE;
7133 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7134
7135 buf = wmi_buf_alloc(wmi_handle, len);
7136 if (!buf) {
7137 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7138 return QDF_STATUS_E_NOMEM;
7139 }
7140
7141 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7142 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7143 WMITLV_SET_HDR(&hlp_params->tlv_header,
7144 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7145 WMITLV_GET_STRUCT_TLVLEN(
7146 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7147
7148 hlp_params->vdev_id = params->vdev_id;
7149 hlp_params->size = params->hlp_ie_len;
7150 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7151
7152 buf_ptr += sizeof(*hlp_params);
7153
7154 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7155 round_up(params->hlp_ie_len,
7156 sizeof(uint32_t)));
7157 buf_ptr += WMI_TLV_HDR_SIZE;
7158 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7159
7160 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7161 hlp_params->vdev_id, hlp_params->size);
7162 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7163 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7164 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7165 wmi_buf_free(buf);
7166 return QDF_STATUS_E_FAILURE;
7167 }
7168
7169 return QDF_STATUS_SUCCESS;
7170}
7171#endif
7172
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307173#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307174/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7175 * @wmi_handle: wmi handle
7176 * @ipa_offload: ipa offload control parameter
7177 *
7178 * Returns: 0 on success, error number otherwise
7179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307180static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307181 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307182{
7183 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7184 wmi_buf_t wmi_buf;
7185 uint32_t len;
7186 u_int8_t *buf_ptr;
7187
7188 len = sizeof(*cmd);
7189 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7190 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307191 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7192 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307193 }
7194
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007195 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307196 ipa_offload->offload_type, ipa_offload->enable);
7197
7198 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7199
7200 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7201 WMITLV_SET_HDR(&cmd->tlv_header,
7202 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7203 WMITLV_GET_STRUCT_TLVLEN(
7204 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7205
7206 cmd->offload_type = ipa_offload->offload_type;
7207 cmd->vdev_id = ipa_offload->vdev_id;
7208 cmd->enable = ipa_offload->enable;
7209
7210 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7211 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307212 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307213 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307214 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215 }
7216
Govind Singhb53420c2016-03-09 14:32:57 +05307217 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307218}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307219#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220
7221/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307222 * send_plm_stop_cmd_tlv() - plm stop request
7223 * @wmi_handle: wmi handle
7224 * @plm: plm request parameters
7225 *
7226 * This function request FW to stop PLM.
7227 *
7228 * Return: CDF status
7229 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307230static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307231 const struct plm_req_params *plm)
7232{
7233 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7234 int32_t len;
7235 wmi_buf_t buf;
7236 uint8_t *buf_ptr;
7237 int ret;
7238
7239 len = sizeof(*cmd);
7240 buf = wmi_buf_alloc(wmi_handle, len);
7241 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307242 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7243 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307244 }
7245
7246 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7247
7248 buf_ptr = (uint8_t *) cmd;
7249
7250 WMITLV_SET_HDR(&cmd->tlv_header,
7251 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7252 WMITLV_GET_STRUCT_TLVLEN
7253 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7254
7255 cmd->vdev_id = plm->session_id;
7256
7257 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307258 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307259
7260 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7261 WMI_VDEV_PLMREQ_STOP_CMDID);
7262 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307263 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307264 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307265 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307266 }
7267
Govind Singhb53420c2016-03-09 14:32:57 +05307268 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307269}
7270
7271/**
7272 * send_plm_start_cmd_tlv() - plm start request
7273 * @wmi_handle: wmi handle
7274 * @plm: plm request parameters
7275 *
7276 * This function request FW to start PLM.
7277 *
7278 * Return: CDF status
7279 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307280static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281 const struct plm_req_params *plm,
7282 uint32_t *gchannel_list)
7283{
7284 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7285 uint32_t *channel_list;
7286 int32_t len;
7287 wmi_buf_t buf;
7288 uint8_t *buf_ptr;
7289 uint8_t count;
7290 int ret;
7291
7292 /* TLV place holder for channel_list */
7293 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7294 len += sizeof(uint32_t) * plm->plm_num_ch;
7295
7296 buf = wmi_buf_alloc(wmi_handle, len);
7297 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307298 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7299 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307300 }
7301 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7302
7303 buf_ptr = (uint8_t *) cmd;
7304
7305 WMITLV_SET_HDR(&cmd->tlv_header,
7306 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7307 WMITLV_GET_STRUCT_TLVLEN
7308 (wmi_vdev_plmreq_start_cmd_fixed_param));
7309
7310 cmd->vdev_id = plm->session_id;
7311
7312 cmd->meas_token = plm->meas_token;
7313 cmd->dialog_token = plm->diag_token;
7314 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307315 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307316 cmd->off_duration = plm->meas_duration;
7317 cmd->burst_cycle = plm->burst_len;
7318 cmd->tx_power = plm->desired_tx_pwr;
7319 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7320 cmd->num_chans = plm->plm_num_ch;
7321
7322 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7323
Govind Singhb53420c2016-03-09 14:32:57 +05307324 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7325 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7326 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7327 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7328 WMI_LOGD("off_duration: %d", cmd->off_duration);
7329 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7330 WMI_LOGD("tx_power: %d", cmd->tx_power);
7331 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307332
7333 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7334 (cmd->num_chans * sizeof(uint32_t)));
7335
7336 buf_ptr += WMI_TLV_HDR_SIZE;
7337 if (cmd->num_chans) {
7338 channel_list = (uint32_t *) buf_ptr;
7339 for (count = 0; count < cmd->num_chans; count++) {
7340 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307341 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307342 channel_list[count] =
7343 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307344 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307345 }
7346 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7347 }
7348
7349 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7350 WMI_VDEV_PLMREQ_START_CMDID);
7351 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307352 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307353 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307354 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307355 }
7356
Govind Singhb53420c2016-03-09 14:32:57 +05307357 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307358}
7359
7360/**
7361 * send_pno_stop_cmd_tlv() - PNO stop request
7362 * @wmi_handle: wmi handle
7363 * @vdev_id: vdev id
7364 *
7365 * This function request FW to stop ongoing PNO operation.
7366 *
7367 * Return: CDF status
7368 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307369static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307370{
7371 wmi_nlo_config_cmd_fixed_param *cmd;
7372 int32_t len = sizeof(*cmd);
7373 wmi_buf_t buf;
7374 uint8_t *buf_ptr;
7375 int ret;
7376
7377 /*
7378 * TLV place holder for array of structures nlo_configured_parameters
7379 * TLV place holder for array of uint32_t channel_list
7380 * TLV place holder for chnl prediction cfg
7381 */
7382 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7383 buf = wmi_buf_alloc(wmi_handle, len);
7384 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307385 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7386 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307387 }
7388
7389 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7390 buf_ptr = (uint8_t *) cmd;
7391
7392 WMITLV_SET_HDR(&cmd->tlv_header,
7393 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7394 WMITLV_GET_STRUCT_TLVLEN
7395 (wmi_nlo_config_cmd_fixed_param));
7396
7397 cmd->vdev_id = vdev_id;
7398 cmd->flags = WMI_NLO_CONFIG_STOP;
7399 buf_ptr += sizeof(*cmd);
7400
7401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7402 buf_ptr += WMI_TLV_HDR_SIZE;
7403
7404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7405 buf_ptr += WMI_TLV_HDR_SIZE;
7406
7407 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7408 buf_ptr += WMI_TLV_HDR_SIZE;
7409
7410
7411 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7412 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7413 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307414 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307415 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307416 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307417 }
7418
Govind Singhb53420c2016-03-09 14:32:57 +05307419 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307420}
7421
7422/**
Govind Singhccb0c272016-04-01 16:30:08 +05307423 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7424 * @buf_ptr: Buffer passed by upper layers
7425 * @pno: Buffer to be sent to the firmware
7426 *
7427 * Copy the PNO Channel prediction configuration parameters
7428 * passed by the upper layers to a WMI format TLV and send it
7429 * down to the firmware.
7430 *
7431 * Return: None
7432 */
7433static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7434 struct pno_scan_req_params *pno)
7435{
7436 nlo_channel_prediction_cfg *channel_prediction_cfg =
7437 (nlo_channel_prediction_cfg *) buf_ptr;
7438 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7439 WMITLV_TAG_ARRAY_BYTE,
7440 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307441#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307442 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7443 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7444 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7445 channel_prediction_cfg->full_scan_period_ms =
7446 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307447#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307448 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7449 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7450 channel_prediction_cfg->enable,
7451 channel_prediction_cfg->top_k_num,
7452 channel_prediction_cfg->stationary_threshold,
7453 channel_prediction_cfg->full_scan_period_ms);
7454}
7455
7456/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007457 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7458 * @wmi_handle: wmi handle
7459 * @params: configuration parameters
7460 *
7461 * Return: QDF_STATUS
7462 */
7463static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7464 struct nlo_mawc_params *params)
7465{
7466 wmi_buf_t buf = NULL;
7467 QDF_STATUS status;
7468 int len;
7469 uint8_t *buf_ptr;
7470 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7471
7472 len = sizeof(*wmi_nlo_mawc_params);
7473 buf = wmi_buf_alloc(wmi_handle, len);
7474 if (!buf) {
7475 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7476 return QDF_STATUS_E_NOMEM;
7477 }
7478
7479 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7480 wmi_nlo_mawc_params =
7481 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7482 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7483 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7484 WMITLV_GET_STRUCT_TLVLEN
7485 (wmi_nlo_configure_mawc_cmd_fixed_param));
7486 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7487 if (params->enable)
7488 wmi_nlo_mawc_params->enable = 1;
7489 else
7490 wmi_nlo_mawc_params->enable = 0;
7491 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7492 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7493 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007494 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7495 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7496 wmi_nlo_mawc_params->exp_backoff_ratio,
7497 wmi_nlo_mawc_params->init_scan_interval,
7498 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007499
7500 status = wmi_unified_cmd_send(wmi_handle, buf,
7501 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7502 if (QDF_IS_STATUS_ERROR(status)) {
7503 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7504 status);
7505 wmi_buf_free(buf);
7506 return QDF_STATUS_E_FAILURE;
7507 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007508
7509 return QDF_STATUS_SUCCESS;
7510}
7511
7512/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307513 * send_pno_start_cmd_tlv() - PNO start request
7514 * @wmi_handle: wmi handle
7515 * @pno: PNO request
7516 *
7517 * This function request FW to start PNO request.
7518 * Request: CDF status
7519 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307520static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307521 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307522{
7523 wmi_nlo_config_cmd_fixed_param *cmd;
7524 nlo_configured_parameters *nlo_list;
7525 uint32_t *channel_list;
7526 int32_t len;
7527 wmi_buf_t buf;
7528 uint8_t *buf_ptr;
7529 uint8_t i;
7530 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307531 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307532 connected_nlo_rssi_params *nlo_relative_rssi;
7533 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307534
7535 /*
7536 * TLV place holder for array nlo_configured_parameters(nlo_list)
7537 * TLV place holder for array of uint32_t channel_list
7538 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307539 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307540 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307541 */
7542 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307543 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307544 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307545
Abhishek Singh5987b632017-03-03 22:09:07 +05307546 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307547 WMI_NLO_MAX_CHAN);
7548 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307549 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307550 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307551 len += sizeof(enlo_candidate_score_params);
7552 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307553 len += sizeof(connected_nlo_rssi_params);
7554 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307555
7556 buf = wmi_buf_alloc(wmi_handle, len);
7557 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307558 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7559 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307560 }
7561
7562 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7563
7564 buf_ptr = (uint8_t *) cmd;
7565 WMITLV_SET_HDR(&cmd->tlv_header,
7566 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7567 WMITLV_GET_STRUCT_TLVLEN
7568 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307569 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307570 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7571
Govind Singh87542482016-06-08 19:40:11 +05307572#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307573 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307574 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307575#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307576 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307577 cmd->active_dwell_time = pno->active_dwell_time;
7578 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307579
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307580 if (pno->do_passive_scan)
7581 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307582 /* Copy scan interval */
7583 cmd->fast_scan_period = pno->fast_scan_period;
7584 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007585 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307586 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007587 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307588 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307589 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307590 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307591
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307592 /* mac randomization attributes */
7593 if (pno->scan_random.randomize) {
7594 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7595 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7596 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7597 pno->scan_random.mac_mask,
7598 &cmd->mac_addr,
7599 &cmd->mac_mask);
7600 }
7601
Govind Singh4eacd2b2016-03-07 14:24:22 +05307602 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7603
Abhishek Singh5987b632017-03-03 22:09:07 +05307604 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307605 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307606 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7607 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7608 buf_ptr += WMI_TLV_HDR_SIZE;
7609
7610 nlo_list = (nlo_configured_parameters *) buf_ptr;
7611 for (i = 0; i < cmd->no_of_ssids; i++) {
7612 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7613 WMITLV_TAG_ARRAY_BYTE,
7614 WMITLV_GET_STRUCT_TLVLEN
7615 (nlo_configured_parameters));
7616 /* Copy ssid and it's length */
7617 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307618 nlo_list[i].ssid.ssid.ssid_len =
7619 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307620 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307621 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307622 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307623 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307624 nlo_list[i].ssid.ssid.ssid_len,
7625 (char *)nlo_list[i].ssid.ssid.ssid,
7626 nlo_list[i].ssid.ssid.ssid_len);
7627
7628 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307629 if (pno->networks_list[i].rssi_thresh &&
7630 pno->networks_list[i].rssi_thresh >
7631 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307632 nlo_list[i].rssi_cond.valid = true;
7633 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307634 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307635 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307636 nlo_list[i].rssi_cond.rssi);
7637 }
7638 nlo_list[i].bcast_nw_type.valid = true;
7639 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307640 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007641 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642 nlo_list[i].bcast_nw_type.bcast_nw_type);
7643 }
7644 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7645
7646 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307647 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307648 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307649 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7651 (cmd->num_of_channels * sizeof(uint32_t)));
7652 buf_ptr += WMI_TLV_HDR_SIZE;
7653
7654 channel_list = (uint32_t *) buf_ptr;
7655 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307656 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307657
7658 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307659 channel_list[i] =
7660 wlan_chan_to_freq(pno->
7661 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307662
Govind Singhb53420c2016-03-09 14:32:57 +05307663 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307664 }
7665 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7667 sizeof(nlo_channel_prediction_cfg));
7668 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307669 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307670 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307671 /** TODO: Discrete firmware doesn't have command/option to configure
7672 * App IE which comes from wpa_supplicant as of part PNO start request.
7673 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7675 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7676 buf_ptr += sizeof(enlo_candidate_score_params);
7677
7678 if (ie_whitelist->white_list) {
7679 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7680 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7681 &cmd->num_vendor_oui,
7682 ie_whitelist);
7683 }
7684
7685 /* ie white list */
7686 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7687 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7688 buf_ptr += WMI_TLV_HDR_SIZE;
7689 if (cmd->num_vendor_oui != 0) {
7690 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7691 ie_whitelist->voui);
7692 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7693 }
7694
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307695 if (pno->relative_rssi_set)
7696 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7697
7698 /*
7699 * Firmware calculation using connected PNO params:
7700 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7701 * deduction of rssi_pref for chosen band_pref and
7702 * addition of rssi_pref for remaining bands (other than chosen band).
7703 */
7704 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7705 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7706 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7707 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7708 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7709 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7710 buf_ptr += sizeof(*nlo_relative_rssi);
7711
7712 /*
7713 * As of now Kernel and Host supports one band and rssi preference.
7714 * Firmware supports array of band and rssi preferences
7715 */
7716 cmd->num_cnlo_band_pref = 1;
7717 WMITLV_SET_HDR(buf_ptr,
7718 WMITLV_TAG_ARRAY_STRUC,
7719 cmd->num_cnlo_band_pref *
7720 sizeof(connected_nlo_bss_band_rssi_pref));
7721 buf_ptr += WMI_TLV_HDR_SIZE;
7722
7723 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7724 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7725 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7726 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7727 WMITLV_GET_STRUCT_TLVLEN(
7728 connected_nlo_bss_band_rssi_pref));
7729 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7730 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7731 WMI_LOGI("band_pref %d, rssi_pref %d",
7732 nlo_band_rssi[i].band,
7733 nlo_band_rssi[i].rssi_pref);
7734 }
7735 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7736
Govind Singh4eacd2b2016-03-07 14:24:22 +05307737 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7738 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7739 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307740 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307741 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307742 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307743 }
7744
Govind Singhb53420c2016-03-09 14:32:57 +05307745 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307746}
7747
7748/* send_set_ric_req_cmd_tlv() - set ric request element
7749 * @wmi_handle: wmi handle
7750 * @msg: message
7751 * @is_add_ts: is addts required
7752 *
7753 * This function sets ric request element for 11r roaming.
7754 *
7755 * Return: CDF status
7756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307757static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307758 void *msg, uint8_t is_add_ts)
7759{
7760 wmi_ric_request_fixed_param *cmd;
7761 wmi_ric_tspec *tspec_param;
7762 wmi_buf_t buf;
7763 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307764 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307765 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7766 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7767
7768 buf = wmi_buf_alloc(wmi_handle, len);
7769 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307770 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7771 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307772 }
7773
7774 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7775
7776 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7777 WMITLV_SET_HDR(&cmd->tlv_header,
7778 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7779 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7780 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007781 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307782 else
7783 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7784 cmd->num_ric_request = 1;
7785 cmd->is_add_ric = is_add_ts;
7786
7787 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7788 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7789
7790 buf_ptr += WMI_TLV_HDR_SIZE;
7791 tspec_param = (wmi_ric_tspec *) buf_ptr;
7792 WMITLV_SET_HDR(&tspec_param->tlv_header,
7793 WMITLV_TAG_STRUC_wmi_ric_tspec,
7794 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7795
7796 if (is_add_ts)
7797 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307798#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307799 else
7800 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307801#endif
7802 if (ptspecIE) {
7803 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307804#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307805 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7806 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307807#else
Govind Singh87542482016-06-08 19:40:11 +05307808 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7809 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307810#endif /* ANI_LITTLE_BIT_ENDIAN */
7811
Govind Singh87542482016-06-08 19:40:11 +05307812 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7813 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7814 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7815 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7816 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7817 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7818 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7819 tspec_param->min_data_rate = ptspecIE->minDataRate;
7820 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7821 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7822 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7823 tspec_param->delay_bound = ptspecIE->delayBound;
7824 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7825 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7826 tspec_param->medium_time = 0;
7827 }
Govind Singhb53420c2016-03-09 14:32:57 +05307828 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307829
7830 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7831 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307832 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307833 __func__);
7834 if (is_add_ts)
7835 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307836 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307837 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307838 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839 }
7840
Govind Singhb53420c2016-03-09 14:32:57 +05307841 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307842}
7843
Qiwei Cai1ccba222018-05-21 16:49:39 +08007844#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307845/**
7846 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7847 * @wmi_handle: wmi handle
7848 * @clear_req: ll stats clear request command params
7849 *
Govind Singhb53420c2016-03-09 14:32:57 +05307850 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307851 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307852static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307853 const struct ll_stats_clear_params *clear_req,
7854 uint8_t addr[IEEE80211_ADDR_LEN])
7855{
7856 wmi_clear_link_stats_cmd_fixed_param *cmd;
7857 int32_t len;
7858 wmi_buf_t buf;
7859 uint8_t *buf_ptr;
7860 int ret;
7861
7862 len = sizeof(*cmd);
7863 buf = wmi_buf_alloc(wmi_handle, len);
7864
7865 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307866 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7867 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307868 }
7869
7870 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307871 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307872 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7873
7874 WMITLV_SET_HDR(&cmd->tlv_header,
7875 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7876 WMITLV_GET_STRUCT_TLVLEN
7877 (wmi_clear_link_stats_cmd_fixed_param));
7878
7879 cmd->stop_stats_collection_req = clear_req->stop_req;
7880 cmd->vdev_id = clear_req->sta_id;
7881 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7882
7883 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7884 &cmd->peer_macaddr);
7885
Govind Singhb53420c2016-03-09 14:32:57 +05307886 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7887 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7888 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7889 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7890 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307891 cmd->peer_macaddr); */
7892
7893 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7894 WMI_CLEAR_LINK_STATS_CMDID);
7895 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307896 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307897 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307898 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307899 }
7900
Govind Singhb53420c2016-03-09 14:32:57 +05307901 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7902 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307903}
7904
7905/**
7906 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7907 * @wmi_handle: wmi handle
7908 * @setReq: ll stats set request command params
7909 *
Govind Singhb53420c2016-03-09 14:32:57 +05307910 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307911 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307912static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307913 const struct ll_stats_set_params *set_req)
7914{
7915 wmi_start_link_stats_cmd_fixed_param *cmd;
7916 int32_t len;
7917 wmi_buf_t buf;
7918 uint8_t *buf_ptr;
7919 int ret;
7920
7921 len = sizeof(*cmd);
7922 buf = wmi_buf_alloc(wmi_handle, len);
7923
7924 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307925 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7926 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307927 }
7928
7929 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307930 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307931 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7932
7933 WMITLV_SET_HDR(&cmd->tlv_header,
7934 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7935 WMITLV_GET_STRUCT_TLVLEN
7936 (wmi_start_link_stats_cmd_fixed_param));
7937
7938 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7939 cmd->aggressive_statistics_gathering =
7940 set_req->aggressive_statistics_gathering;
7941
Govind Singhb53420c2016-03-09 14:32:57 +05307942 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7943 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7944 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307945
7946 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7947 WMI_START_LINK_STATS_CMDID);
7948 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307949 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307950 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307951 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307952 }
7953
Govind Singhb53420c2016-03-09 14:32:57 +05307954 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307955}
7956
7957/**
7958 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7959 * @wmi_handle:wmi handle
7960 * @get_req:ll stats get request command params
7961 * @addr: mac address
7962 *
Govind Singhb53420c2016-03-09 14:32:57 +05307963 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307964 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307965static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307966 const struct ll_stats_get_params *get_req,
7967 uint8_t addr[IEEE80211_ADDR_LEN])
7968{
7969 wmi_request_link_stats_cmd_fixed_param *cmd;
7970 int32_t len;
7971 wmi_buf_t buf;
7972 uint8_t *buf_ptr;
7973 int ret;
7974
7975 len = sizeof(*cmd);
7976 buf = wmi_buf_alloc(wmi_handle, len);
7977
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307978 if (!buf) {
7979 WMI_LOGE("%s: buf allocation failed", __func__);
7980 return QDF_STATUS_E_NOMEM;
7981 }
7982
Govind Singh4eacd2b2016-03-07 14:24:22 +05307983 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307984 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307985 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7986
7987 WMITLV_SET_HDR(&cmd->tlv_header,
7988 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7989 WMITLV_GET_STRUCT_TLVLEN
7990 (wmi_request_link_stats_cmd_fixed_param));
7991
7992 cmd->request_id = get_req->req_id;
7993 cmd->stats_type = get_req->param_id_mask;
7994 cmd->vdev_id = get_req->sta_id;
7995
7996 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7997 &cmd->peer_macaddr);
7998
Govind Singhb53420c2016-03-09 14:32:57 +05307999 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008000 WMI_LOGD("Request ID : %u", cmd->request_id);
8001 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308002 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8003 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308004
8005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8006 WMI_REQUEST_LINK_STATS_CMDID);
8007 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308008 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308009 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308010 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308011 }
8012
Govind Singhb53420c2016-03-09 14:32:57 +05308013 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308014}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008015#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308016
Govind Singh20c5dac2016-03-07 15:33:31 +05308017/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308018 * send_congestion_cmd_tlv() - send request to fw to get CCA
8019 * @wmi_handle: wmi handle
8020 * @vdev_id: vdev id
8021 *
8022 * Return: CDF status
8023 */
8024static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308025 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308026{
8027 wmi_buf_t buf;
8028 wmi_request_stats_cmd_fixed_param *cmd;
8029 uint8_t len;
8030 uint8_t *buf_ptr;
8031
8032 len = sizeof(*cmd);
8033 buf = wmi_buf_alloc(wmi_handle, len);
8034 if (!buf) {
8035 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8036 return QDF_STATUS_E_FAILURE;
8037 }
8038
8039 buf_ptr = wmi_buf_data(buf);
8040 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8041 WMITLV_SET_HDR(&cmd->tlv_header,
8042 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8043 WMITLV_GET_STRUCT_TLVLEN
8044 (wmi_request_stats_cmd_fixed_param));
8045
8046 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8047 cmd->vdev_id = vdev_id;
8048 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8049 cmd->vdev_id, cmd->stats_id);
8050
8051 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8052 WMI_REQUEST_STATS_CMDID)) {
8053 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8054 __func__);
8055 wmi_buf_free(buf);
8056 return QDF_STATUS_E_FAILURE;
8057 }
8058
8059 return QDF_STATUS_SUCCESS;
8060}
8061
8062/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308063 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8064 * @wmi_handle: wmi handle
8065 * @rssi_req: get RSSI request
8066 *
8067 * Return: CDF status
8068 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308069static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308070{
8071 wmi_buf_t buf;
8072 wmi_request_stats_cmd_fixed_param *cmd;
8073 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8074
8075 buf = wmi_buf_alloc(wmi_handle, len);
8076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308077 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8078 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308079 }
8080
8081 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8082 WMITLV_SET_HDR(&cmd->tlv_header,
8083 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8084 WMITLV_GET_STRUCT_TLVLEN
8085 (wmi_request_stats_cmd_fixed_param));
8086 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8087 if (wmi_unified_cmd_send
8088 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308089 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308090 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308091 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308092 }
8093
Govind Singhb53420c2016-03-09 14:32:57 +05308094 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308095}
8096
8097/**
8098 * send_snr_cmd_tlv() - get RSSI from fw
8099 * @wmi_handle: wmi handle
8100 * @vdev_id: vdev id
8101 *
8102 * Return: CDF status
8103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308104static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308105{
8106 wmi_buf_t buf;
8107 wmi_request_stats_cmd_fixed_param *cmd;
8108 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8109
8110 buf = wmi_buf_alloc(wmi_handle, len);
8111 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308112 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8113 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308114 }
8115
8116 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8117 cmd->vdev_id = vdev_id;
8118
8119 WMITLV_SET_HDR(&cmd->tlv_header,
8120 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8121 WMITLV_GET_STRUCT_TLVLEN
8122 (wmi_request_stats_cmd_fixed_param));
8123 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8124 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8125 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308126 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308127 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308128 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308129 }
8130
Govind Singhb53420c2016-03-09 14:32:57 +05308131 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308132}
8133
8134/**
8135 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8136 * @wmi_handle: wmi handle
8137 * @link_status: get link params
8138 *
8139 * Return: CDF status
8140 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308141static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308142 struct link_status_params *link_status)
8143{
8144 wmi_buf_t buf;
8145 wmi_request_stats_cmd_fixed_param *cmd;
8146 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8147
8148 buf = wmi_buf_alloc(wmi_handle, len);
8149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308150 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8151 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308152 }
8153
8154 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8155 WMITLV_SET_HDR(&cmd->tlv_header,
8156 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8157 WMITLV_GET_STRUCT_TLVLEN
8158 (wmi_request_stats_cmd_fixed_param));
8159 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8160 cmd->vdev_id = link_status->session_id;
8161 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8162 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308163 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308164 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308165 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308166 }
8167
Govind Singhb53420c2016-03-09 14:32:57 +05308168 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308169}
8170
Govind Singh20c5dac2016-03-07 15:33:31 +05308171/**
8172 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8173 * @wmi_handle: wmi handle
8174 * @ta_dhcp_ind: DHCP indication parameter
8175 *
8176 * Return: CDF Status
8177 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308178static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308179 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8180{
Govind Singh67922e82016-04-01 16:48:57 +05308181 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308182 wmi_buf_t buf = NULL;
8183 uint8_t *buf_ptr;
8184 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8185 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8186
8187
8188 buf = wmi_buf_alloc(wmi_handle, len);
8189 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308190 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8191 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308192 }
8193
8194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8195 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8196 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8197 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8198 WMITLV_GET_STRUCT_TLVLEN
8199 (wmi_peer_set_param_cmd_fixed_param));
8200
8201 /* fill in values */
8202 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8203 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8204 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308205 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308206 &ta_dhcp_ind->peer_macaddr,
8207 sizeof(ta_dhcp_ind->peer_macaddr));
8208
8209 status = wmi_unified_cmd_send(wmi_handle, buf,
8210 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308211 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308212 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308213 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308214 wmi_buf_free(buf);
8215 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308216
Govind Singh67922e82016-04-01 16:48:57 +05308217 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308218}
8219
8220/**
8221 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8222 * @wmi_handle: wmi handle
8223 * @pLinkSpeed: link speed info
8224 *
8225 * Return: CDF status
8226 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308227static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308228 wmi_mac_addr peer_macaddr)
8229{
8230 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8231 wmi_buf_t wmi_buf;
8232 uint32_t len;
8233 uint8_t *buf_ptr;
8234
8235 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8236 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8237 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308238 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8239 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308240 }
8241 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8242
8243 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8244 WMITLV_SET_HDR(&cmd->tlv_header,
8245 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8246 WMITLV_GET_STRUCT_TLVLEN
8247 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8248
8249 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308250 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308251 &peer_macaddr,
8252 sizeof(peer_macaddr));
8253
8254
8255 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8256 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308257 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308258 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308259 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308260 }
Govind Singhb53420c2016-03-09 14:32:57 +05308261 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308262}
8263
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308264#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308265/**
8266 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8267 * @wmi_handle: wmi handler
8268 * @egap_params: pointer to egap_params
8269 *
8270 * Return: 0 for success, otherwise appropriate error code
8271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308272static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308273 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308274{
8275 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8276 wmi_buf_t buf;
8277 int32_t err;
8278
8279 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308281 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8282 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308283 }
8284 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8285 WMITLV_SET_HDR(&cmd->tlv_header,
8286 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8287 WMITLV_GET_STRUCT_TLVLEN(
8288 wmi_ap_ps_egap_param_cmd_fixed_param));
8289
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308290 cmd->enable = egap_params->host_enable_egap;
8291 cmd->inactivity_time = egap_params->egap_inactivity_time;
8292 cmd->wait_time = egap_params->egap_wait_time;
8293 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308294 err = wmi_unified_cmd_send(wmi_handle, buf,
8295 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8296 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308297 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308298 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308299 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308300 }
8301
Govind Singhb53420c2016-03-09 14:32:57 +05308302 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308303}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308304#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308305
8306/**
8307 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8308 * @wmi_handl: wmi handle
8309 * @cmd: Profiling command index
8310 * @value1: parameter1 value
8311 * @value2: parameter2 value
8312 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308313 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308314 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308315static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308316 uint32_t cmd, uint32_t value1, uint32_t value2)
8317{
8318 wmi_buf_t buf;
8319 int32_t len = 0;
8320 int ret;
8321 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8322 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8323 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8324 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8325
8326 switch (cmd) {
8327 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8328 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8329 buf = wmi_buf_alloc(wmi_handle, len);
8330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308331 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308332 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 }
8334 prof_trig_cmd =
8335 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8336 wmi_buf_data(buf);
8337 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8338 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8339 WMITLV_GET_STRUCT_TLVLEN
8340 (wmi_wlan_profile_trigger_cmd_fixed_param));
8341 prof_trig_cmd->enable = value1;
8342 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8343 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8344 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308345 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308346 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308347 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 return ret;
8349 }
8350 break;
8351
8352 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8353 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8354 buf = wmi_buf_alloc(wmi_handle, len);
8355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308356 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308357 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308358 }
8359 profile_getdata_cmd =
8360 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8361 wmi_buf_data(buf);
8362 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8363 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8364 WMITLV_GET_STRUCT_TLVLEN
8365 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8366 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8367 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8368 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308369 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308370 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308371 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 return ret;
8373 }
8374 break;
8375
8376 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8377 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8378 buf = wmi_buf_alloc(wmi_handle, len);
8379 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308380 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308381 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308382 }
8383 hist_intvl_cmd =
8384 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8385 wmi_buf_data(buf);
8386 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8387 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8388 WMITLV_GET_STRUCT_TLVLEN
8389 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8390 hist_intvl_cmd->profile_id = value1;
8391 hist_intvl_cmd->value = value2;
8392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8393 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8394 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308395 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308396 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308397 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308398 return ret;
8399 }
8400 break;
8401
8402 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8403 len =
8404 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8405 buf = wmi_buf_alloc(wmi_handle, len);
8406 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308407 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308408 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308409 }
8410 profile_enable_cmd =
8411 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8412 wmi_buf_data(buf);
8413 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8414 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8415 WMITLV_GET_STRUCT_TLVLEN
8416 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8417 profile_enable_cmd->profile_id = value1;
8418 profile_enable_cmd->enable = value2;
8419 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8420 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8421 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308422 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308423 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308424 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 return ret;
8426 }
8427 break;
8428
8429 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308430 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 break;
8432 }
8433
8434 return 0;
8435}
8436
Paul Zhang92ab8d32017-12-08 16:08:00 +08008437static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8438 struct wlm_latency_level_param *params)
8439{
8440 wmi_wlm_config_cmd_fixed_param *cmd;
8441 wmi_buf_t buf;
8442 uint32_t len = sizeof(*cmd);
8443 static uint32_t ll[4] = {100, 60, 40, 20};
8444
8445 buf = wmi_buf_alloc(wmi_handle, len);
8446 if (!buf) {
8447 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8448 return QDF_STATUS_E_NOMEM;
8449 }
8450 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8451 WMITLV_SET_HDR(&cmd->tlv_header,
8452 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8453 WMITLV_GET_STRUCT_TLVLEN
8454 (wmi_wlm_config_cmd_fixed_param));
8455 cmd->vdev_id = params->vdev_id;
8456 cmd->latency_level = params->wlm_latency_level;
8457 cmd->ul_latency = ll[params->wlm_latency_level];
8458 cmd->dl_latency = ll[params->wlm_latency_level];
8459 cmd->flags = params->wlm_latency_flags;
8460 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8461 WMI_WLM_CONFIG_CMDID)) {
8462 WMI_LOGE("%s: Failed to send setting latency config command",
8463 __func__);
8464 wmi_buf_free(buf);
8465 return QDF_STATUS_E_FAILURE;
8466 }
8467
8468 return 0;
8469}
Govind Singh20c5dac2016-03-07 15:33:31 +05308470/**
8471 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8472 * @wmi_handle: wmi handle
8473 * @vdev_id: vdev id
8474 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308475 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308476 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308477static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308478{
8479 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8480 wmi_buf_t buf;
8481 int32_t len = sizeof(*cmd);
8482
Govind Singhb53420c2016-03-09 14:32:57 +05308483 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308484 buf = wmi_buf_alloc(wmi_handle, len);
8485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308486 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308487 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308488 }
8489 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8490 wmi_buf_data(buf);
8491 WMITLV_SET_HDR(&cmd->tlv_header,
8492 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8493 WMITLV_GET_STRUCT_TLVLEN
8494 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8495 cmd->vdev_id = vdev_id;
8496 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8497 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8498 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308499 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308500 __func__);
8501 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308502 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308503 }
8504
8505 return 0;
8506}
8507
8508/**
8509 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8510 * @wmi_handle: wmi handle
8511 * @vdev_id: vdev id
8512 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308513 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308514 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308515static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308516 uint8_t vdev_id)
8517{
8518 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8519 wmi_buf_t buf;
8520 int32_t len = sizeof(*cmd);
8521
Govind Singhb53420c2016-03-09 14:32:57 +05308522 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308523 buf = wmi_buf_alloc(wmi_handle, len);
8524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308525 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308526 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308527 }
8528 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8529 WMITLV_SET_HDR(&cmd->tlv_header,
8530 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8531 WMITLV_GET_STRUCT_TLVLEN
8532 (wmi_csa_offload_enable_cmd_fixed_param));
8533 cmd->vdev_id = vdev_id;
8534 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8535 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8536 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308537 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308538 __func__);
8539 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308540 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308541 }
8542
8543 return 0;
8544}
8545
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008546#ifdef WLAN_FEATURE_CIF_CFR
8547/**
8548 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8549 * @wmi_handle: wmi handle
8550 * @data_len: len of dma cfg req
8551 * @data: dma cfg req
8552 *
8553 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8554 */
8555static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8556 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8557{
8558 wmi_buf_t buf;
8559 uint8_t *cmd;
8560 QDF_STATUS ret;
8561
8562 WMITLV_SET_HDR(cfg,
8563 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8564 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8565
8566 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8567 if (!buf) {
8568 WMI_LOGE(FL("wmi_buf_alloc failed"));
8569 return QDF_STATUS_E_FAILURE;
8570 }
8571
8572 cmd = (uint8_t *) wmi_buf_data(buf);
8573 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8574 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8575 sizeof(*cfg));
8576 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8577 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8578 if (QDF_IS_STATUS_ERROR(ret)) {
8579 WMI_LOGE(FL(":wmi cmd send failed"));
8580 wmi_buf_free(buf);
8581 }
8582
8583 return ret;
8584}
8585#endif
8586
Govind Singh20c5dac2016-03-07 15:33:31 +05308587/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308588 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8589 * @wmi_handle: wmi handle
8590 * @data_len: len of dma cfg req
8591 * @data: dma cfg req
8592 *
8593 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8594 */
8595static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8596 struct direct_buf_rx_cfg_req *cfg)
8597{
8598 wmi_buf_t buf;
8599 wmi_dma_ring_cfg_req_fixed_param *cmd;
8600 QDF_STATUS ret;
8601 int32_t len = sizeof(*cmd);
8602
8603 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8604 if (!buf) {
8605 WMI_LOGE(FL("wmi_buf_alloc failed"));
8606 return QDF_STATUS_E_FAILURE;
8607 }
8608
8609 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8610
8611 WMITLV_SET_HDR(&cmd->tlv_header,
8612 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8613 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8614
8615 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8616 cfg->pdev_id);
8617 cmd->mod_id = cfg->mod_id;
8618 cmd->base_paddr_lo = cfg->base_paddr_lo;
8619 cmd->base_paddr_hi = cfg->base_paddr_hi;
8620 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8621 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8622 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8623 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8624 cmd->num_elems = cfg->num_elems;
8625 cmd->buf_size = cfg->buf_size;
8626 cmd->num_resp_per_event = cfg->num_resp_per_event;
8627 cmd->event_timeout_ms = cfg->event_timeout_ms;
8628
8629 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8630 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8631 "head idx paddr hi %x tail idx paddr lo %x"
8632 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8633 "event timeout %d\n", __func__, cmd->pdev_id,
8634 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8635 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8636 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8637 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8638 cmd->event_timeout_ms);
8639 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8640 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8641 if (QDF_IS_STATUS_ERROR(ret)) {
8642 WMI_LOGE(FL(":wmi cmd send failed"));
8643 wmi_buf_free(buf);
8644 }
8645
8646 return ret;
8647}
8648
8649/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008650 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8651 * @wmi_handle: wmi handle
8652 * @start_11d_scan: 11d scan start request parameters
8653 *
8654 * This function request FW to start 11d scan.
8655 *
8656 * Return: QDF status
8657 */
8658static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8659 struct reg_start_11d_scan_req *start_11d_scan)
8660{
8661 wmi_11d_scan_start_cmd_fixed_param *cmd;
8662 int32_t len;
8663 wmi_buf_t buf;
8664 int ret;
8665
8666 len = sizeof(*cmd);
8667 buf = wmi_buf_alloc(wmi_handle, len);
8668 if (!buf) {
8669 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8670 return QDF_STATUS_E_NOMEM;
8671 }
8672
8673 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8674
8675 WMITLV_SET_HDR(&cmd->tlv_header,
8676 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8677 WMITLV_GET_STRUCT_TLVLEN
8678 (wmi_11d_scan_start_cmd_fixed_param));
8679
8680 cmd->vdev_id = start_11d_scan->vdev_id;
8681 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8682 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8683
8684 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8685
8686 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8687 WMI_11D_SCAN_START_CMDID);
8688 if (ret) {
8689 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8690 wmi_buf_free(buf);
8691 return QDF_STATUS_E_FAILURE;
8692 }
8693
8694 return QDF_STATUS_SUCCESS;
8695}
8696
8697/**
8698 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8699 * @wmi_handle: wmi handle
8700 * @start_11d_scan: 11d scan stop request parameters
8701 *
8702 * This function request FW to stop 11d scan.
8703 *
8704 * Return: QDF status
8705 */
8706static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8707 struct reg_stop_11d_scan_req *stop_11d_scan)
8708{
8709 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8710 int32_t len;
8711 wmi_buf_t buf;
8712 int ret;
8713
8714 len = sizeof(*cmd);
8715 buf = wmi_buf_alloc(wmi_handle, len);
8716 if (!buf) {
8717 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8718 return QDF_STATUS_E_NOMEM;
8719 }
8720
8721 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8722
8723 WMITLV_SET_HDR(&cmd->tlv_header,
8724 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8725 WMITLV_GET_STRUCT_TLVLEN
8726 (wmi_11d_scan_stop_cmd_fixed_param));
8727
8728 cmd->vdev_id = stop_11d_scan->vdev_id;
8729
8730 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8731
8732 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8733 WMI_11D_SCAN_STOP_CMDID);
8734 if (ret) {
8735 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8736 wmi_buf_free(buf);
8737 return QDF_STATUS_E_FAILURE;
8738 }
8739
8740 return QDF_STATUS_SUCCESS;
8741}
8742
8743/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308744 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8745 * @wmi_handle: wmi handle
8746 * @startOemDataReq: start request params
8747 *
8748 * Return: CDF status
8749 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308750static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008751 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308752 uint8_t *data)
8753{
8754 wmi_buf_t buf;
8755 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308756 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308757
8758 buf = wmi_buf_alloc(wmi_handle,
8759 (data_len + WMI_TLV_HDR_SIZE));
8760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308761 WMI_LOGE(FL("wmi_buf_alloc failed"));
8762 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308763 }
8764
8765 cmd = (uint8_t *) wmi_buf_data(buf);
8766
8767 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8768 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308769 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308770 data_len);
8771
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008772 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308773 data_len);
8774
8775 ret = wmi_unified_cmd_send(wmi_handle, buf,
8776 (data_len +
8777 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8778
Govind Singh67922e82016-04-01 16:48:57 +05308779 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308780 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308781 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308782 }
8783
Govind Singh67922e82016-04-01 16:48:57 +05308784 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308785}
8786
8787/**
8788 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8789 * @wmi_handle: wmi handle
8790 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8791 *
8792 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8793 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8794 * to firmware based on phyerr filtering
8795 * offload status.
8796 *
8797 * Return: 1 success, 0 failure
8798 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308799static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308800send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8801 bool dfs_phyerr_filter_offload)
8802{
8803 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8804 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8805 wmi_buf_t buf;
8806 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308807 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308808
8809
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008810 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308811 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308812 __func__);
8813 len = sizeof(*disable_phyerr_offload_cmd);
8814 buf = wmi_buf_alloc(wmi_handle, len);
8815 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308816 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308817 return 0;
8818 }
8819 disable_phyerr_offload_cmd =
8820 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8821 wmi_buf_data(buf);
8822
8823 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8824 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8825 WMITLV_GET_STRUCT_TLVLEN
8826 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8827
8828 /*
8829 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8830 * to the firmware to disable the phyerror
8831 * filtering offload.
8832 */
8833 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8834 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308835 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308836 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308837 __func__, ret);
8838 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308839 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308840 }
Govind Singhb53420c2016-03-09 14:32:57 +05308841 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 __func__);
8843 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308844 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308845 __func__);
8846
8847 len = sizeof(*enable_phyerr_offload_cmd);
8848 buf = wmi_buf_alloc(wmi_handle, len);
8849 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308850 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8851 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308852 }
8853
8854 enable_phyerr_offload_cmd =
8855 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8856 wmi_buf_data(buf);
8857
8858 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8859 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8860 WMITLV_GET_STRUCT_TLVLEN
8861 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8862
8863 /*
8864 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8865 * to the firmware to enable the phyerror
8866 * filtering offload.
8867 */
8868 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8869 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8870
Govind Singh67922e82016-04-01 16:48:57 +05308871 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308872 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308873 __func__, ret);
8874 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308875 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 }
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 __func__);
8879 }
8880
Govind Singhb53420c2016-03-09 14:32:57 +05308881 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308882}
8883
Naveen Rawata5817e72017-10-26 18:50:19 -07008884/**
8885 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8886 * will wake up host after specified time is elapsed
8887 * @wmi_handle: wmi handle
8888 * @vdev_id: vdev id
8889 * @cookie: value to identify reason why host set up wake call.
8890 * @time: time in ms
8891 *
8892 * Return: QDF status
8893 */
8894static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8895 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8896{
8897 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8898 wmi_buf_t buf;
8899 uint8_t *buf_ptr;
8900 int32_t len;
8901 int ret;
8902
8903 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8904 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8905 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8906 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8907 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308908 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8909 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008910
8911 buf = wmi_buf_alloc(wmi_handle, len);
8912 if (!buf) {
8913 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8914 return QDF_STATUS_E_NOMEM;
8915 }
8916
8917 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8918 buf_ptr = (uint8_t *) cmd;
8919
8920 WMITLV_SET_HDR(&cmd->tlv_header,
8921 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8922 WMITLV_GET_STRUCT_TLVLEN
8923 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8924 cmd->vdev_id = vdev_id;
8925 cmd->pattern_id = cookie,
8926 cmd->pattern_type = WOW_TIMER_PATTERN;
8927 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8928
8929 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8930 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8931 buf_ptr += WMI_TLV_HDR_SIZE;
8932
8933 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8934 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8935 buf_ptr += WMI_TLV_HDR_SIZE;
8936
8937 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8938 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8939 buf_ptr += WMI_TLV_HDR_SIZE;
8940
8941 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8942 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8943 buf_ptr += WMI_TLV_HDR_SIZE;
8944
8945 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008947 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308948 *((uint32_t *) buf_ptr) = time;
8949 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008950
8951 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308952 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008953 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308954 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008955
8956 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8957 __func__, time, vdev_id);
8958
8959 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8960 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8961 if (ret) {
8962 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
8963 __func__);
8964 wmi_buf_free(buf);
8965 return QDF_STATUS_E_FAILURE;
8966 }
8967
8968 return QDF_STATUS_SUCCESS;
8969}
8970
Govind Singh20c5dac2016-03-07 15:33:31 +05308971#if !defined(REMOVE_PKT_LOG)
8972/**
8973 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8974 * @wmi_handle: wmi handle
8975 * @pktlog_event: pktlog event
8976 * @cmd_id: pktlog cmd id
8977 *
8978 * Return: CDF status
8979 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308980static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308981 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308982 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308983{
8984 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8985 WMI_CMD_ID CMD_ID;
8986 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8987 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8988 int len = 0;
8989 wmi_buf_t buf;
8990
8991 PKTLOG_EVENT = pktlog_event;
8992 CMD_ID = cmd_id;
8993
8994 switch (CMD_ID) {
8995 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8996 len = sizeof(*cmd);
8997 buf = wmi_buf_alloc(wmi_handle, len);
8998 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308999 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9000 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309001 }
9002 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9003 wmi_buf_data(buf);
9004 WMITLV_SET_HDR(&cmd->tlv_header,
9005 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9006 WMITLV_GET_STRUCT_TLVLEN
9007 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9008 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309009 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9010 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309011 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9012 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309013 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9014 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309015 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309016 goto wmi_send_failed;
9017 }
9018 break;
9019 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9020 len = sizeof(*disable_cmd);
9021 buf = wmi_buf_alloc(wmi_handle, len);
9022 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309023 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9024 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309025 }
9026 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9027 wmi_buf_data(buf);
9028 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9029 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9030 WMITLV_GET_STRUCT_TLVLEN
9031 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309032 disable_cmd->pdev_id =
9033 wmi_handle->ops->convert_pdev_id_host_to_target(
9034 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309035 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9036 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309037 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309038 goto wmi_send_failed;
9039 }
9040 break;
9041 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309042 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309043 break;
9044 }
9045
Govind Singhb53420c2016-03-09 14:32:57 +05309046 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309047
9048wmi_send_failed:
9049 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309050 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309051}
9052#endif /* REMOVE_PKT_LOG */
9053
9054/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309055 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9056 * @wmi_handle: wmi handle
9057 * @ptrn_id: pattern id
9058 * @vdev_id: vdev id
9059 *
9060 * Return: CDF status
9061 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309062static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9063 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309064{
9065 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9066 wmi_buf_t buf;
9067 int32_t len;
9068 int ret;
9069
9070 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9071
9072
9073 buf = wmi_buf_alloc(wmi_handle, len);
9074 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309075 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9076 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309077 }
9078
9079 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9080
9081 WMITLV_SET_HDR(&cmd->tlv_header,
9082 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9083 WMITLV_GET_STRUCT_TLVLEN(
9084 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9085 cmd->vdev_id = vdev_id;
9086 cmd->pattern_id = ptrn_id;
9087 cmd->pattern_type = WOW_BITMAP_PATTERN;
9088
Govind Singhb53420c2016-03-09 14:32:57 +05309089 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309090 cmd->pattern_id, vdev_id);
9091
9092 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9093 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9094 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309095 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309096 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309097 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309098 }
9099
Govind Singhb53420c2016-03-09 14:32:57 +05309100 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309101}
9102
9103/**
9104 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9105 * @wmi_handle: wmi handle
9106 *
9107 * Sends host wakeup indication to FW. On receiving this indication,
9108 * FW will come out of WOW.
9109 *
9110 * Return: CDF status
9111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309112static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309113{
9114 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9115 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309116 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309117 int32_t len;
9118 int ret;
9119
9120 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9121
9122 buf = wmi_buf_alloc(wmi_handle, len);
9123 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309124 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9125 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309126 }
9127
9128 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9129 wmi_buf_data(buf);
9130 WMITLV_SET_HDR(&cmd->tlv_header,
9131 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9132 WMITLV_GET_STRUCT_TLVLEN
9133 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9134
9135
9136 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9137 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9138 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309139 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309141 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309142 }
9143
Govind Singhb53420c2016-03-09 14:32:57 +05309144 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309145}
9146
9147/**
9148 * send_del_ts_cmd_tlv() - send DELTS request to fw
9149 * @wmi_handle: wmi handle
9150 * @msg: delts params
9151 *
9152 * Return: CDF status
9153 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309154static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309155 uint8_t ac)
9156{
9157 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9158 wmi_buf_t buf;
9159 int32_t len = sizeof(*cmd);
9160
9161 buf = wmi_buf_alloc(wmi_handle, len);
9162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309163 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9164 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309165 }
9166 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9167 WMITLV_SET_HDR(&cmd->tlv_header,
9168 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9169 WMITLV_GET_STRUCT_TLVLEN
9170 (wmi_vdev_wmm_delts_cmd_fixed_param));
9171 cmd->vdev_id = vdev_id;
9172 cmd->ac = ac;
9173
Govind Singhb53420c2016-03-09 14:32:57 +05309174 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9176 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9177 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309178 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309179 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309180 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309181 }
9182
Govind Singhb53420c2016-03-09 14:32:57 +05309183 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309184}
9185
9186/**
9187 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9188 * @wmi_handle: handle to wmi
9189 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9190 *
Govind Singhb53420c2016-03-09 14:32:57 +05309191 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309192 * ADD_TS requestes to firmware in loop for all the ACs with
9193 * active flow.
9194 *
9195 * Return: CDF status
9196 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309197static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309198 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9199{
9200 int i = 0;
9201 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9202 wmi_buf_t buf;
9203 int32_t len = sizeof(*cmd);
9204
9205 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9206 /* if flow in this AC is active */
9207 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9208 /*
9209 * as per implementation of wma_add_ts_req() we
9210 * are not waiting any response from firmware so
9211 * apart from sending ADDTS to firmware just send
9212 * success to upper layers
9213 */
Govind Singhb53420c2016-03-09 14:32:57 +05309214 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309215
9216 buf = wmi_buf_alloc(wmi_handle, len);
9217 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309218 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9219 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309220 }
9221 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9222 wmi_buf_data(buf);
9223 WMITLV_SET_HDR(&cmd->tlv_header,
9224 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9225 WMITLV_GET_STRUCT_TLVLEN
9226 (wmi_vdev_wmm_addts_cmd_fixed_param));
9227 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9228 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309229 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309230 traffic.userPrio);
9231 cmd->medium_time_us =
9232 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9233 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309234 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309235 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9236 cmd->medium_time_us, cmd->downgrade_type);
9237 if (wmi_unified_cmd_send
9238 (wmi_handle, buf, len,
9239 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309240 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309241 __func__);
9242 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309243 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309244 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309245 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309246 }
9247 }
9248 }
9249
Govind Singhb53420c2016-03-09 14:32:57 +05309250 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309251}
9252
9253/**
9254 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9255 * @wmi_handle: wmi handle
9256 * @msg: ADDTS params
9257 *
9258 * Return: CDF status
9259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309260static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309261 struct add_ts_param *msg)
9262{
9263 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9264 wmi_buf_t buf;
9265 int32_t len = sizeof(*cmd);
9266
Govind Singhb53420c2016-03-09 14:32:57 +05309267 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309268
9269 buf = wmi_buf_alloc(wmi_handle, len);
9270 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309271 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9272 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309273 }
9274 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9275 WMITLV_SET_HDR(&cmd->tlv_header,
9276 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9277 WMITLV_GET_STRUCT_TLVLEN
9278 (wmi_vdev_wmm_addts_cmd_fixed_param));
9279 cmd->vdev_id = msg->sme_session_id;
9280 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9281 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9282 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309283 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9285 cmd->downgrade_type, __func__, __LINE__);
9286 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9287 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309288 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9289 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309290 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309291 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309292 }
9293
Govind Singhb53420c2016-03-09 14:32:57 +05309294 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309295}
9296
9297/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309298 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9299 * @wmi_handle: wmi handle
9300 * @pAddPeriodicTxPtrnParams: tx ptrn params
9301 *
9302 * Retrun: CDF status
9303 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309304static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 struct periodic_tx_pattern *
9306 pAddPeriodicTxPtrnParams,
9307 uint8_t vdev_id)
9308{
9309 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9310 wmi_buf_t wmi_buf;
9311 uint32_t len;
9312 uint8_t *buf_ptr;
9313 uint32_t ptrn_len, ptrn_len_aligned;
9314 int j;
9315
9316 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9317 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9318 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9319 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9320
9321 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9322 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309323 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9324 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309325 }
9326
9327 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9328
9329 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9330 WMITLV_SET_HDR(&cmd->tlv_header,
9331 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9332 WMITLV_GET_STRUCT_TLVLEN
9333 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9334
9335 /* Pass the pattern id to delete for the corresponding vdev id */
9336 cmd->vdev_id = vdev_id;
9337 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9338 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9339 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9340
9341 /* Pattern info */
9342 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9343 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9344 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309345 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309346 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309347 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309348
Govind Singhb53420c2016-03-09 14:32:57 +05309349 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309350 __func__, cmd->pattern_id, cmd->vdev_id);
9351
9352 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9353 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309354 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309355 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309356 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309357 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309358 }
Govind Singhb53420c2016-03-09 14:32:57 +05309359 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309360}
9361
9362/**
9363 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9364 * @wmi_handle: wmi handle
9365 * @vdev_id: vdev id
9366 * @pattern_id: pattern id
9367 *
9368 * Retrun: CDF status
9369 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309370static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309371 uint8_t vdev_id,
9372 uint8_t pattern_id)
9373{
9374 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9375 wmi_buf_t wmi_buf;
9376 uint32_t len =
9377 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9378
9379 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9380 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309381 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9382 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309383 }
9384
9385 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9386 wmi_buf_data(wmi_buf);
9387 WMITLV_SET_HDR(&cmd->tlv_header,
9388 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9389 WMITLV_GET_STRUCT_TLVLEN
9390 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9391
9392 /* Pass the pattern id to delete for the corresponding vdev id */
9393 cmd->vdev_id = vdev_id;
9394 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309395 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309396 __func__, cmd->pattern_id, cmd->vdev_id);
9397
9398 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9399 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309400 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309401 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309402 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309403 }
Govind Singhb53420c2016-03-09 14:32:57 +05309404 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309405}
9406
9407/**
9408 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9409 * @wmi_handle: wmi handle
9410 * @preq: stats ext params
9411 *
9412 * Return: CDF status
9413 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309414static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309415 struct stats_ext_params *preq)
9416{
Govind Singh67922e82016-04-01 16:48:57 +05309417 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309418 wmi_req_stats_ext_cmd_fixed_param *cmd;
9419 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309420 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309421 uint8_t *buf_ptr;
9422
9423 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9424
9425 buf = wmi_buf_alloc(wmi_handle, len);
9426 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309427 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309428 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309429 }
9430
9431 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9432 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9433
9434 WMITLV_SET_HDR(&cmd->tlv_header,
9435 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9436 WMITLV_GET_STRUCT_TLVLEN
9437 (wmi_req_stats_ext_cmd_fixed_param));
9438 cmd->vdev_id = preq->vdev_id;
9439 cmd->data_len = preq->request_data_len;
9440
Govind Singhb53420c2016-03-09 14:32:57 +05309441 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309442 __func__, preq->request_data_len, preq->vdev_id);
9443
9444 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9446
9447 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309448 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309449
9450 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9451 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309452 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309453 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 ret);
9455 wmi_buf_free(buf);
9456 }
9457
9458 return ret;
9459}
9460
9461/**
9462 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9463 * @wmi_handle: wmi handle
9464 * @params: ext wow params
9465 *
9466 * Return:0 for success or error code
9467 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309468static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309469 struct ext_wow_params *params)
9470{
9471 wmi_extwow_enable_cmd_fixed_param *cmd;
9472 wmi_buf_t buf;
9473 int32_t len;
9474 int ret;
9475
9476 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9477 buf = wmi_buf_alloc(wmi_handle, len);
9478 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309479 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9480 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309481 }
9482
9483 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9484
9485 WMITLV_SET_HDR(&cmd->tlv_header,
9486 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9487 WMITLV_GET_STRUCT_TLVLEN
9488 (wmi_extwow_enable_cmd_fixed_param));
9489
9490 cmd->vdev_id = params->vdev_id;
9491 cmd->type = params->type;
9492 cmd->wakeup_pin_num = params->wakeup_pin_num;
9493
Govind Singhb53420c2016-03-09 14:32:57 +05309494 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309495 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9496
9497 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9498 WMI_EXTWOW_ENABLE_CMDID);
9499 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309500 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309502 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309503 }
9504
Govind Singhb53420c2016-03-09 14:32:57 +05309505 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309506
9507}
9508
9509/**
9510 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9511 * @wmi_handle: wmi handle
9512 * @app_type1_params: app type1 params
9513 *
9514 * Return: CDF status
9515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309516static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309517 struct app_type1_params *app_type1_params)
9518{
9519 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9520 wmi_buf_t buf;
9521 int32_t len;
9522 int ret;
9523
9524 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9525 buf = wmi_buf_alloc(wmi_handle, len);
9526 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309527 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9528 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309529 }
9530
9531 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9532 wmi_buf_data(buf);
9533
9534 WMITLV_SET_HDR(&cmd->tlv_header,
9535 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9536 WMITLV_GET_STRUCT_TLVLEN
9537 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9538
9539 cmd->vdev_id = app_type1_params->vdev_id;
9540 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9541 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309542 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309543 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309544 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309545 cmd->passwd_len = app_type1_params->pass_length;
9546
Govind Singhb53420c2016-03-09 14:32:57 +05309547 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309548 "identification_id %.8s id_length %u "
9549 "password %.16s pass_length %u",
9550 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9551 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9552
9553 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9554 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9555 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309556 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309557 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309558 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309559 }
9560
Govind Singhb53420c2016-03-09 14:32:57 +05309561 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309562}
9563
9564/**
9565 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9566 * @wmi_handle: wmi handle
9567 * @appType2Params: app type2 params
9568 *
9569 * Return: CDF status
9570 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309571static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309572 struct app_type2_params *appType2Params)
9573{
9574 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9575 wmi_buf_t buf;
9576 int32_t len;
9577 int ret;
9578
9579 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9580 buf = wmi_buf_alloc(wmi_handle, len);
9581 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309582 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9583 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 }
9585
9586 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9587 wmi_buf_data(buf);
9588
9589 WMITLV_SET_HDR(&cmd->tlv_header,
9590 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9591 WMITLV_GET_STRUCT_TLVLEN
9592 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9593
9594 cmd->vdev_id = appType2Params->vdev_id;
9595
Govind Singhb53420c2016-03-09 14:32:57 +05309596 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309597 cmd->rc4_key_len = appType2Params->rc4_key_len;
9598
9599 cmd->ip_id = appType2Params->ip_id;
9600 cmd->ip_device_ip = appType2Params->ip_device_ip;
9601 cmd->ip_server_ip = appType2Params->ip_server_ip;
9602
9603 cmd->tcp_src_port = appType2Params->tcp_src_port;
9604 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9605 cmd->tcp_seq = appType2Params->tcp_seq;
9606 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9607
9608 cmd->keepalive_init = appType2Params->keepalive_init;
9609 cmd->keepalive_min = appType2Params->keepalive_min;
9610 cmd->keepalive_max = appType2Params->keepalive_max;
9611 cmd->keepalive_inc = appType2Params->keepalive_inc;
9612
9613 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9614 &cmd->gateway_mac);
9615 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9616 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9617
Govind Singhb53420c2016-03-09 14:32:57 +05309618 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309619 "rc4_key %.16s rc4_key_len %u "
9620 "ip_id %x ip_device_ip %x ip_server_ip %x "
9621 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9622 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9623 "keepalive_max %u keepalive_inc %u "
9624 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9625 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9626 cmd->rc4_key, cmd->rc4_key_len,
9627 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9628 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9629 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9630 cmd->keepalive_max, cmd->keepalive_inc,
9631 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9632
9633 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9634 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9635 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309636 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309637 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309638 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309639 }
9640
Govind Singhb53420c2016-03-09 14:32:57 +05309641 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309642
9643}
9644
9645/**
9646 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9647 * @wmi_handle: wmi handle
9648 * @timer_val: auto shutdown timer value
9649 *
9650 * Return: CDF status
9651 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309652static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309653 uint32_t timer_val)
9654{
Govind Singh67922e82016-04-01 16:48:57 +05309655 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309656 wmi_buf_t buf = NULL;
9657 uint8_t *buf_ptr;
9658 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9659 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9660
Govind Singhb53420c2016-03-09 14:32:57 +05309661 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309662 __func__, timer_val);
9663
9664 buf = wmi_buf_alloc(wmi_handle, len);
9665 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309666 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9667 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309668 }
9669
9670 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9671 wmi_auto_sh_cmd =
9672 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9673 wmi_auto_sh_cmd->timer_value = timer_val;
9674
9675 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9676 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9677 WMITLV_GET_STRUCT_TLVLEN
9678 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9679
9680 status = wmi_unified_cmd_send(wmi_handle, buf,
9681 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309682 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309683 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309684 __func__, status);
9685 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309686 }
9687
Govind Singh67922e82016-04-01 16:48:57 +05309688 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309689}
9690
9691/**
9692 * send_nan_req_cmd_tlv() - to send nan request to target
9693 * @wmi_handle: wmi handle
9694 * @nan_req: request data which will be non-null
9695 *
9696 * Return: CDF status
9697 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309698static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309699 struct nan_req_params *nan_req)
9700{
Govind Singh67922e82016-04-01 16:48:57 +05309701 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309702 wmi_nan_cmd_param *cmd;
9703 wmi_buf_t buf;
9704 uint16_t len = sizeof(*cmd);
9705 uint16_t nan_data_len, nan_data_len_aligned;
9706 uint8_t *buf_ptr;
9707
9708 /*
9709 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9710 * +------------+----------+-----------------------+--------------+
9711 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9712 * +------------+----------+-----------------------+--------------+
9713 */
9714 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309715 WMI_LOGE("%s:nan req is not valid", __func__);
9716 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309717 }
9718 nan_data_len = nan_req->request_data_len;
9719 nan_data_len_aligned = roundup(nan_req->request_data_len,
9720 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009721 if (nan_data_len_aligned < nan_req->request_data_len) {
9722 WMI_LOGE("%s: integer overflow while rounding up data_len",
9723 __func__);
9724 return QDF_STATUS_E_FAILURE;
9725 }
9726
9727 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9728 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9729 __func__);
9730 return QDF_STATUS_E_FAILURE;
9731 }
9732
Govind Singh20c5dac2016-03-07 15:33:31 +05309733 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9734 buf = wmi_buf_alloc(wmi_handle, len);
9735 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309736 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9737 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309738 }
9739 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9740 cmd = (wmi_nan_cmd_param *) buf_ptr;
9741 WMITLV_SET_HDR(&cmd->tlv_header,
9742 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9743 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9744 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309745 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309746 __func__, nan_req->request_data_len);
9747 buf_ptr += sizeof(wmi_nan_cmd_param);
9748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9749 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309750 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309751
9752 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9753 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309754 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309755 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309756 __func__, ret);
9757 wmi_buf_free(buf);
9758 }
9759
9760 return ret;
9761}
9762
9763/**
9764 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9765 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009766 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309767 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309768 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309769 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009770static QDF_STATUS
9771send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9772 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309773{
9774 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9775 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309776 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309777
9778 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9779 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309780 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309781 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309782 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309783 }
9784
9785 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309786
9787 WMITLV_SET_HDR(&cmd->tlv_header,
9788 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9789 WMITLV_GET_STRUCT_TLVLEN
9790 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009791 cmd->vdev_id = params->vdev_id;
9792 cmd->enable = params->dhcp_offload_enabled;
9793 cmd->num_client = params->dhcp_client_num;
9794 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309795 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309796 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309797 sizeof(*cmd),
9798 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309799 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309800 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309801 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309802 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309803 }
Govind Singhb53420c2016-03-09 14:32:57 +05309804 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009805 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309806
9807 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309808}
9809
9810/**
9811 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9812 * @wmi_handle: wmi handle
9813 * @flashing: flashing request
9814 *
9815 * Return: CDF status
9816 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309817static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309818 struct flashing_req_params *flashing)
9819{
9820 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309821 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309822 wmi_buf_t buf;
9823 uint8_t *buf_ptr;
9824 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9825
9826 buf = wmi_buf_alloc(wmi_handle, len);
9827 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309828 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309829 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309830 }
9831 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9832 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9833 WMITLV_SET_HDR(&cmd->tlv_header,
9834 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9835 WMITLV_GET_STRUCT_TLVLEN
9836 (wmi_set_led_flashing_cmd_fixed_param));
9837 cmd->pattern_id = flashing->pattern_id;
9838 cmd->led_x0 = flashing->led_x0;
9839 cmd->led_x1 = flashing->led_x1;
9840
9841 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9842 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309843 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309844 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309845 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309846 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309847 }
Govind Singh67922e82016-04-01 16:48:57 +05309848
9849 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309850}
9851
9852/**
9853 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9854 * @wmi_handle: wmi handle
9855 * @ch_avoid_update_req: channel avoid update params
9856 *
9857 * Return: CDF status
9858 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309859static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309860{
Govind Singh67922e82016-04-01 16:48:57 +05309861 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309862 wmi_buf_t buf = NULL;
9863 uint8_t *buf_ptr;
9864 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9865 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9866
9867
9868 buf = wmi_buf_alloc(wmi_handle, len);
9869 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309870 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9871 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309872 }
9873
9874 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9875 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9876 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9877 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9878 WMITLV_GET_STRUCT_TLVLEN
9879 (wmi_chan_avoid_update_cmd_param));
9880
9881 status = wmi_unified_cmd_send(wmi_handle, buf,
9882 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309883 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309884 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309885 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9886 " returned Error %d", status);
9887 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309888 }
9889
Govind Singh67922e82016-04-01 16:48:57 +05309890 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309891}
9892
9893/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309894 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9895 * @wmi_handle: wmi handle
9896 * @param: pointer to pdev regdomain params
9897 *
9898 * Return: 0 for success or error code
9899 */
9900static QDF_STATUS
9901send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9902 struct pdev_set_regdomain_params *param)
9903{
9904 wmi_buf_t buf;
9905 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9906 int32_t len = sizeof(*cmd);
9907
9908
9909 buf = wmi_buf_alloc(wmi_handle, len);
9910 if (!buf) {
9911 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9912 return QDF_STATUS_E_NOMEM;
9913 }
9914 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9915 WMITLV_SET_HDR(&cmd->tlv_header,
9916 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9917 WMITLV_GET_STRUCT_TLVLEN
9918 (wmi_pdev_set_regdomain_cmd_fixed_param));
9919
9920 cmd->reg_domain = param->currentRDinuse;
9921 cmd->reg_domain_2G = param->currentRD2G;
9922 cmd->reg_domain_5G = param->currentRD5G;
9923 cmd->conformance_test_limit_2G = param->ctl_2G;
9924 cmd->conformance_test_limit_5G = param->ctl_5G;
9925 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309926 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9927 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309928
9929 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9930 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9931 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9932 __func__);
9933 wmi_buf_free(buf);
9934 return QDF_STATUS_E_FAILURE;
9935 }
9936
9937 return QDF_STATUS_SUCCESS;
9938}
9939
9940/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309941 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9942 * @wmi_handle: wmi handle
9943 * @reg_dmn: reg domain
9944 * @regdmn2G: 2G reg domain
9945 * @regdmn5G: 5G reg domain
9946 * @ctl2G: 2G test limit
9947 * @ctl5G: 5G test limit
9948 *
9949 * Return: none
9950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309951static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309952 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309953 uint16_t regdmn5G, uint8_t ctl2G,
9954 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309955{
9956 wmi_buf_t buf;
9957 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9958 int32_t len = sizeof(*cmd);
9959
9960
9961 buf = wmi_buf_alloc(wmi_handle, len);
9962 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309963 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9964 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309965 }
9966 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9967 WMITLV_SET_HDR(&cmd->tlv_header,
9968 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9969 WMITLV_GET_STRUCT_TLVLEN
9970 (wmi_pdev_set_regdomain_cmd_fixed_param));
9971 cmd->reg_domain = reg_dmn;
9972 cmd->reg_domain_2G = regdmn2G;
9973 cmd->reg_domain_5G = regdmn5G;
9974 cmd->conformance_test_limit_2G = ctl2G;
9975 cmd->conformance_test_limit_5G = ctl5G;
9976
9977 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9978 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309979 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309980 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309981 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309982 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309983 }
9984
Govind Singhb53420c2016-03-09 14:32:57 +05309985 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309986}
9987
9988
9989/**
9990 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9991 * @wmi_handle: wmi handle
9992 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9993 *
9994 * This function sets tdls off channel mode
9995 *
9996 * Return: 0 on success; Negative errno otherwise
9997 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309998static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309999 struct tdls_channel_switch_params *chan_switch_params)
10000{
10001 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10002 wmi_buf_t wmi_buf;
10003 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10004
10005 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10006 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010007 WMI_LOGE(FL("wmi_buf_alloc failed"));
10008 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010009 }
10010 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10011 wmi_buf_data(wmi_buf);
10012 WMITLV_SET_HDR(&cmd->tlv_header,
10013 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10014 WMITLV_GET_STRUCT_TLVLEN(
10015 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10016
10017 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10018 &cmd->peer_macaddr);
10019 cmd->vdev_id = chan_switch_params->vdev_id;
10020 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10021 cmd->is_peer_responder = chan_switch_params->is_responder;
10022 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10023 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10024 cmd->offchan_oper_class = chan_switch_params->oper_class;
10025
Govind Singhb53420c2016-03-09 14:32:57 +053010026 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010027 cmd->peer_macaddr.mac_addr31to0,
10028 cmd->peer_macaddr.mac_addr47to32);
10029
Govind Singhb53420c2016-03-09 14:32:57 +053010030 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010031 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10032 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10033 ),
10034 cmd->vdev_id,
10035 cmd->offchan_mode,
10036 cmd->offchan_num,
10037 cmd->offchan_bw_bitmap,
10038 cmd->is_peer_responder,
10039 cmd->offchan_oper_class);
10040
10041 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10042 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010043 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010044 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010045 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010046 }
10047
10048
Govind Singhb53420c2016-03-09 14:32:57 +053010049 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010050}
10051
10052/**
10053 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10054 * @wmi_handle: wmi handle
10055 * @pwmaTdlsparams: TDLS params
10056 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010057 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010058 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010059static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010060 void *tdls_param, uint8_t tdls_state)
10061{
10062 wmi_tdls_set_state_cmd_fixed_param *cmd;
10063 wmi_buf_t wmi_buf;
10064
10065 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10066 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10067
10068 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10069 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010070 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10071 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010072 }
10073 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10074 WMITLV_SET_HDR(&cmd->tlv_header,
10075 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10076 WMITLV_GET_STRUCT_TLVLEN
10077 (wmi_tdls_set_state_cmd_fixed_param));
10078 cmd->vdev_id = wmi_tdls->vdev_id;
10079 cmd->state = tdls_state;
10080 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10081 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10082 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10083 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10084 cmd->rssi_delta = wmi_tdls->rssi_delta;
10085 cmd->tdls_options = wmi_tdls->tdls_options;
10086 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10087 cmd->tdls_peer_traffic_response_timeout_ms =
10088 wmi_tdls->peer_traffic_response_timeout;
10089 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10090 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10091 cmd->tdls_puapsd_rx_frame_threshold =
10092 wmi_tdls->puapsd_rx_frame_threshold;
10093 cmd->teardown_notification_ms =
10094 wmi_tdls->teardown_notification_ms;
10095 cmd->tdls_peer_kickout_threshold =
10096 wmi_tdls->tdls_peer_kickout_threshold;
10097
Govind Singhb53420c2016-03-09 14:32:57 +053010098 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010099 "notification_interval_ms: %d, "
10100 "tx_discovery_threshold: %d, "
10101 "tx_teardown_threshold: %d, "
10102 "rssi_teardown_threshold: %d, "
10103 "rssi_delta: %d, "
10104 "tdls_options: 0x%x, "
10105 "tdls_peer_traffic_ind_window: %d, "
10106 "tdls_peer_traffic_response_timeout: %d, "
10107 "tdls_puapsd_mask: 0x%x, "
10108 "tdls_puapsd_inactivity_time: %d, "
10109 "tdls_puapsd_rx_frame_threshold: %d, "
10110 "teardown_notification_ms: %d, "
10111 "tdls_peer_kickout_threshold: %d",
10112 __func__, tdls_state, cmd->state,
10113 cmd->notification_interval_ms,
10114 cmd->tx_discovery_threshold,
10115 cmd->tx_teardown_threshold,
10116 cmd->rssi_teardown_threshold,
10117 cmd->rssi_delta,
10118 cmd->tdls_options,
10119 cmd->tdls_peer_traffic_ind_window,
10120 cmd->tdls_peer_traffic_response_timeout_ms,
10121 cmd->tdls_puapsd_mask,
10122 cmd->tdls_puapsd_inactivity_time_ms,
10123 cmd->tdls_puapsd_rx_frame_threshold,
10124 cmd->teardown_notification_ms,
10125 cmd->tdls_peer_kickout_threshold);
10126
10127 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10128 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010129 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010130 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010131 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010132 }
Govind Singhb53420c2016-03-09 14:32:57 +053010133 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010134
Govind Singhb53420c2016-03-09 14:32:57 +053010135 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010136}
10137
10138/**
10139 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10140 * @wmi_handle: wmi handle
10141 * @peerStateParams: TDLS peer state params
10142 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010143 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010144 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010145static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010146 struct tdls_peer_state_params *peerStateParams,
10147 uint32_t *ch_mhz)
10148{
10149 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10150 wmi_tdls_peer_capabilities *peer_cap;
10151 wmi_channel *chan_info;
10152 wmi_buf_t wmi_buf;
10153 uint8_t *buf_ptr;
10154 uint32_t i;
10155 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10156 sizeof(wmi_tdls_peer_capabilities);
10157
10158
10159 len += WMI_TLV_HDR_SIZE +
10160 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10161
10162 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10163 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010164 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10165 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010166 }
10167
10168 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10169 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10170 WMITLV_SET_HDR(&cmd->tlv_header,
10171 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10172 WMITLV_GET_STRUCT_TLVLEN
10173 (wmi_tdls_peer_update_cmd_fixed_param));
10174
10175 cmd->vdev_id = peerStateParams->vdevId;
10176 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10177 &cmd->peer_macaddr);
10178
10179
10180 cmd->peer_state = peerStateParams->peerState;
10181
Govind Singhb53420c2016-03-09 14:32:57 +053010182 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010183 "peer_macaddr.mac_addr31to0: 0x%x, "
10184 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10185 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10186 cmd->peer_macaddr.mac_addr31to0,
10187 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10188
10189 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10190 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10191 WMITLV_SET_HDR(&peer_cap->tlv_header,
10192 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10193 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10194
10195 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10196 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10197 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10198 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10199 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10200 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10201 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10202 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10203
10204 /* Ack and More Data Ack are sent as 0, so no need to set
10205 * but fill SP
10206 */
10207 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10208 peerStateParams->peerCap.peerMaxSp);
10209
10210 peer_cap->buff_sta_support =
10211 peerStateParams->peerCap.peerBuffStaSupport;
10212 peer_cap->off_chan_support =
10213 peerStateParams->peerCap.peerOffChanSupport;
10214 peer_cap->peer_curr_operclass =
10215 peerStateParams->peerCap.peerCurrOperClass;
10216 /* self curr operclass is not being used and so pass op class for
10217 * preferred off chan in it.
10218 */
10219 peer_cap->self_curr_operclass =
10220 peerStateParams->peerCap.opClassForPrefOffChan;
10221 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10222 peer_cap->peer_operclass_len =
10223 peerStateParams->peerCap.peerOperClassLen;
10224
Govind Singhb53420c2016-03-09 14:32:57 +053010225 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010226 __func__, peer_cap->peer_operclass_len);
10227 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10228 peer_cap->peer_operclass[i] =
10229 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010230 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010231 __func__, i, peer_cap->peer_operclass[i]);
10232 }
10233
10234 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10235 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10236 peer_cap->pref_offchan_bw =
10237 peerStateParams->peerCap.prefOffChanBandwidth;
10238
Govind Singhb53420c2016-03-09 14:32:57 +053010239 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010240 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10241 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10242 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10243 " %d, pref_offchan_bw: %d",
10244 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10245 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10246 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10247 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10248 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10249
10250 /* next fill variable size array of peer chan info */
10251 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10252 WMITLV_SET_HDR(buf_ptr,
10253 WMITLV_TAG_ARRAY_STRUC,
10254 sizeof(wmi_channel) *
10255 peerStateParams->peerCap.peerChanLen);
10256 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10257
10258 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10259 WMITLV_SET_HDR(&chan_info->tlv_header,
10260 WMITLV_TAG_STRUC_wmi_channel,
10261 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10262 chan_info->mhz = ch_mhz[i];
10263 chan_info->band_center_freq1 = chan_info->mhz;
10264 chan_info->band_center_freq2 = 0;
10265
Govind Singhb53420c2016-03-09 14:32:57 +053010266 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010267
10268 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10269 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010270 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010271 peerStateParams->peerCap.peerChan[i].chanId,
10272 peerStateParams->peerCap.peerChan[i].dfsSet);
10273 }
10274
10275 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10276 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10277 else
10278 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10279
10280 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10281 peerStateParams->peerCap.
10282 peerChan[i].pwr);
10283
10284 WMI_SET_CHANNEL_REG_POWER(chan_info,
10285 peerStateParams->peerCap.peerChan[i].
10286 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010287 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010288 peerStateParams->peerCap.peerChan[i].pwr);
10289
10290 chan_info++;
10291 }
10292
10293 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10294 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010295 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010296 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010297 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010298 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010299 }
10300
10301
Govind Singhb53420c2016-03-09 14:32:57 +053010302 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010303}
10304
10305/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010306 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10307 * @wmi_handle: Pointer to WMi handle
10308 * @ie_data: Pointer for ie data
10309 *
10310 * This function sends IE information to firmware
10311 *
Govind Singhb53420c2016-03-09 14:32:57 +053010312 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010313 *
10314 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010315static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010316 struct vdev_ie_info_param *ie_info)
10317{
10318 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10319 wmi_buf_t buf;
10320 uint8_t *buf_ptr;
10321 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010322 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010323
10324
10325 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10326 /* Allocate memory for the WMI command */
10327 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10328
10329 buf = wmi_buf_alloc(wmi_handle, len);
10330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010331 WMI_LOGE(FL("wmi_buf_alloc failed"));
10332 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010333 }
10334
10335 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010336 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010337
10338 /* Populate the WMI command */
10339 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10340
10341 WMITLV_SET_HDR(&cmd->tlv_header,
10342 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10343 WMITLV_GET_STRUCT_TLVLEN(
10344 wmi_vdev_set_ie_cmd_fixed_param));
10345 cmd->vdev_id = ie_info->vdev_id;
10346 cmd->ie_id = ie_info->ie_id;
10347 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010348 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010349
Govind Singhb53420c2016-03-09 14:32:57 +053010350 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010351 ie_info->length, ie_info->vdev_id);
10352
10353 buf_ptr += sizeof(*cmd);
10354 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10355 buf_ptr += WMI_TLV_HDR_SIZE;
10356
Govind Singhb53420c2016-03-09 14:32:57 +053010357 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010358
10359 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10360 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010361 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010362 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010363 wmi_buf_free(buf);
10364 }
10365
10366 return ret;
10367}
10368
Sathish Kumar497bef42017-03-01 14:02:36 +053010369/**
10370 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10371 *
10372 * @param wmi_handle : handle to WMI.
10373 * @param param : pointer to antenna param
10374 *
10375 * This function sends smart antenna enable command to FW
10376 *
10377 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10378 */
10379static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10380 struct smart_ant_enable_params *param)
10381{
10382 /* Send WMI COMMAND to Enable */
10383 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10384 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10385 wmi_buf_t buf;
10386 uint8_t *buf_ptr;
10387 int len = 0;
10388 QDF_STATUS ret;
10389 int loop = 0;
10390
10391 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10392 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10393 buf = wmi_buf_alloc(wmi_handle, len);
10394
10395 if (!buf) {
10396 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10397 return QDF_STATUS_E_NOMEM;
10398 }
10399
10400 buf_ptr = wmi_buf_data(buf);
10401 qdf_mem_zero(buf_ptr, len);
10402 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10403
10404 WMITLV_SET_HDR(&cmd->tlv_header,
10405 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10406 WMITLV_GET_STRUCT_TLVLEN(
10407 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10408
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010409 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10410 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010411 cmd->enable = param->enable;
10412 cmd->mode = param->mode;
10413 cmd->rx_antenna = param->rx_antenna;
10414 cmd->tx_default_antenna = param->rx_antenna;
10415
10416 /* TLV indicating array of structures to follow */
10417 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10419 WMI_HAL_MAX_SANTENNA *
10420 sizeof(wmi_pdev_smart_ant_gpio_handle));
10421
10422 buf_ptr += WMI_TLV_HDR_SIZE;
10423 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10424
10425 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10426 WMITLV_SET_HDR(&gpio_param->tlv_header,
10427 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10428 WMITLV_GET_STRUCT_TLVLEN(
10429 wmi_pdev_smart_ant_gpio_handle));
10430 if (param->mode == SMART_ANT_MODE_SERIAL) {
10431 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10432 gpio_param->gpio_pin = param->gpio_pin[loop];
10433 gpio_param->gpio_func = param->gpio_func[loop];
10434 } else {
10435 gpio_param->gpio_pin = 0;
10436 gpio_param->gpio_func = 0;
10437 }
10438 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10439 gpio_param->gpio_pin = param->gpio_pin[loop];
10440 gpio_param->gpio_func = param->gpio_func[loop];
10441 }
10442 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010443 gpio_param->pdev_id =
10444 wmi_handle->ops->convert_pdev_id_host_to_target(
10445 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010446 gpio_param++;
10447 }
10448
10449 ret = wmi_unified_cmd_send(wmi_handle,
10450 buf,
10451 len,
10452 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10453
10454 if (ret != 0) {
10455 WMI_LOGE(" %s :WMI Failed\n", __func__);
10456 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10457 cmd->enable,
10458 cmd->mode,
10459 cmd->rx_antenna,
10460 param->gpio_pin[0], param->gpio_pin[1],
10461 param->gpio_pin[2], param->gpio_pin[3],
10462 param->gpio_func[0], param->gpio_func[1],
10463 param->gpio_func[2], param->gpio_func[3],
10464 ret);
10465 wmi_buf_free(buf);
10466 }
10467
10468 return ret;
10469}
10470
10471/**
10472 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10473 *
10474 * @param wmi_handle : handle to WMI.
10475 * @param param : pointer to rx antenna param
10476 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10477 */
10478static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10479 struct smart_ant_rx_ant_params *param)
10480{
10481 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10482 wmi_buf_t buf;
10483 uint8_t *buf_ptr;
10484 uint32_t len;
10485 QDF_STATUS ret;
10486
10487 len = sizeof(*cmd);
10488 buf = wmi_buf_alloc(wmi_handle, len);
10489 WMI_LOGD("%s:\n", __func__);
10490 if (!buf) {
10491 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10492 return QDF_STATUS_E_NOMEM;
10493 }
10494
10495 buf_ptr = wmi_buf_data(buf);
10496 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10497 WMITLV_SET_HDR(&cmd->tlv_header,
10498 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10499 WMITLV_GET_STRUCT_TLVLEN(
10500 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10501 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010502 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10503 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010504
10505 ret = wmi_unified_cmd_send(wmi_handle,
10506 buf,
10507 len,
10508 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10509
10510 if (ret != 0) {
10511 WMI_LOGE(" %s :WMI Failed\n", __func__);
10512 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10513 __func__,
10514 cmd->rx_antenna,
10515 ret);
10516 wmi_buf_free(buf);
10517 }
10518
10519 return ret;
10520}
10521
10522/**
10523 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10524 * @wmi_handle: wmi handle
10525 * @param: pointer to hold ctl table param
10526 *
10527 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10528 */
10529static QDF_STATUS
10530send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10531 struct ctl_table_params *param)
10532{
10533 uint16_t len, ctl_tlv_len;
10534 uint8_t *buf_ptr;
10535 wmi_buf_t buf;
10536 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10537 uint32_t *ctl_array;
10538
10539 if (!param->ctl_array)
10540 return QDF_STATUS_E_FAILURE;
10541
Sathish Kumar497bef42017-03-01 14:02:36 +053010542 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010543 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010544 len = sizeof(*cmd) + ctl_tlv_len;
10545
10546 buf = wmi_buf_alloc(wmi_handle, len);
10547 if (!buf) {
10548 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10549 return QDF_STATUS_E_FAILURE;
10550 }
10551
10552 buf_ptr = wmi_buf_data(buf);
10553 qdf_mem_zero(buf_ptr, len);
10554
10555 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10556
10557 WMITLV_SET_HDR(&cmd->tlv_header,
10558 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10559 WMITLV_GET_STRUCT_TLVLEN(
10560 wmi_pdev_set_ctl_table_cmd_fixed_param));
10561 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010562 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10563 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010564
10565 buf_ptr += sizeof(*cmd);
10566 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10567 (cmd->ctl_len));
10568 buf_ptr += WMI_TLV_HDR_SIZE;
10569 ctl_array = (uint32_t *)buf_ptr;
10570
10571 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10572 sizeof(param->ctl_band));
10573 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10574 param->ctl_cmd_len -
10575 sizeof(param->ctl_band));
10576
10577 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10578 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10579 WMI_LOGE("%s:Failed to send command\n", __func__);
10580 wmi_buf_free(buf);
10581 return QDF_STATUS_E_FAILURE;
10582 }
10583
10584 return QDF_STATUS_SUCCESS;
10585}
10586
10587/**
10588 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10589 * @wmi_handle: wmi handle
10590 * @param: pointer to hold mimogain table param
10591 *
10592 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10593 */
10594static QDF_STATUS
10595send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10596 struct mimogain_table_params *param)
10597{
10598 uint16_t len, table_tlv_len;
10599 wmi_buf_t buf;
10600 uint8_t *buf_ptr;
10601 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10602 uint32_t *gain_table;
10603
10604 if (!param->array_gain)
10605 return QDF_STATUS_E_FAILURE;
10606
10607 /* len must be multiple of a single array gain table */
10608 if (param->tbl_len %
10609 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10610 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10611 WMI_LOGE("Array gain table len not correct\n");
10612 return QDF_STATUS_E_FAILURE;
10613 }
10614
10615 table_tlv_len = WMI_TLV_HDR_SIZE +
10616 roundup(param->tbl_len, sizeof(uint32_t));
10617 len = sizeof(*cmd) + table_tlv_len;
10618
10619 buf = wmi_buf_alloc(wmi_handle, len);
10620 if (!buf) {
10621 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10622 return QDF_STATUS_E_FAILURE;
10623 }
10624
10625 buf_ptr = wmi_buf_data(buf);
10626 qdf_mem_zero(buf_ptr, len);
10627
10628 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10629
10630 WMITLV_SET_HDR(&cmd->tlv_header,
10631 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10632 WMITLV_GET_STRUCT_TLVLEN(
10633 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10634
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010635 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10636 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010637 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10638 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10639 param->multichain_gain_bypass);
10640
10641 buf_ptr += sizeof(*cmd);
10642 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10643 (param->tbl_len));
10644 buf_ptr += WMI_TLV_HDR_SIZE;
10645 gain_table = (uint32_t *)buf_ptr;
10646
10647 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10648 param->array_gain,
10649 param->tbl_len);
10650
10651 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10652 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10653 return QDF_STATUS_E_FAILURE;
10654 }
10655
10656 return QDF_STATUS_SUCCESS;
10657}
10658
10659/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010660 * enum packet_power_tlv_flags: target defined
10661 * packet power rate flags for TLV
10662 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10663 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10664 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10665 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10666 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10667 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10668 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10669 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10670 * @WMI_TLV_FLAG_STBC: STBC is set
10671 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10672 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10673 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10674 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10675 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10676 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10677 * @WMI_TLV_FLAG_LDPC: LDPC is set
10678 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10679 * @WMI_TLV_FLAG_SU: SU Data
10680 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10681 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10682 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10683 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10684 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10685 *
10686 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10687 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10688 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10689 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10690 */
10691enum packet_power_tlv_flags {
10692 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10693 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10694 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10695 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10696 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10697 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10698 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10699 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10700 WMI_TLV_FLAG_STBC = 0x00000100,
10701 WMI_TLV_FLAG_40MHZ = 0x00000200,
10702 WMI_TLV_FLAG_80MHZ = 0x00000300,
10703 WMI_TLV_FLAG_160MHZ = 0x00000400,
10704 WMI_TLV_FLAG_TXBF = 0x00000800,
10705 WMI_TLV_FLAG_RTSENA = 0x00001000,
10706 WMI_TLV_FLAG_CTSENA = 0x00002000,
10707 WMI_TLV_FLAG_LDPC = 0x00004000,
10708 WMI_TLV_FLAG_SGI = 0x00008000,
10709 WMI_TLV_FLAG_SU = 0x00100000,
10710 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10711 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10712 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10713 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10714 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10715
10716 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10717 WMI_TLV_FLAG_BW_MASK = 0x3,
10718 WMI_TLV_FLAG_BW_SHIFT = 9,
10719 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10720 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10721};
10722
10723/**
10724 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10725 * to FW understandable format
10726 * @param: pointer to hold packet power info param
10727 *
10728 * @return FW understandable 32 bit rate flags
10729 */
10730static uint32_t
10731convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10732{
10733 uint32_t rateflags = 0;
10734
10735 if (param->chainmask)
10736 rateflags |=
10737 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10738 if (param->chan_width)
10739 rateflags |=
10740 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10741 << WMI_TLV_FLAG_BW_SHIFT);
10742 if (param->su_mu_ofdma)
10743 rateflags |=
10744 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10745 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10746 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10747 rateflags |= WMI_TLV_FLAG_STBC;
10748 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10749 rateflags |= WMI_TLV_FLAG_LDPC;
10750 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10751 rateflags |= WMI_TLV_FLAG_TXBF;
10752 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10753 rateflags |= WMI_TLV_FLAG_RTSENA;
10754 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10755 rateflags |= WMI_TLV_FLAG_CTSENA;
10756 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10757 rateflags |= WMI_TLV_FLAG_SGI;
10758
10759 return rateflags;
10760}
10761
10762/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010763 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10764 * info to fw
10765 * @wmi_handle: wmi handle
10766 * @param: pointer to hold packet power info param
10767 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010768 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010769 */
10770static QDF_STATUS
10771send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10772 struct packet_power_info_params *param)
10773{
10774 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10775 wmi_buf_t wmibuf;
10776 uint8_t *buf_ptr;
10777 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10778
10779 wmibuf = wmi_buf_alloc(wmi_handle, len);
10780 if (wmibuf == NULL)
10781 return QDF_STATUS_E_NOMEM;
10782
10783 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10784
10785 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10786 WMITLV_SET_HDR(&cmd->tlv_header,
10787 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10788 WMITLV_GET_STRUCT_TLVLEN(
10789 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010790 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10791 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010792 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010793 cmd->nss = param->nss;
10794 cmd->preamble = param->preamble;
10795 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010796
10797 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10798 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10799 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10800 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10801
Sathish Kumar497bef42017-03-01 14:02:36 +053010802 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10803 WMI_PDEV_GET_TPC_CMDID)) {
10804 WMI_LOGE(FL("Failed to get tpc command\n"));
10805 wmi_buf_free(wmibuf);
10806 return QDF_STATUS_E_FAILURE;
10807 }
10808
10809 return QDF_STATUS_SUCCESS;
10810}
10811
10812/**
10813 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10814 * @wmi_handle: wmi handle
10815 * @param: pointer to hold config ratemask params
10816 *
10817 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10818 */
10819static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10820 struct config_ratemask_params *param)
10821{
10822 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10823 wmi_buf_t buf;
10824 int32_t len = sizeof(*cmd);
10825
10826 buf = wmi_buf_alloc(wmi_handle, len);
10827 if (!buf) {
10828 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10829 return QDF_STATUS_E_FAILURE;
10830 }
10831 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10832 WMITLV_SET_HDR(&cmd->tlv_header,
10833 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10834 WMITLV_GET_STRUCT_TLVLEN(
10835 wmi_vdev_config_ratemask_cmd_fixed_param));
10836 cmd->vdev_id = param->vdev_id;
10837 cmd->type = param->type;
10838 cmd->mask_lower32 = param->lower32;
10839 cmd->mask_higher32 = param->higher32;
Rhythm Patwab5ca01d2018-06-19 10:43:00 -070010840 cmd->mask_lower32_2 = param->lower32_2;
10841 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X"
10842 "mask_l32 = 0x%X mask_h32 = 0x%X mask_l32_2 = 0x%X\n",
10843 param->vdev_id, param->type, param->lower32,
10844 param->higher32, param->lower32_2);
Sathish Kumar497bef42017-03-01 14:02:36 +053010845
10846 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10847 WMI_VDEV_RATEMASK_CMDID)) {
10848 WMI_LOGE("Seting vdev ratemask failed\n");
10849 wmi_buf_free(buf);
10850 return QDF_STATUS_E_FAILURE;
10851 }
10852
10853 return QDF_STATUS_SUCCESS;
10854}
10855
10856/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010857 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10858 * @param: param sent from the host side
10859 * @cmd: param to be sent to the fw side
10860 */
10861static inline void copy_custom_aggr_bitmap(
10862 struct set_custom_aggr_size_params *param,
10863 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10864{
10865 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10866 param->ac);
10867 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10868 param->aggr_type);
10869 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10870 param->tx_aggr_size_disable);
10871 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10872 param->rx_aggr_size_disable);
10873 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10874 param->tx_ac_enable);
10875}
10876
10877/**
10878 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10879 * @wmi_handle: wmi handle
10880 * @param: pointer to hold custom aggr size params
10881 *
10882 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10883 */
10884static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10885 wmi_unified_t wmi_handle,
10886 struct set_custom_aggr_size_params *param)
10887{
10888 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10889 wmi_buf_t buf;
10890 int32_t len = sizeof(*cmd);
10891
10892 buf = wmi_buf_alloc(wmi_handle, len);
10893 if (!buf) {
10894 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10895 return QDF_STATUS_E_FAILURE;
10896 }
10897 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10898 wmi_buf_data(buf);
10899 WMITLV_SET_HDR(&cmd->tlv_header,
10900 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10901 WMITLV_GET_STRUCT_TLVLEN(
10902 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10903 cmd->vdev_id = param->vdev_id;
10904 cmd->tx_aggr_size = param->tx_aggr_size;
10905 cmd->rx_aggr_size = param->rx_aggr_size;
10906 copy_custom_aggr_bitmap(param, cmd);
10907
10908 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10909 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10910 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10911 "tx_ac_enable=0x%X\n",
10912 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10913 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10914 param->rx_aggr_size_disable, param->tx_ac_enable);
10915
10916 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10917 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10918 WMI_LOGE("Seting custom aggregation size failed\n");
10919 wmi_buf_free(buf);
10920 return QDF_STATUS_E_FAILURE;
10921 }
10922
10923 return QDF_STATUS_SUCCESS;
10924}
10925
10926/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010927 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10928 * @param wmi_handle : handle to WMI.
10929 * @param param : pointer to tx antenna param
10930 *
10931 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10932 */
10933
10934static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10935 struct set_qdepth_thresh_params *param)
10936{
10937 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10938 wmi_msduq_qdepth_thresh_update *cmd_update;
10939 wmi_buf_t buf;
10940 int32_t len = 0;
10941 int i;
10942 uint8_t *buf_ptr;
10943 QDF_STATUS ret;
10944
10945 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10946 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10947 return QDF_STATUS_E_INVAL;
10948 }
10949
10950 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10951 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10952 param->num_of_msduq_updates);
10953 buf = wmi_buf_alloc(wmi_handle, len);
10954
10955 if (!buf) {
10956 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10957 return QDF_STATUS_E_NOMEM;
10958 }
10959
10960 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10961 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
10962 buf_ptr;
10963
10964 WMITLV_SET_HDR(&cmd->tlv_header,
10965 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
10966 , WMITLV_GET_STRUCT_TLVLEN(
10967 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
10968
10969 cmd->pdev_id =
10970 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
10971 cmd->vdev_id = param->vdev_id;
10972 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
10973 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
10974
10975 buf_ptr += sizeof(
10976 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
10977 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10978 param->num_of_msduq_updates *
10979 sizeof(wmi_msduq_qdepth_thresh_update));
10980 buf_ptr += WMI_TLV_HDR_SIZE;
10981 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
10982
10983 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
10984 WMITLV_SET_HDR(&cmd_update->tlv_header,
10985 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
10986 WMITLV_GET_STRUCT_TLVLEN(
10987 wmi_msduq_qdepth_thresh_update));
10988 cmd_update->tid_num = param->update_params[i].tid_num;
10989 cmd_update->msduq_update_mask =
10990 param->update_params[i].msduq_update_mask;
10991 cmd_update->qdepth_thresh_value =
10992 param->update_params[i].qdepth_thresh_value;
10993 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
10994 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
10995 " update mask=0x%X thresh val=0x%X\n",
10996 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
10997 cmd->peer_mac_address.mac_addr31to0,
10998 cmd->peer_mac_address.mac_addr47to32,
10999 cmd_update->msduq_update_mask,
11000 cmd_update->qdepth_thresh_value);
11001 cmd_update++;
11002 }
11003
11004 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11005 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11006
11007 if (ret != 0) {
11008 WMI_LOGE(" %s :WMI Failed\n", __func__);
11009 wmi_buf_free(buf);
11010 }
11011
11012 return ret;
11013}
11014
11015/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011016 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11017 * @wmi_handle: wmi handle
11018 * @param: pointer to hold vap dscp tid map param
11019 *
11020 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11021 */
11022static QDF_STATUS
11023send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11024 struct vap_dscp_tid_map_params *param)
11025{
11026 wmi_buf_t buf;
11027 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11028 int32_t len = sizeof(*cmd);
11029
11030 buf = wmi_buf_alloc(wmi_handle, len);
11031 if (!buf) {
11032 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11033 return QDF_STATUS_E_FAILURE;
11034 }
11035
11036 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11037 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011038 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011039
11040 cmd->vdev_id = param->vdev_id;
11041 cmd->enable_override = 0;
11042
11043 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11044 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11045 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11046 WMI_LOGE("Failed to set dscp cmd\n");
11047 wmi_buf_free(buf);
11048 return QDF_STATUS_E_FAILURE;
11049 }
11050
11051 return QDF_STATUS_SUCCESS;
11052}
11053
11054/**
11055 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11056 * @wmi_handle: wmi handle
11057 * @macaddr: vdev mac address
11058 * @param: pointer to hold neigbour rx param
11059 *
11060 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11061 */
11062static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11063 uint8_t macaddr[IEEE80211_ADDR_LEN],
11064 struct set_neighbour_rx_params *param)
11065{
11066 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11067 wmi_buf_t buf;
11068 int32_t len = sizeof(*cmd);
11069
11070 buf = wmi_buf_alloc(wmi_handle, len);
11071 if (!buf) {
11072 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11073 return QDF_STATUS_E_FAILURE;
11074 }
11075 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11076 WMITLV_SET_HDR(&cmd->tlv_header,
11077 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11078 WMITLV_GET_STRUCT_TLVLEN(
11079 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11080 cmd->vdev_id = param->vdev_id;
11081 cmd->bssid_idx = param->idx;
11082 cmd->action = param->action;
11083 cmd->type = param->type;
11084 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11085 cmd->flag = 0;
11086
11087 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11088 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11089 WMI_LOGE("Failed to set neighbour rx param\n");
11090 wmi_buf_free(buf);
11091 return QDF_STATUS_E_FAILURE;
11092 }
11093
11094 return QDF_STATUS_SUCCESS;
11095}
11096
11097/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011098 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011099 * @param wmi_handle : handle to WMI.
11100 * @param macaddr : vdev mac address
11101 * @param param : pointer to tx antenna param
11102 *
11103 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11104 */
11105static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11106 uint8_t macaddr[IEEE80211_ADDR_LEN],
11107 struct smart_ant_tx_ant_params *param)
11108{
11109 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11110 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11111 wmi_buf_t buf;
11112 int32_t len = 0;
11113 int i;
11114 uint8_t *buf_ptr;
11115 QDF_STATUS ret;
11116
11117 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11118 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11119 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11120 buf = wmi_buf_alloc(wmi_handle, len);
11121
11122 if (!buf) {
11123 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11124 return QDF_STATUS_E_NOMEM;
11125 }
11126
11127 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11128 qdf_mem_zero(buf_ptr, len);
11129 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11130
11131 WMITLV_SET_HDR(&cmd->tlv_header,
11132 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11133 WMITLV_GET_STRUCT_TLVLEN(
11134 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11135
11136 cmd->vdev_id = param->vdev_id;
11137 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11138
11139 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11140 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11141 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11142 buf_ptr += WMI_TLV_HDR_SIZE;
11143 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11144
11145 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11146 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11147 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11148 WMITLV_GET_STRUCT_TLVLEN(
11149 wmi_peer_smart_ant_set_tx_antenna_series));
11150 ant_tx_series->antenna_series = param->antenna_array[i];
11151 ant_tx_series++;
11152 }
11153
11154 ret = wmi_unified_cmd_send(wmi_handle,
11155 buf,
11156 len,
11157 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11158
11159 if (ret != 0) {
11160 WMI_LOGE(" %s :WMI Failed\n", __func__);
11161 wmi_buf_free(buf);
11162 }
11163
11164 return ret;
11165}
11166
Sathish Kumar02c3b542017-02-22 17:24:45 +053011167/**
11168 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11169 * @wmi_handle: wmi handle
11170 * @param: pointer to hold ant switch tbl param
11171 *
11172 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11173 */
11174static QDF_STATUS
11175send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11176 struct ant_switch_tbl_params *param)
11177{
11178 uint8_t len;
11179 wmi_buf_t buf;
11180 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11181 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11182 uint8_t *buf_ptr;
11183
11184 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11185 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11186 buf = wmi_buf_alloc(wmi_handle, len);
11187
11188 if (!buf) {
11189 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11190 return QDF_STATUS_E_NOMEM;
11191 }
11192
11193 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11194 qdf_mem_zero(buf_ptr, len);
11195 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11196
11197 WMITLV_SET_HDR(&cmd->tlv_header,
11198 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11199 WMITLV_GET_STRUCT_TLVLEN(
11200 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11201
11202 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11203 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011204 cmd->mac_id =
11205 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011206
11207 /* TLV indicating array of structures to follow */
11208 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11210 sizeof(wmi_pdev_set_ant_ctrl_chain));
11211 buf_ptr += WMI_TLV_HDR_SIZE;
11212 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11213
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011214 ctrl_chain->pdev_id =
11215 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011216 ctrl_chain->antCtrlChain = param->antCtrlChain;
11217
11218 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11219 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11220 wmi_buf_free(buf);
11221 return QDF_STATUS_E_FAILURE;
11222 }
11223
11224 return QDF_STATUS_SUCCESS;
11225}
11226
11227/**
11228 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11229 * training information function
11230 * @param wmi_handle : handle to WMI.
11231 * @macaddr : vdev mac address
11232 * @param param : pointer to tx antenna param
11233 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11234 */
11235static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11236 wmi_unified_t wmi_handle,
11237 uint8_t macaddr[IEEE80211_ADDR_LEN],
11238 struct smart_ant_training_info_params *param)
11239{
11240 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11241 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11242 wmi_buf_t buf;
11243 uint8_t *buf_ptr;
11244 int32_t len = 0;
11245 QDF_STATUS ret;
11246 int loop;
11247
11248 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11249 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11250 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11251 buf = wmi_buf_alloc(wmi_handle, len);
11252
11253 if (!buf) {
11254 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11255 return QDF_STATUS_E_NOMEM;
11256 }
11257
11258 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11259 qdf_mem_zero(buf_ptr, len);
11260 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11261
11262 WMITLV_SET_HDR(&cmd->tlv_header,
11263 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11264 WMITLV_GET_STRUCT_TLVLEN(
11265 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11266
11267 cmd->vdev_id = param->vdev_id;
11268 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11269 cmd->num_pkts = param->numpkts;
11270
11271 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11272 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11273 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11274 WMI_SMART_ANT_MAX_RATE_SERIES);
11275
11276 buf_ptr += WMI_TLV_HDR_SIZE;
11277 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11278
11279 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11280 WMITLV_SET_HDR(&train_param->tlv_header,
11281 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11282 WMITLV_GET_STRUCT_TLVLEN(
11283 wmi_peer_smart_ant_set_train_antenna_param));
11284 train_param->train_rate_series = param->rate_array[loop];
11285 train_param->train_antenna_series = param->antenna_array[loop];
11286 train_param->rc_flags = 0;
11287 WMI_LOGI(FL("Series number:%d\n"), loop);
11288 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11289 train_param->train_rate_series,
11290 train_param->train_antenna_series);
11291 train_param++;
11292 }
11293
11294 ret = wmi_unified_cmd_send(wmi_handle,
11295 buf,
11296 len,
11297 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11298
11299 if (ret != 0) {
11300 WMI_LOGE(" %s :WMI Failed\n", __func__);
11301 wmi_buf_free(buf);
11302 return QDF_STATUS_E_FAILURE;
11303 }
11304
11305 return ret;
11306}
11307
11308/**
11309 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11310 * configuration function
11311 * @param wmi_handle : handle to WMI.
11312 * @macaddr : vdev mad address
11313 * @param param : pointer to tx antenna param
11314 *
11315 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11316 */
11317static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11318 wmi_unified_t wmi_handle,
11319 uint8_t macaddr[IEEE80211_ADDR_LEN],
11320 struct smart_ant_node_config_params *param)
11321{
11322 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11323 wmi_buf_t buf;
11324 uint8_t *buf_ptr;
11325 int32_t len = 0, args_tlv_len;
11326 int ret;
11327 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011328 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011329
Vivekc5823092018-03-22 23:27:21 +053011330 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011331 len = sizeof(*cmd) + args_tlv_len;
11332
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011333 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011334 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11335 __func__, param->args_count);
11336 return QDF_STATUS_E_FAILURE;
11337 }
11338
11339 buf = wmi_buf_alloc(wmi_handle, len);
11340 if (!buf) {
11341 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11342 return QDF_STATUS_E_NOMEM;
11343 }
11344
11345 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11346 wmi_buf_data(buf);
11347 buf_ptr = (uint8_t *)cmd;
11348 WMITLV_SET_HDR(&cmd->tlv_header,
11349 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11350 WMITLV_GET_STRUCT_TLVLEN(
11351 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11352 cmd->vdev_id = param->vdev_id;
11353 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11354 cmd->cmd_id = param->cmd_id;
11355 cmd->args_count = param->args_count;
11356 buf_ptr += sizeof(
11357 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011359 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011360 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011361 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011362
11363 for (i = 0; i < param->args_count; i++) {
11364 node_config_args[i] = param->args_arr[i];
11365 WMI_LOGI("%d", param->args_arr[i]);
11366 }
11367
11368 ret = wmi_unified_cmd_send(wmi_handle,
11369 buf,
11370 len,
11371 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11372
11373 if (ret != 0) {
11374 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11375 __func__, param->cmd_id, macaddr[0],
11376 macaddr[1], macaddr[2], macaddr[3],
11377 macaddr[4], macaddr[5], ret);
11378 wmi_buf_free(buf);
11379 }
11380
11381 return ret;
11382}
11383
11384/**
11385 * send_set_atf_cmd_tlv() - send set atf command to fw
11386 * @wmi_handle: wmi handle
11387 * @param: pointer to set atf param
11388 *
11389 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11390 */
11391static QDF_STATUS
11392send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11393 struct set_atf_params *param)
11394{
11395 wmi_atf_peer_info *peer_info;
11396 wmi_peer_atf_request_fixed_param *cmd;
11397 wmi_buf_t buf;
11398 uint8_t *buf_ptr;
11399 int i;
11400 int32_t len = 0;
11401 QDF_STATUS retval;
11402
11403 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11404 len += param->num_peers * sizeof(wmi_atf_peer_info);
11405 buf = wmi_buf_alloc(wmi_handle, len);
11406 if (!buf) {
11407 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11408 return QDF_STATUS_E_FAILURE;
11409 }
11410 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11411 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11412 WMITLV_SET_HDR(&cmd->tlv_header,
11413 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11414 WMITLV_GET_STRUCT_TLVLEN(
11415 wmi_peer_atf_request_fixed_param));
11416 cmd->num_peers = param->num_peers;
11417
11418 buf_ptr += sizeof(*cmd);
11419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11420 sizeof(wmi_atf_peer_info) *
11421 cmd->num_peers);
11422 buf_ptr += WMI_TLV_HDR_SIZE;
11423 peer_info = (wmi_atf_peer_info *)buf_ptr;
11424
11425 for (i = 0; i < cmd->num_peers; i++) {
11426 WMITLV_SET_HDR(&peer_info->tlv_header,
11427 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11428 WMITLV_GET_STRUCT_TLVLEN(
11429 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011430 qdf_mem_copy(&(peer_info->peer_macaddr),
11431 &(param->peer_info[i].peer_macaddr),
11432 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011433 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011434 peer_info->vdev_id = param->peer_info[i].vdev_id;
11435 peer_info->pdev_id =
11436 wmi_handle->ops->convert_pdev_id_host_to_target(
11437 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011438 /*
11439 * TLV definition for peer atf request fixed param combines
11440 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11441 * stats and atf extension stats as two different
11442 * implementations.
11443 * Need to discuss with FW on this.
11444 *
11445 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11446 * peer_info->atf_units_reserved =
11447 * param->peer_ext_info[i].atf_index_reserved;
11448 */
11449 peer_info++;
11450 }
11451
11452 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11453 WMI_PEER_ATF_REQUEST_CMDID);
11454
11455 if (retval != QDF_STATUS_SUCCESS) {
11456 WMI_LOGE("%s : WMI Failed\n", __func__);
11457 wmi_buf_free(buf);
11458 }
11459
11460 return retval;
11461}
11462
11463/**
11464 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11465 * @wmi_handle: wmi handle
11466 * @param: pointer to hold fwtest param
11467 *
11468 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11469 */
11470static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11471 struct set_fwtest_params *param)
11472{
11473 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11474 wmi_buf_t buf;
11475 int32_t len = sizeof(*cmd);
11476
11477 buf = wmi_buf_alloc(wmi_handle, len);
11478
11479 if (!buf) {
11480 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11481 return QDF_STATUS_E_FAILURE;
11482 }
11483
11484 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11485 WMITLV_SET_HDR(&cmd->tlv_header,
11486 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11487 WMITLV_GET_STRUCT_TLVLEN(
11488 wmi_fwtest_set_param_cmd_fixed_param));
11489 cmd->param_id = param->arg;
11490 cmd->param_value = param->value;
11491
11492 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11493 WMI_LOGE("Setting FW test param failed\n");
11494 wmi_buf_free(buf);
11495 return QDF_STATUS_E_FAILURE;
11496 }
11497
11498 return QDF_STATUS_SUCCESS;
11499}
11500
11501/**
11502 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11503 * @wmi_handle: wmi handle
11504 * @param: pointer to qboost params
11505 * @macaddr: vdev mac address
11506 *
11507 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11508 */
11509static QDF_STATUS
11510send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11511 uint8_t macaddr[IEEE80211_ADDR_LEN],
11512 struct set_qboost_params *param)
11513{
11514 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11515 wmi_buf_t buf;
11516 int32_t len;
11517 QDF_STATUS ret;
11518
11519 len = sizeof(*cmd);
11520
11521 buf = wmi_buf_alloc(wmi_handle, len);
11522 if (!buf) {
11523 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11524 return QDF_STATUS_E_FAILURE;
11525 }
11526
11527 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11528 WMITLV_SET_HDR(&cmd->tlv_header,
11529 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11530 WMITLV_GET_STRUCT_TLVLEN(
11531 WMI_QBOOST_CFG_CMD_fixed_param));
11532 cmd->vdev_id = param->vdev_id;
11533 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11534 cmd->qb_enable = param->value;
11535
11536 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11537 WMI_QBOOST_CFG_CMDID);
11538
11539 if (ret != 0) {
11540 WMI_LOGE("Setting qboost cmd failed\n");
11541 wmi_buf_free(buf);
11542 }
11543
11544 return ret;
11545}
11546
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011547/**
11548 * send_gpio_config_cmd_tlv() - send gpio config to fw
11549 * @wmi_handle: wmi handle
11550 * @param: pointer to hold gpio config param
11551 *
11552 * Return: 0 for success or error code
11553 */
11554static QDF_STATUS
11555send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11556 struct gpio_config_params *param)
11557{
11558 wmi_gpio_config_cmd_fixed_param *cmd;
11559 wmi_buf_t buf;
11560 int32_t len;
11561 QDF_STATUS ret;
11562
11563 len = sizeof(*cmd);
11564
11565 /* Sanity Checks */
11566 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11567 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11568 return QDF_STATUS_E_FAILURE;
11569 }
11570
11571 buf = wmi_buf_alloc(wmi_handle, len);
11572 if (!buf) {
11573 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11574 return QDF_STATUS_E_FAILURE;
11575 }
11576
11577 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11578 WMITLV_SET_HDR(&cmd->tlv_header,
11579 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11580 WMITLV_GET_STRUCT_TLVLEN(
11581 wmi_gpio_config_cmd_fixed_param));
11582 cmd->gpio_num = param->gpio_num;
11583 cmd->input = param->input;
11584 cmd->pull_type = param->pull_type;
11585 cmd->intr_mode = param->intr_mode;
11586
11587 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11588 WMI_GPIO_CONFIG_CMDID);
11589
11590 if (ret != 0) {
11591 WMI_LOGE("Sending GPIO config cmd failed\n");
11592 wmi_buf_free(buf);
11593 }
11594
11595 return ret;
11596}
11597
11598/**
11599 * send_gpio_output_cmd_tlv() - send gpio output to fw
11600 * @wmi_handle: wmi handle
11601 * @param: pointer to hold gpio output param
11602 *
11603 * Return: 0 for success or error code
11604 */
11605static QDF_STATUS
11606send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11607 struct gpio_output_params *param)
11608{
11609 wmi_gpio_output_cmd_fixed_param *cmd;
11610 wmi_buf_t buf;
11611 int32_t len;
11612 QDF_STATUS ret;
11613
11614 len = sizeof(*cmd);
11615
11616 buf = wmi_buf_alloc(wmi_handle, len);
11617 if (!buf) {
11618 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11619 return QDF_STATUS_E_FAILURE;
11620 }
11621
11622 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11623 WMITLV_SET_HDR(&cmd->tlv_header,
11624 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11625 WMITLV_GET_STRUCT_TLVLEN(
11626 wmi_gpio_output_cmd_fixed_param));
11627 cmd->gpio_num = param->gpio_num;
11628 cmd->set = param->set;
11629
11630 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11631 WMI_GPIO_OUTPUT_CMDID);
11632
11633 if (ret != 0) {
11634 WMI_LOGE("Sending GPIO output cmd failed\n");
11635 wmi_buf_free(buf);
11636 }
11637
11638 return ret;
11639
11640}
11641
11642/**
11643 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11644 *
11645 * @param wmi_handle : handle to WMI.
11646 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11647 */
11648static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11649{
11650 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11651 wmi_buf_t buf;
11652 QDF_STATUS ret;
11653 int32_t len;
11654
11655 len = sizeof(*cmd);
11656
11657 buf = wmi_buf_alloc(wmi_handle, len);
11658 if (!buf) {
11659 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11660 return QDF_STATUS_E_FAILURE;
11661 }
11662
11663 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11664 WMITLV_SET_HDR(&cmd->tlv_header,
11665 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11666 WMITLV_GET_STRUCT_TLVLEN(
11667 wmi_pdev_dfs_disable_cmd_fixed_param));
11668 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011669 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11670 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011671
11672 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11673 WMI_PDEV_DFS_DISABLE_CMDID);
11674
11675 if (ret != 0) {
11676 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11677 wmi_buf_free(buf);
11678 }
11679
11680 return ret;
11681}
11682
11683/**
11684 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11685 *
11686 * @param wmi_handle : handle to WMI.
11687 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11688 */
11689static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11690{
11691 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11692 wmi_buf_t buf;
11693 QDF_STATUS ret;
11694 int32_t len;
11695
11696 len = sizeof(*cmd);
11697
11698 buf = wmi_buf_alloc(wmi_handle, len);
11699 if (!buf) {
11700 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11701 return QDF_STATUS_E_FAILURE;
11702 }
11703
11704 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11705 WMITLV_SET_HDR(&cmd->tlv_header,
11706 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11707 WMITLV_GET_STRUCT_TLVLEN(
11708 wmi_pdev_dfs_enable_cmd_fixed_param));
11709 /* Reserved for future use */
11710 cmd->reserved0 = 0;
11711
11712 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11713 WMI_PDEV_DFS_ENABLE_CMDID);
11714
11715 if (ret != 0) {
11716 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11717 wmi_buf_free(buf);
11718 }
11719
11720 return ret;
11721}
11722
11723/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011724 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11725 * to fw
11726 * @wmi_handle: wmi handle
11727 * @param: pointer to hold periodic chan stats param
11728 *
11729 * Return: 0 for success or error code
11730 */
11731static QDF_STATUS
11732send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11733 struct periodic_chan_stats_params *param)
11734{
11735 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11736 wmi_buf_t buf;
11737 QDF_STATUS ret;
11738 int32_t len;
11739
11740 len = sizeof(*cmd);
11741
11742 buf = wmi_buf_alloc(wmi_handle, len);
11743 if (!buf) {
11744 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11745 return QDF_STATUS_E_FAILURE;
11746 }
11747
11748 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11749 wmi_buf_data(buf);
11750 WMITLV_SET_HDR(&cmd->tlv_header,
11751 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11752 WMITLV_GET_STRUCT_TLVLEN(
11753 wmi_set_periodic_channel_stats_config_fixed_param));
11754 cmd->enable = param->enable;
11755 cmd->stats_period = param->stats_period;
11756 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11757 param->pdev_id);
11758
11759 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11760 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11761
11762 if (ret != 0) {
11763 WMI_LOGE("Sending periodic chan stats config failed");
11764 wmi_buf_free(buf);
11765 }
11766
11767 return ret;
11768}
11769
11770/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011771 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11772 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011773 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011774 *
11775 * Return: 0 for success or error code
11776 */
11777static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011778send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011779{
11780 wmi_buf_t buf;
11781 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011782 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11783 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011784
nobeljf74583b2018-01-25 16:35:36 -080011785 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011786 if (buf == NULL)
11787 return QDF_STATUS_E_NOMEM;
11788
nobeljf74583b2018-01-25 16:35:36 -080011789 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11790 WMITLV_SET_HDR(&cmd->tlv_header,
11791 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11792 WMITLV_GET_STRUCT_TLVLEN
11793 (wmi_pdev_get_nfcal_power_fixed_param));
11794 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11795
11796 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011797 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11798 if (ret != 0) {
11799 WMI_LOGE("Sending get nfcal power cmd failed\n");
11800 wmi_buf_free(buf);
11801 }
11802
11803 return ret;
11804}
11805
11806/**
11807 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11808 * @wmi_handle: wmi handle
11809 * @param: pointer to ht ie param
11810 *
11811 * Return: 0 for success or error code
11812 */
11813static QDF_STATUS
11814send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11815 struct ht_ie_params *param)
11816{
11817 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11818 wmi_buf_t buf;
11819 QDF_STATUS ret;
11820 int32_t len;
11821 uint8_t *buf_ptr;
11822
11823 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11824 roundup(param->ie_len, sizeof(uint32_t));
11825
11826 buf = wmi_buf_alloc(wmi_handle, len);
11827 if (!buf) {
11828 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11829 return QDF_STATUS_E_FAILURE;
11830 }
11831
11832 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11833 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11834 WMITLV_SET_HDR(&cmd->tlv_header,
11835 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11836 WMITLV_GET_STRUCT_TLVLEN(
11837 wmi_pdev_set_ht_ie_cmd_fixed_param));
11838 cmd->reserved0 = 0;
11839 cmd->ie_len = param->ie_len;
11840 cmd->tx_streams = param->tx_streams;
11841 cmd->rx_streams = param->rx_streams;
11842
11843 buf_ptr += sizeof(*cmd);
11844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11845 buf_ptr += WMI_TLV_HDR_SIZE;
11846 if (param->ie_len)
11847 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11848 cmd->ie_len);
11849
11850 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11851 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11852
11853 if (ret != 0) {
11854 WMI_LOGE("Sending set ht ie cmd failed\n");
11855 wmi_buf_free(buf);
11856 }
11857
11858 return ret;
11859}
11860
11861/**
11862 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11863 * @wmi_handle: wmi handle
11864 * @param: pointer to vht ie param
11865 *
11866 * Return: 0 for success or error code
11867 */
11868static QDF_STATUS
11869send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11870 struct vht_ie_params *param)
11871{
11872 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11873 wmi_buf_t buf;
11874 QDF_STATUS ret;
11875 int32_t len;
11876 uint8_t *buf_ptr;
11877
11878 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11879 roundup(param->ie_len, sizeof(uint32_t));
11880
11881 buf = wmi_buf_alloc(wmi_handle, len);
11882 if (!buf) {
11883 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11884 return QDF_STATUS_E_FAILURE;
11885 }
11886
11887 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11888 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11889 WMITLV_SET_HDR(&cmd->tlv_header,
11890 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11891 WMITLV_GET_STRUCT_TLVLEN(
11892 wmi_pdev_set_vht_ie_cmd_fixed_param));
11893 cmd->reserved0 = 0;
11894 cmd->ie_len = param->ie_len;
11895 cmd->tx_streams = param->tx_streams;
11896 cmd->rx_streams = param->rx_streams;
11897
11898 buf_ptr += sizeof(*cmd);
11899 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11900 buf_ptr += WMI_TLV_HDR_SIZE;
11901 if (param->ie_len)
11902 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11903 cmd->ie_len);
11904
11905 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11906 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11907
11908 if (ret != 0) {
11909 WMI_LOGE("Sending set vht ie cmd failed\n");
11910 wmi_buf_free(buf);
11911 }
11912
11913 return ret;
11914}
11915
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011916/**
11917 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11918 * @wmi_handle: wmi handle
11919 * @param: pointer to quiet mode params
11920 *
11921 * Return: 0 for success or error code
11922 */
11923static QDF_STATUS
11924send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11925 struct set_quiet_mode_params *param)
11926{
11927 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11928 wmi_buf_t buf;
11929 QDF_STATUS ret;
11930 int32_t len;
11931
11932 len = sizeof(*quiet_cmd);
11933 buf = wmi_buf_alloc(wmi_handle, len);
11934 if (!buf) {
11935 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11936 return QDF_STATUS_E_FAILURE;
11937 }
11938
11939 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11940 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11941 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11942 WMITLV_GET_STRUCT_TLVLEN(
11943 wmi_pdev_set_quiet_cmd_fixed_param));
11944 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11945 quiet_cmd->enabled = param->enabled;
11946 quiet_cmd->period = (param->period)*(param->intval);
11947 quiet_cmd->duration = param->duration;
11948 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011949 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11950 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011951
11952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11953 WMI_PDEV_SET_QUIET_MODE_CMDID);
11954
11955 if (ret != 0) {
11956 WMI_LOGE("Sending set quiet cmd failed\n");
11957 wmi_buf_free(buf);
11958 }
11959
11960 return ret;
11961}
11962
11963/**
11964 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11965 * @wmi_handle: wmi handle
11966 * @param: pointer to set bwf param
11967 *
11968 * Return: 0 for success or error code
11969 */
11970static QDF_STATUS
11971send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11972 struct set_bwf_params *param)
11973{
11974 wmi_bwf_peer_info *peer_info;
11975 wmi_peer_bwf_request_fixed_param *cmd;
11976 wmi_buf_t buf;
11977 QDF_STATUS retval;
11978 int32_t len;
11979 uint8_t *buf_ptr;
11980 int i;
11981
11982 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11983 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11984 buf = wmi_buf_alloc(wmi_handle, len);
11985 if (!buf) {
11986 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11987 return QDF_STATUS_E_FAILURE;
11988 }
11989 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11990 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11991 WMITLV_SET_HDR(&cmd->tlv_header,
11992 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11993 WMITLV_GET_STRUCT_TLVLEN(
11994 wmi_peer_bwf_request_fixed_param));
11995 cmd->num_peers = param->num_peers;
11996
11997 buf_ptr += sizeof(*cmd);
11998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11999 sizeof(wmi_bwf_peer_info) *
12000 cmd->num_peers);
12001 buf_ptr += WMI_TLV_HDR_SIZE;
12002 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12003
12004 for (i = 0; i < cmd->num_peers; i++) {
12005 WMITLV_SET_HDR(&peer_info->tlv_header,
12006 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12007 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12008 peer_info->bwf_guaranteed_bandwidth =
12009 param->peer_info[i].throughput;
12010 peer_info->bwf_max_airtime =
12011 param->peer_info[i].max_airtime;
12012 peer_info->bwf_peer_priority =
12013 param->peer_info[i].priority;
12014 qdf_mem_copy(&peer_info->peer_macaddr,
12015 &param->peer_info[i].peer_macaddr,
12016 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012017 peer_info->vdev_id =
12018 param->peer_info[i].vdev_id;
12019 peer_info->pdev_id =
12020 wmi_handle->ops->convert_pdev_id_host_to_target(
12021 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012022 peer_info++;
12023 }
12024
12025 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12026 WMI_PEER_BWF_REQUEST_CMDID);
12027
12028 if (retval != QDF_STATUS_SUCCESS) {
12029 WMI_LOGE("%s : WMI Failed\n", __func__);
12030 wmi_buf_free(buf);
12031 }
12032
12033 return retval;
12034}
12035
12036/**
12037 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12038 * @wmi_handle: wmi handle
12039 * @param: pointer to hold mcast update param
12040 *
12041 * Return: 0 for success or error code
12042 */
12043static QDF_STATUS
12044send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12045 struct mcast_group_update_params *param)
12046{
12047 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12048 wmi_buf_t buf;
12049 QDF_STATUS ret;
12050 int32_t len;
12051 int offset = 0;
12052 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12053
12054 len = sizeof(*cmd);
12055 buf = wmi_buf_alloc(wmi_handle, len);
12056 if (!buf) {
12057 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12058 return QDF_STATUS_E_FAILURE;
12059 }
12060 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12061 WMITLV_SET_HDR(&cmd->tlv_header,
12062 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12063 WMITLV_GET_STRUCT_TLVLEN(
12064 wmi_peer_mcast_group_cmd_fixed_param));
12065 /* confirm the buffer is 4-byte aligned */
12066 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12067 qdf_mem_zero(cmd, sizeof(*cmd));
12068
12069 cmd->vdev_id = param->vap_id;
12070 /* construct the message assuming our endianness matches the target */
12071 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12072 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12073 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12074 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12075 if (param->is_action_delete)
12076 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12077
12078 if (param->is_mcast_addr_len)
12079 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12080
12081 if (param->is_filter_mode_snoop)
12082 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12083
12084 /* unicast address spec only applies for non-wildcard cases */
12085 if (!param->wildcard && param->ucast_mac_addr) {
12086 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12087 &cmd->ucast_mac_addr);
12088 }
Amar Singhal5593c902017-10-03 13:00:29 -070012089
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012090 if (param->mcast_ip_addr) {
12091 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12092 sizeof(cmd->mcast_ip_addr));
12093 offset = sizeof(cmd->mcast_ip_addr) -
12094 param->mcast_ip_addr_bytes;
12095 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12096 param->mcast_ip_addr,
12097 param->mcast_ip_addr_bytes);
12098 }
12099 if (!param->mask)
12100 param->mask = &dummymask[0];
12101
12102 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12103 param->mask,
12104 param->mcast_ip_addr_bytes);
12105
12106 if (param->srcs && param->nsrcs) {
12107 cmd->num_filter_addr = param->nsrcs;
12108 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12109 sizeof(cmd->filter_addr));
12110
12111 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12112 param->nsrcs * param->mcast_ip_addr_bytes);
12113 }
12114
12115 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12116 WMI_PEER_MCAST_GROUP_CMDID);
12117
12118 if (ret != QDF_STATUS_SUCCESS) {
12119 WMI_LOGE("%s : WMI Failed\n", __func__);
12120 wmi_buf_free(buf);
12121 }
12122
12123 return ret;
12124}
12125
12126/**
12127 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12128 * command to fw
12129 * @wmi_handle: wmi handle
12130 * @param: pointer to hold spectral config parameter
12131 *
12132 * Return: 0 for success or error code
12133 */
12134static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12135 struct vdev_spectral_configure_params *param)
12136{
12137 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12138 wmi_buf_t buf;
12139 QDF_STATUS ret;
12140 int32_t len;
12141
12142 len = sizeof(*cmd);
12143 buf = wmi_buf_alloc(wmi_handle, len);
12144 if (!buf) {
12145 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12146 return QDF_STATUS_E_FAILURE;
12147 }
12148
12149 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12150 WMITLV_SET_HDR(&cmd->tlv_header,
12151 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12152 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012153 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012154
12155 cmd->vdev_id = param->vdev_id;
12156 cmd->spectral_scan_count = param->count;
12157 cmd->spectral_scan_period = param->period;
12158 cmd->spectral_scan_priority = param->spectral_pri;
12159 cmd->spectral_scan_fft_size = param->fft_size;
12160 cmd->spectral_scan_gc_ena = param->gc_enable;
12161 cmd->spectral_scan_restart_ena = param->restart_enable;
12162 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12163 cmd->spectral_scan_init_delay = param->init_delay;
12164 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12165 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12166 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12167 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12168 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12169 cmd->spectral_scan_pwr_format = param->pwr_format;
12170 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12171 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012172 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012173 cmd->spectral_scan_chn_mask = param->chn_mask;
12174
12175 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12176 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12177
12178 if (ret != 0) {
12179 WMI_LOGE("Sending set quiet cmd failed\n");
12180 wmi_buf_free(buf);
12181 }
12182
12183 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12184 __func__);
12185
12186 WMI_LOGI("vdev_id = %u\n"
12187 "spectral_scan_count = %u\n"
12188 "spectral_scan_period = %u\n"
12189 "spectral_scan_priority = %u\n"
12190 "spectral_scan_fft_size = %u\n"
12191 "spectral_scan_gc_ena = %u\n"
12192 "spectral_scan_restart_ena = %u\n"
12193 "spectral_scan_noise_floor_ref = %u\n"
12194 "spectral_scan_init_delay = %u\n"
12195 "spectral_scan_nb_tone_thr = %u\n"
12196 "spectral_scan_str_bin_thr = %u\n"
12197 "spectral_scan_wb_rpt_mode = %u\n"
12198 "spectral_scan_rssi_rpt_mode = %u\n"
12199 "spectral_scan_rssi_thr = %u\n"
12200 "spectral_scan_pwr_format = %u\n"
12201 "spectral_scan_rpt_mode = %u\n"
12202 "spectral_scan_bin_scale = %u\n"
12203 "spectral_scan_dBm_adj = %u\n"
12204 "spectral_scan_chn_mask = %u\n",
12205 param->vdev_id,
12206 param->count,
12207 param->period,
12208 param->spectral_pri,
12209 param->fft_size,
12210 param->gc_enable,
12211 param->restart_enable,
12212 param->noise_floor_ref,
12213 param->init_delay,
12214 param->nb_tone_thr,
12215 param->str_bin_thr,
12216 param->wb_rpt_mode,
12217 param->rssi_rpt_mode,
12218 param->rssi_thr,
12219 param->pwr_format,
12220 param->rpt_mode,
12221 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012222 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012223 param->chn_mask);
12224 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12225
12226 return ret;
12227}
12228
12229/**
12230 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12231 * command to fw
12232 * @wmi_handle: wmi handle
12233 * @param: pointer to hold spectral enable parameter
12234 *
12235 * Return: 0 for success or error code
12236 */
12237static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12238 struct vdev_spectral_enable_params *param)
12239{
12240 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12241 wmi_buf_t buf;
12242 QDF_STATUS ret;
12243 int32_t len;
12244
12245 len = sizeof(*cmd);
12246 buf = wmi_buf_alloc(wmi_handle, len);
12247 if (!buf) {
12248 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12249 return QDF_STATUS_E_FAILURE;
12250 }
12251
12252 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12253 WMITLV_SET_HDR(&cmd->tlv_header,
12254 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12255 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012256 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012257
12258 cmd->vdev_id = param->vdev_id;
12259
12260 if (param->active_valid) {
12261 cmd->trigger_cmd = param->active ? 1 : 2;
12262 /* 1: Trigger, 2: Clear Trigger */
12263 } else {
12264 cmd->trigger_cmd = 0; /* 0: Ignore */
12265 }
12266
12267 if (param->enabled_valid) {
12268 cmd->enable_cmd = param->enabled ? 1 : 2;
12269 /* 1: Enable 2: Disable */
12270 } else {
12271 cmd->enable_cmd = 0; /* 0: Ignore */
12272 }
12273
12274 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12275 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12276
12277 if (ret != 0) {
12278 WMI_LOGE("Sending scan enable CMD failed\n");
12279 wmi_buf_free(buf);
12280 }
12281
12282 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12283
12284 WMI_LOGI("vdev_id = %u\n"
12285 "trigger_cmd = %u\n"
12286 "enable_cmd = %u\n",
12287 cmd->vdev_id,
12288 cmd->trigger_cmd,
12289 cmd->enable_cmd);
12290
12291 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12292
12293 return ret;
12294}
12295
12296/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012297 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12298 * @param wmi_handle : handle to WMI.
12299 * @param param : pointer to hold thermal mitigation param
12300 *
12301 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12302 */
12303static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12304 wmi_unified_t wmi_handle,
12305 struct thermal_mitigation_params *param)
12306{
12307 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12308 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12309 wmi_buf_t buf = NULL;
12310 uint8_t *buf_ptr = NULL;
12311 int error;
12312 int32_t len;
12313 int i;
12314
12315 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12316 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12317
12318 buf = wmi_buf_alloc(wmi_handle, len);
12319 if (!buf) {
12320 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12321 return QDF_STATUS_E_NOMEM;
12322 }
12323 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12324
12325 /* init fixed params */
12326 WMITLV_SET_HDR(tt_conf,
12327 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12328 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12329
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012330 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12331 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012332 tt_conf->enable = param->enable;
12333 tt_conf->dc = param->dc;
12334 tt_conf->dc_per_event = param->dc_per_event;
12335 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12336
12337 buf_ptr = (uint8_t *) ++tt_conf;
12338 /* init TLV params */
12339 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12340 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12341
12342 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12343 for (i = 0; i < THERMAL_LEVELS; i++) {
12344 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12345 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12346 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12347 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12348 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12349 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12350 lvl_conf->prio = param->levelconf[i].priority;
12351 lvl_conf++;
12352 }
12353
12354 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12355 WMI_THERM_THROT_SET_CONF_CMDID);
12356 if (QDF_IS_STATUS_ERROR(error)) {
12357 wmi_buf_free(buf);
12358 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12359 }
12360
12361 return error;
12362}
12363
12364/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012365 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12366 * @wmi_handle: wmi handle
12367 * @param: pointer to pdev_qvit_params
12368 *
12369 * Return: 0 for success or error code
12370 */
12371static QDF_STATUS
12372send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12373 struct pdev_qvit_params *param)
12374{
12375 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012376 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012377 uint8_t *cmd;
12378 static uint8_t msgref = 1;
12379 uint8_t segnumber = 0, seginfo, numsegments;
12380 uint16_t chunk_len, total_bytes;
12381 uint8_t *bufpos;
12382 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12383
12384 bufpos = param->utf_payload;
12385 total_bytes = param->len;
12386 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12387 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12388 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12389
12390 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12391 numsegments++;
12392
12393 while (param->len) {
12394 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012395 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012396 else
12397 chunk_len = param->len;
12398
12399 buf = wmi_buf_alloc(wmi_handle,
12400 (chunk_len + sizeof(seghdrinfo) +
12401 WMI_TLV_HDR_SIZE));
12402 if (!buf) {
12403 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12404 return QDF_STATUS_E_NOMEM;
12405 }
12406
12407 cmd = (uint8_t *) wmi_buf_data(buf);
12408
12409 seghdrinfo.len = total_bytes;
12410 seghdrinfo.msgref = msgref;
12411 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12412 seghdrinfo.segmentInfo = seginfo;
12413
12414 segnumber++;
12415
12416 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12417 (chunk_len + sizeof(seghdrinfo)));
12418 cmd += WMI_TLV_HDR_SIZE;
12419 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12420 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12421
12422 ret = wmi_unified_cmd_send(wmi_handle, buf,
12423 (chunk_len + sizeof(seghdrinfo) +
12424 WMI_TLV_HDR_SIZE),
12425 WMI_PDEV_QVIT_CMDID);
12426
12427 if (ret != 0) {
12428 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12429 wmi_buf_free(buf);
12430 break;
12431 }
12432
12433 param->len -= chunk_len;
12434 bufpos += chunk_len;
12435 }
12436 msgref++;
12437
12438 return ret;
12439}
12440
12441/**
12442 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12443 * @wmi_handle: wmi handle
12444 * @param: pointer to wmm update param
12445 *
12446 * Return: 0 for success or error code
12447 */
12448static QDF_STATUS
12449send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12450 struct wmm_update_params *param)
12451{
12452 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12453 wmi_wmm_params *wmm_param;
12454 wmi_buf_t buf;
12455 QDF_STATUS ret;
12456 int32_t len;
12457 int ac = 0;
12458 struct wmi_host_wmeParams *wmep;
12459 uint8_t *buf_ptr;
12460
12461 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12462 buf = wmi_buf_alloc(wmi_handle, len);
12463 if (!buf) {
12464 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12465 return QDF_STATUS_E_FAILURE;
12466 }
12467
12468 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12469 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12470 WMITLV_SET_HDR(&cmd->tlv_header,
12471 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12472 WMITLV_GET_STRUCT_TLVLEN
12473 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12474
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012475 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012476
12477 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12478
12479 for (ac = 0; ac < WME_NUM_AC; ac++) {
12480 wmep = &param->wmep_array[ac];
12481 wmm_param = (wmi_wmm_params *)buf_ptr;
12482 WMITLV_SET_HDR(&wmm_param->tlv_header,
12483 WMITLV_TAG_STRUC_wmi_wmm_params,
12484 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12485 wmm_param->aifs = wmep->wmep_aifsn;
12486 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12487 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12488 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12489 wmm_param->acm = wmep->wmep_acm;
12490 wmm_param->no_ack = wmep->wmep_noackPolicy;
12491 buf_ptr += sizeof(wmi_wmm_params);
12492 }
12493 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12494 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12495
12496 if (ret != 0) {
12497 WMI_LOGE("Sending WMM update CMD failed\n");
12498 wmi_buf_free(buf);
12499 }
12500
12501 return ret;
12502}
12503
Sathish Kumar80f4f382017-04-24 11:36:00 +053012504/**
12505 * send_coex_config_cmd_tlv() - send coex config command to fw
12506 * @wmi_handle: wmi handle
12507 * @param: pointer to coex config param
12508 *
12509 * Return: 0 for success or error code
12510 */
12511static QDF_STATUS
12512send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12513 struct coex_config_params *param)
12514{
12515 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12516 wmi_buf_t buf;
12517 QDF_STATUS ret;
12518 int32_t len;
12519
12520 len = sizeof(*cmd);
12521 buf = wmi_buf_alloc(wmi_handle, len);
12522 if (!buf) {
12523 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12524 return QDF_STATUS_E_FAILURE;
12525 }
12526
12527 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12528 WMITLV_SET_HDR(&cmd->tlv_header,
12529 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12530 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012531 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012532
12533 cmd->vdev_id = param->vdev_id;
12534 cmd->config_type = param->config_type;
12535 cmd->config_arg1 = param->config_arg1;
12536 cmd->config_arg2 = param->config_arg2;
12537 cmd->config_arg3 = param->config_arg3;
12538 cmd->config_arg4 = param->config_arg4;
12539 cmd->config_arg5 = param->config_arg5;
12540 cmd->config_arg6 = param->config_arg6;
12541
12542 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12543 WMI_COEX_CONFIG_CMDID);
12544
12545 if (ret != 0) {
12546 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12547 wmi_buf_free(buf);
12548 }
12549
12550 return ret;
12551}
12552
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012553
12554#ifdef WLAN_SUPPORT_TWT
12555static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12556 target_resource_config *tgt_res_cfg)
12557{
12558 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12559 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12560}
12561#else
12562static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12563 target_resource_config *tgt_res_cfg)
12564{
12565 resource_cfg->twt_ap_pdev_count = 0;
12566 resource_cfg->twt_ap_sta_count = 0;
12567}
12568#endif
12569
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012570static
Govind Singh9ddd5162016-03-07 16:30:32 +053012571void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012572 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012573{
Govind Singhe7f2f342016-05-23 12:12:52 +053012574 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012575 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12576 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12577 resource_cfg->num_offload_reorder_buffs =
12578 tgt_res_cfg->num_offload_reorder_buffs;
12579 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12580 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12581 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12582 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12583 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12584 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12585 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12586 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12587 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12588 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12589 resource_cfg->scan_max_pending_req =
12590 tgt_res_cfg->scan_max_pending_req;
12591 resource_cfg->bmiss_offload_max_vdev =
12592 tgt_res_cfg->bmiss_offload_max_vdev;
12593 resource_cfg->roam_offload_max_vdev =
12594 tgt_res_cfg->roam_offload_max_vdev;
12595 resource_cfg->roam_offload_max_ap_profiles =
12596 tgt_res_cfg->roam_offload_max_ap_profiles;
12597 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12598 resource_cfg->num_mcast_table_elems =
12599 tgt_res_cfg->num_mcast_table_elems;
12600 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12601 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12602 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12603 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12604 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12605 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12606 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12607 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12608 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12609 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12610 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12611 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12612 resource_cfg->num_tdls_conn_table_entries =
12613 tgt_res_cfg->num_tdls_conn_table_entries;
12614 resource_cfg->beacon_tx_offload_max_vdev =
12615 tgt_res_cfg->beacon_tx_offload_max_vdev;
12616 resource_cfg->num_multicast_filter_entries =
12617 tgt_res_cfg->num_multicast_filter_entries;
12618 resource_cfg->num_wow_filters =
12619 tgt_res_cfg->num_wow_filters;
12620 resource_cfg->num_keep_alive_pattern =
12621 tgt_res_cfg->num_keep_alive_pattern;
12622 resource_cfg->keep_alive_pattern_size =
12623 tgt_res_cfg->keep_alive_pattern_size;
12624 resource_cfg->max_tdls_concurrent_sleep_sta =
12625 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12626 resource_cfg->max_tdls_concurrent_buffer_sta =
12627 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12628 resource_cfg->wmi_send_separate =
12629 tgt_res_cfg->wmi_send_separate;
12630 resource_cfg->num_ocb_vdevs =
12631 tgt_res_cfg->num_ocb_vdevs;
12632 resource_cfg->num_ocb_channels =
12633 tgt_res_cfg->num_ocb_channels;
12634 resource_cfg->num_ocb_schedules =
12635 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012636 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012637 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12638 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012639 resource_cfg->max_num_dbs_scan_duty_cycle =
12640 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012641 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012642 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12643 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012644
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012645 if (tgt_res_cfg->atf_config)
12646 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12647 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12648 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12649 resource_cfg->flag1, 1);
12650 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12651 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12652 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012653 if (tgt_res_cfg->cce_disable)
12654 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012655
12656 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012657}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012658
12659/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12660 * @wmi_handle: pointer to wmi handle
12661 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012662 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012663 * @param: point host parameters for init command
12664 *
12665 * Return: Updated pointer of buf_ptr.
12666 */
12667static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12668 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12669{
12670 uint16_t idx;
12671
12672 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12673 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12674 wmi_pdev_band_to_mac *band_to_mac;
12675
12676 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12677 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12678 sizeof(wmi_resource_config) +
12679 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12680 sizeof(wlan_host_memory_chunk)));
12681
12682 WMITLV_SET_HDR(&hw_mode->tlv_header,
12683 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12684 (WMITLV_GET_STRUCT_TLVLEN
12685 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12686
12687 hw_mode->hw_mode_index = param->hw_mode_id;
12688 hw_mode->num_band_to_mac = param->num_band_to_mac;
12689
12690 buf_ptr = (uint8_t *) (hw_mode + 1);
12691 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12692 WMI_TLV_HDR_SIZE);
12693 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12694 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12695 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12696 WMITLV_GET_STRUCT_TLVLEN
12697 (wmi_pdev_band_to_mac));
12698 band_to_mac[idx].pdev_id =
12699 wmi_handle->ops->convert_pdev_id_host_to_target(
12700 param->band_to_mac[idx].pdev_id);
12701 band_to_mac[idx].start_freq =
12702 param->band_to_mac[idx].start_freq;
12703 band_to_mac[idx].end_freq =
12704 param->band_to_mac[idx].end_freq;
12705 }
12706 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12707 (param->num_band_to_mac *
12708 sizeof(wmi_pdev_band_to_mac)) +
12709 WMI_TLV_HDR_SIZE;
12710
12711 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12712 (param->num_band_to_mac *
12713 sizeof(wmi_pdev_band_to_mac)));
12714 }
12715
12716 return buf_ptr;
12717}
12718
12719static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12720 wmi_init_cmd_fixed_param *cmd)
12721{
12722 int num_whitelist;
12723 wmi_abi_version my_vers;
12724
12725 num_whitelist = sizeof(version_whitelist) /
12726 sizeof(wmi_whitelist_version_info);
12727 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12728 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12729 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12730 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12731 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12732 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12733
12734 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12735 &my_vers,
12736 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12737 &cmd->host_abi_vers);
12738
12739 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12740 __func__,
12741 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12742 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12743 cmd->host_abi_vers.abi_version_ns_0,
12744 cmd->host_abi_vers.abi_version_ns_1,
12745 cmd->host_abi_vers.abi_version_ns_2,
12746 cmd->host_abi_vers.abi_version_ns_3);
12747
12748 /* Save version sent from host -
12749 * Will be used to check ready event
12750 */
12751 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12752 sizeof(wmi_abi_version));
12753}
12754
Sathish Kumarfd347372017-02-13 12:29:09 +053012755static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012756{
12757 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12758 wmi_service_ready_event_fixed_param *ev;
12759
12760
12761 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12762
12763 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12764 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012765 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012766
12767 /*Save fw version from service ready message */
12768 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012769 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012770 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012771
Govind Singhb53420c2016-03-09 14:32:57 +053012772 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012773}
12774
12775/**
12776 * wmi_unified_save_fw_version_cmd() - save fw version
12777 * @wmi_handle: pointer to wmi handle
12778 * @res_cfg: resource config
12779 * @num_mem_chunks: no of mem chunck
12780 * @mem_chunk: pointer to mem chunck structure
12781 *
12782 * This function sends IE information to firmware
12783 *
Govind Singhb53420c2016-03-09 14:32:57 +053012784 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012785 *
12786 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012787static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012788 void *evt_buf)
12789{
12790 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12791 wmi_ready_event_fixed_param *ev = NULL;
12792
12793 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12794 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012795 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12796 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012797 &ev->fw_abi_vers)) {
12798 /*
12799 * Error: Our host version and the given firmware version
12800 * are incompatible.
12801 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012802 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012803 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12804 __func__,
12805 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12806 abi_version_0),
12807 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12808 abi_version_0),
12809 wmi_handle->final_abi_vers.abi_version_ns_0,
12810 wmi_handle->final_abi_vers.abi_version_ns_1,
12811 wmi_handle->final_abi_vers.abi_version_ns_2,
12812 wmi_handle->final_abi_vers.abi_version_ns_3,
12813 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12814 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12815 ev->fw_abi_vers.abi_version_ns_0,
12816 ev->fw_abi_vers.abi_version_ns_1,
12817 ev->fw_abi_vers.abi_version_ns_2,
12818 ev->fw_abi_vers.abi_version_ns_3);
12819
Govind Singhb53420c2016-03-09 14:32:57 +053012820 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012821 }
Govind Singhb53420c2016-03-09 14:32:57 +053012822 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012823 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012824 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012825 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012826
Govind Singhb53420c2016-03-09 14:32:57 +053012827 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012828}
Govind Singha4836fd2016-03-07 16:45:38 +053012829
12830/**
12831 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12832 * @wmi_handle: wmi handle
12833 * @custom_addr: base mac address
12834 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012835 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012836 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012837static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012838 uint8_t *custom_addr)
12839{
12840 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12841 wmi_buf_t buf;
12842 int err;
12843
12844 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012846 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012847 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012848 }
12849
12850 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012851 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012852
12853 WMITLV_SET_HDR(&cmd->tlv_header,
12854 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12855 WMITLV_GET_STRUCT_TLVLEN
12856 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12857 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012858 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12859 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012860 err = wmi_unified_cmd_send(wmi_handle, buf,
12861 sizeof(*cmd),
12862 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12863 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012864 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012865 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012866 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012867 }
12868
12869 return 0;
12870}
12871
12872/**
12873 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12874 * @handle: wmi handle
12875 * @event: Event received from FW
12876 * @len: Length of the event
12877 *
12878 * Enables the low frequency events and disables the high frequency
12879 * events. Bit 17 indicates if the event if low/high frequency.
12880 * 1 - high frequency, 0 - low frequency
12881 *
12882 * Return: 0 on successfully enabling/disabling the events
12883 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012884static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012885 uint8_t *event,
12886 uint32_t len)
12887{
12888 uint32_t num_of_diag_events_logs;
12889 wmi_diag_event_log_config_fixed_param *cmd;
12890 wmi_buf_t buf;
12891 uint8_t *buf_ptr;
12892 uint32_t *cmd_args, *evt_args;
12893 uint32_t buf_len, i;
12894
12895 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12896 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12897
Govind Singhb53420c2016-03-09 14:32:57 +053012898 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012899
12900 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12901 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012902 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012903 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012904 }
12905 wmi_event = param_buf->fixed_param;
12906 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012907
12908 if (num_of_diag_events_logs >
12909 param_buf->num_diag_events_logs_list) {
12910 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12911 num_of_diag_events_logs,
12912 param_buf->num_diag_events_logs_list);
12913 return QDF_STATUS_E_INVAL;
12914 }
12915
Govind Singha4836fd2016-03-07 16:45:38 +053012916 evt_args = param_buf->diag_events_logs_list;
12917 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012918 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012919 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012920 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012921 }
12922
Govind Singhb53420c2016-03-09 14:32:57 +053012923 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012924 __func__, num_of_diag_events_logs);
12925
12926 /* Free any previous allocation */
12927 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012928 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012929
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012930 if (num_of_diag_events_logs >
12931 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12932 WMI_LOGE("%s: excess num of logs:%d", __func__,
12933 num_of_diag_events_logs);
12934 QDF_ASSERT(0);
12935 return QDF_STATUS_E_INVAL;
12936 }
Govind Singha4836fd2016-03-07 16:45:38 +053012937 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012938 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012939 sizeof(uint32_t));
12940 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012941 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012942 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012943 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012944 }
12945 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12946
12947 /* Prepare the send buffer */
12948 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12949 (num_of_diag_events_logs * sizeof(uint32_t));
12950
12951 buf = wmi_buf_alloc(wmi_handle, buf_len);
12952 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012953 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12954 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012955 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012956 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012957 }
12958
12959 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12960 buf_ptr = (uint8_t *) cmd;
12961
12962 WMITLV_SET_HDR(&cmd->tlv_header,
12963 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12964 WMITLV_GET_STRUCT_TLVLEN(
12965 wmi_diag_event_log_config_fixed_param));
12966
12967 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12968
12969 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12970
12971 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12972 (num_of_diag_events_logs * sizeof(uint32_t)));
12973
12974 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12975
12976 /* Populate the events */
12977 for (i = 0; i < num_of_diag_events_logs; i++) {
12978 /* Low freq (0) - Enable (1) the event
12979 * High freq (1) - Disable (0) the event
12980 */
12981 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12982 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12983 /* Set the event ID */
12984 WMI_DIAG_ID_SET(cmd_args[i],
12985 WMI_DIAG_ID_GET(evt_args[i]));
12986 /* Set the type */
12987 WMI_DIAG_TYPE_SET(cmd_args[i],
12988 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012989 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012990 wmi_handle->events_logs_list[i] = evt_args[i];
12991 }
12992
12993 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12994 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012995 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012996 __func__);
12997 wmi_buf_free(buf);
12998 /* Not clearing events_logs_list, though wmi cmd failed.
12999 * Host can still have this list
13000 */
Govind Singh67922e82016-04-01 16:48:57 +053013001 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013002 }
13003
13004 return 0;
13005}
13006
13007/**
13008 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13009 * @wmi_handle: wmi handle
13010 * @start_log: Start logging related parameters
13011 *
13012 * Send the command to the FW based on which specific logging of diag
13013 * event/log id can be started/stopped
13014 *
13015 * Return: None
13016 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013017static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013018 struct wmi_wifi_start_log *start_log)
13019{
13020 wmi_diag_event_log_config_fixed_param *cmd;
13021 wmi_buf_t buf;
13022 uint8_t *buf_ptr;
13023 uint32_t len, count, log_level, i;
13024 uint32_t *cmd_args;
13025 uint32_t total_len;
13026 count = 0;
13027
13028 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013029 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013030 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013031 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013032 }
13033 /* total_len stores the number of events where BITS 17 and 18 are set.
13034 * i.e., events of high frequency (17) and for extended debugging (18)
13035 */
13036 total_len = 0;
13037 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13038 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13039 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13040 total_len++;
13041 }
13042
13043 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13044 (total_len * sizeof(uint32_t));
13045
13046 buf = wmi_buf_alloc(wmi_handle, len);
13047 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013048 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013049 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013050 }
13051 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13052 buf_ptr = (uint8_t *) cmd;
13053
13054 WMITLV_SET_HDR(&cmd->tlv_header,
13055 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13056 WMITLV_GET_STRUCT_TLVLEN(
13057 wmi_diag_event_log_config_fixed_param));
13058
13059 cmd->num_of_diag_events_logs = total_len;
13060
13061 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13062
13063 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13064 (total_len * sizeof(uint32_t)));
13065
13066 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13067
Govind Singh224a7312016-06-21 14:33:26 +053013068 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013069 log_level = 1;
13070 else
13071 log_level = 0;
13072
Govind Singhb53420c2016-03-09 14:32:57 +053013073 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013074 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13075 uint32_t val = wmi_handle->events_logs_list[i];
13076 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13077 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13078
13079 WMI_DIAG_ID_SET(cmd_args[count],
13080 WMI_DIAG_ID_GET(val));
13081 WMI_DIAG_TYPE_SET(cmd_args[count],
13082 WMI_DIAG_TYPE_GET(val));
13083 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13084 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013085 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013086 count++;
13087 }
13088 }
13089
13090 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13091 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013092 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013093 __func__);
13094 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013095 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013096 }
13097
Govind Singhb53420c2016-03-09 14:32:57 +053013098 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013099}
13100
13101/**
13102 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13103 * @wmi_handle: WMI handle
13104 *
13105 * This function is used to send the flush command to the FW,
13106 * that will flush the fw logs that are residue in the FW
13107 *
13108 * Return: None
13109 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013110static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013111{
13112 wmi_debug_mesg_flush_fixed_param *cmd;
13113 wmi_buf_t buf;
13114 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013115 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013116
13117 buf = wmi_buf_alloc(wmi_handle, len);
13118 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013119 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013120 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013121 }
13122
13123 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13124 WMITLV_SET_HDR(&cmd->tlv_header,
13125 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13126 WMITLV_GET_STRUCT_TLVLEN(
13127 wmi_debug_mesg_flush_fixed_param));
13128 cmd->reserved0 = 0;
13129
13130 ret = wmi_unified_cmd_send(wmi_handle,
13131 buf,
13132 len,
13133 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013134 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013135 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013136 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013137 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013138 }
Govind Singhb53420c2016-03-09 14:32:57 +053013139 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013140
Govind Singh67922e82016-04-01 16:48:57 +053013141 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013142}
13143
13144/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013145 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013146 * @wmi_handle: wmi handle
13147 * @msg: PCL structure containing the PCL and the number of channels
13148 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013149 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013150 * firmware. The DBS Manager is the consumer of this information in the WLAN
13151 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13152 * to migrate to a new channel without host driver involvement. An example of
13153 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13154 * manage the channel selection without firmware involvement.
13155 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013156 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13157 * channel list. The weights corresponds to the channels sent in
13158 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13159 * weightage compared to the non PCL channels.
13160 *
Govind Singha4836fd2016-03-07 16:45:38 +053013161 * Return: Success if the cmd is sent successfully to the firmware
13162 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013163static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013164 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013165{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013166 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013167 wmi_buf_t buf;
13168 uint8_t *buf_ptr;
13169 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013170 uint32_t chan_len;
13171
13172 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013173
13174 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013175 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013176
13177 buf = wmi_buf_alloc(wmi_handle, len);
13178 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013179 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13180 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013181 }
13182
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013183 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013184 buf_ptr = (uint8_t *) cmd;
13185 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013186 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13187 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013188
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013189 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13190 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013191 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013192 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013193
13194 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013195 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013196 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013197 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013198 for (i = 0; i < chan_len ; i++) {
13199 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013200 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013201 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013202 }
13203 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013204 WMI_PDEV_SET_PCL_CMDID)) {
13205 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013206 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013207 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013208 }
Govind Singhb53420c2016-03-09 14:32:57 +053013209 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013210}
13211
13212/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013213 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013214 * @wmi_handle: wmi handle
13215 * @msg: Structure containing the following parameters
13216 *
13217 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13218 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13219 *
13220 * Provides notification to the WLAN firmware that host driver is requesting a
13221 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13222 * configurations that include the Dual Band Simultaneous (DBS) feature.
13223 *
13224 * Return: Success if the cmd is sent successfully to the firmware
13225 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013226static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013227 uint32_t hw_mode_index)
13228{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013229 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013230 wmi_buf_t buf;
13231 uint32_t len;
13232
13233 len = sizeof(*cmd);
13234
13235 buf = wmi_buf_alloc(wmi_handle, len);
13236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013237 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13238 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013239 }
13240
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013241 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013242 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013243 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13244 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13245
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013246 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13247 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013248 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013249 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013250
13251 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013252 WMI_PDEV_SET_HW_MODE_CMDID)) {
13253 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013254 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013255 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013256 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013257 }
13258
Govind Singhb53420c2016-03-09 14:32:57 +053013259 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013260}
13261
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013262#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013263/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013264 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013265 * @wmi_handle: wmi handle
13266 * @msg: Dual MAC config parameters
13267 *
13268 * Configures WLAN firmware with the dual MAC features
13269 *
Govind Singhb53420c2016-03-09 14:32:57 +053013270 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013271 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013272static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013273QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013274 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013275{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013276 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013277 wmi_buf_t buf;
13278 uint32_t len;
13279
13280 len = sizeof(*cmd);
13281
13282 buf = wmi_buf_alloc(wmi_handle, len);
13283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013284 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13285 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013286 }
13287
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013288 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013289 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013290 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013291 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013292 wmi_pdev_set_mac_config_cmd_fixed_param));
13293
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013294 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13295 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013296 cmd->concurrent_scan_config_bits = msg->scan_config;
13297 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013298 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013299 __func__, msg->scan_config, msg->fw_mode_config);
13300
13301 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013302 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13303 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013304 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013305 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013306 }
Govind Singhb53420c2016-03-09 14:32:57 +053013307 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013308}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013309#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013310
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013311#ifdef BIG_ENDIAN_HOST
13312/**
13313* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13314* @param data_len - data length
13315* @param data - pointer to data
13316*
13317* Return: QDF_STATUS - success or error status
13318*/
13319static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13320 struct fips_params *param)
13321{
13322 unsigned char *key_unaligned, *data_unaligned;
13323 int c;
13324 u_int8_t *key_aligned = NULL;
13325 u_int8_t *data_aligned = NULL;
13326
13327 /* Assigning unaligned space to copy the key */
13328 key_unaligned = qdf_mem_malloc(
13329 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13330 data_unaligned = qdf_mem_malloc(
13331 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13332
Jeff Johnsonda263992018-05-12 14:22:00 -070013333 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013334 if (key_unaligned == NULL)
13335 return QDF_STATUS_SUCCESS;
13336 /* Checking if space is aligned */
13337 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13338 /* align to 4 */
13339 key_aligned =
13340 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13341 FIPS_ALIGN);
13342 } else {
13343 key_aligned = (u_int8_t *)key_unaligned;
13344 }
13345
13346 /* memset and copy content from key to key aligned */
13347 OS_MEMSET(key_aligned, 0, param->key_len);
13348 OS_MEMCPY(key_aligned, param->key, param->key_len);
13349
13350 /* print a hexdump for host debug */
13351 print_hex_dump(KERN_DEBUG,
13352 "\t Aligned and Copied Key:@@@@ ",
13353 DUMP_PREFIX_NONE,
13354 16, 1, key_aligned, param->key_len, true);
13355
Jeff Johnsonda263992018-05-12 14:22:00 -070013356 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013357 if (data_unaligned == NULL)
13358 return QDF_STATUS_SUCCESS;
13359 /* Checking of space is aligned */
13360 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13361 /* align to 4 */
13362 data_aligned =
13363 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13364 FIPS_ALIGN);
13365 } else {
13366 data_aligned = (u_int8_t *)data_unaligned;
13367 }
13368
13369 /* memset and copy content from data to data aligned */
13370 OS_MEMSET(data_aligned, 0, param->data_len);
13371 OS_MEMCPY(data_aligned, param->data, param->data_len);
13372
13373 /* print a hexdump for host debug */
13374 print_hex_dump(KERN_DEBUG,
13375 "\t Properly Aligned and Copied Data:@@@@ ",
13376 DUMP_PREFIX_NONE,
13377 16, 1, data_aligned, param->data_len, true);
13378
13379 /* converting to little Endian both key_aligned and
13380 * data_aligned*/
13381 for (c = 0; c < param->key_len/4; c++) {
13382 *((u_int32_t *)key_aligned+c) =
13383 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13384 }
13385 for (c = 0; c < param->data_len/4; c++) {
13386 *((u_int32_t *)data_aligned+c) =
13387 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13388 }
13389
13390 /* update endian data to key and data vectors */
13391 OS_MEMCPY(param->key, key_aligned, param->key_len);
13392 OS_MEMCPY(param->data, data_aligned, param->data_len);
13393
13394 /* clean up allocated spaces */
13395 qdf_mem_free(key_unaligned);
13396 key_unaligned = NULL;
13397 key_aligned = NULL;
13398
13399 qdf_mem_free(data_unaligned);
13400 data_unaligned = NULL;
13401 data_aligned = NULL;
13402
13403 return QDF_STATUS_SUCCESS;
13404}
13405#else
13406/**
13407* fips_align_data_be() - DUMMY for LE platform
13408*
13409* Return: QDF_STATUS - success
13410*/
13411static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13412 struct fips_params *param)
13413{
13414 return QDF_STATUS_SUCCESS;
13415}
13416#endif
13417
13418
13419/**
13420 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13421 * @wmi_handle: wmi handle
13422 * @param: pointer to hold pdev fips param
13423 *
13424 * Return: 0 for success or error code
13425 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013426static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013427send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13428 struct fips_params *param)
13429{
13430 wmi_pdev_fips_cmd_fixed_param *cmd;
13431 wmi_buf_t buf;
13432 uint8_t *buf_ptr;
13433 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13434 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13435
13436 /* Length TLV placeholder for array of bytes */
13437 len += WMI_TLV_HDR_SIZE;
13438 if (param->data_len)
13439 len += (param->data_len*sizeof(uint8_t));
13440
13441 /*
13442 * Data length must be multiples of 16 bytes - checked against 0xF -
13443 * and must be less than WMI_SVC_MSG_SIZE - static size of
13444 * wmi_pdev_fips_cmd structure
13445 */
13446
13447 /* do sanity on the input */
13448 if (!(((param->data_len & 0xF) == 0) &&
13449 ((param->data_len > 0) &&
13450 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13451 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13452 return QDF_STATUS_E_INVAL;
13453 }
13454
13455 buf = wmi_buf_alloc(wmi_handle, len);
13456 if (!buf) {
13457 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13458 return QDF_STATUS_E_FAILURE;
13459 }
13460
13461 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13462 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13463 WMITLV_SET_HDR(&cmd->tlv_header,
13464 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13465 WMITLV_GET_STRUCT_TLVLEN
13466 (wmi_pdev_fips_cmd_fixed_param));
13467
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013468 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13469 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013470 if (param->key != NULL && param->data != NULL) {
13471 cmd->key_len = param->key_len;
13472 cmd->data_len = param->data_len;
13473 cmd->fips_cmd = !!(param->op);
13474
13475 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13476 return QDF_STATUS_E_FAILURE;
13477
13478 qdf_mem_copy(cmd->key, param->key, param->key_len);
13479
13480 if (param->mode == FIPS_ENGINE_AES_CTR ||
13481 param->mode == FIPS_ENGINE_AES_MIC) {
13482 cmd->mode = param->mode;
13483 } else {
13484 cmd->mode = FIPS_ENGINE_AES_CTR;
13485 }
13486 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13487 cmd->key_len, cmd->data_len);
13488
13489 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13490 cmd->key, cmd->key_len, true);
13491 buf_ptr += sizeof(*cmd);
13492
13493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13494
13495 buf_ptr += WMI_TLV_HDR_SIZE;
13496 if (param->data_len)
13497 qdf_mem_copy(buf_ptr,
13498 (uint8_t *) param->data, param->data_len);
13499
13500 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13501 16, 1, buf_ptr, cmd->data_len, true);
13502
13503 buf_ptr += param->data_len;
13504
13505 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13506 WMI_PDEV_FIPS_CMDID);
13507 qdf_print("%s return value %d\n", __func__, retval);
13508 } else {
13509 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13510 wmi_buf_free(buf);
13511 retval = -QDF_STATUS_E_BADMSG;
13512 }
13513
13514 return retval;
13515}
13516
Wu Gao52c0b772018-05-17 16:14:00 +080013517#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013518/**
13519 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13520 * @wmi_handle: wmi handle
13521 * @vdev_id: vdev id
13522 * @bitmap: Event bitmap
13523 * @enable: enable/disable
13524 *
13525 * Return: CDF status
13526 */
13527static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13528 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013529 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013530 bool enable)
13531{
13532 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13533 uint16_t len;
13534 wmi_buf_t buf;
13535 int ret;
13536
13537 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13538 buf = wmi_buf_alloc(wmi_handle, len);
13539 if (!buf) {
13540 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13541 return QDF_STATUS_E_NOMEM;
13542 }
13543 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13544 WMITLV_SET_HDR(&cmd->tlv_header,
13545 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13546 WMITLV_GET_STRUCT_TLVLEN
13547 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13548 cmd->vdev_id = vdev_id;
13549 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013550 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13551 WMI_WOW_MAX_EVENT_BM_LEN);
13552
13553 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13554 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13555 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013556
13557 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13558 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13559 if (ret) {
13560 WMI_LOGE("Failed to config wow wakeup event");
13561 wmi_buf_free(buf);
13562 return QDF_STATUS_E_FAILURE;
13563 }
13564
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013565 return QDF_STATUS_SUCCESS;
13566}
13567
13568/**
13569 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13570 * @wmi_handle: wmi handle
13571 * @vdev_id: vdev id
13572 * @ptrn_id: pattern id
13573 * @ptrn: pattern
13574 * @ptrn_len: pattern length
13575 * @ptrn_offset: pattern offset
13576 * @mask: mask
13577 * @mask_len: mask length
13578 * @user: true for user configured pattern and false for default pattern
13579 * @default_patterns: default patterns
13580 *
13581 * Return: CDF status
13582 */
13583static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13584 uint8_t vdev_id, uint8_t ptrn_id,
13585 const uint8_t *ptrn, uint8_t ptrn_len,
13586 uint8_t ptrn_offset, const uint8_t *mask,
13587 uint8_t mask_len, bool user,
13588 uint8_t default_patterns)
13589{
13590 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13591 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13592 wmi_buf_t buf;
13593 uint8_t *buf_ptr;
13594 int32_t len;
13595 int ret;
13596
13597 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13598 WMI_TLV_HDR_SIZE +
13599 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13600 WMI_TLV_HDR_SIZE +
13601 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13602 WMI_TLV_HDR_SIZE +
13603 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13604 WMI_TLV_HDR_SIZE +
13605 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13606 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013607 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013608
13609 buf = wmi_buf_alloc(wmi_handle, len);
13610 if (!buf) {
13611 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13612 return QDF_STATUS_E_NOMEM;
13613 }
13614
13615 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13616 buf_ptr = (uint8_t *) cmd;
13617
13618 WMITLV_SET_HDR(&cmd->tlv_header,
13619 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13620 WMITLV_GET_STRUCT_TLVLEN
13621 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13622 cmd->vdev_id = vdev_id;
13623 cmd->pattern_id = ptrn_id;
13624
13625 cmd->pattern_type = WOW_BITMAP_PATTERN;
13626 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13627
13628 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13629 sizeof(WOW_BITMAP_PATTERN_T));
13630 buf_ptr += WMI_TLV_HDR_SIZE;
13631 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13632
13633 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13634 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13635 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13636
13637 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13638 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13639
13640 bitmap_pattern->pattern_offset = ptrn_offset;
13641 bitmap_pattern->pattern_len = ptrn_len;
13642
13643 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13644 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13645
13646 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13647 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13648
13649 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13650 bitmap_pattern->pattern_id = ptrn_id;
13651
13652 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13653 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13654 bitmap_pattern->pattern_offset, user);
13655 WMI_LOGI("Pattern : ");
13656 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13657 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13658
13659 WMI_LOGI("Mask : ");
13660 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13661 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13662
13663 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13664
13665 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13667 buf_ptr += WMI_TLV_HDR_SIZE;
13668
13669 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13670 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13671 buf_ptr += WMI_TLV_HDR_SIZE;
13672
13673 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13675 buf_ptr += WMI_TLV_HDR_SIZE;
13676
13677 /* Fill TLV for pattern_info_timeout but no data. */
13678 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13679 buf_ptr += WMI_TLV_HDR_SIZE;
13680
13681 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013683 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013684 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013685
13686 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13687 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13688 if (ret) {
13689 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13690 wmi_buf_free(buf);
13691 return QDF_STATUS_E_FAILURE;
13692 }
13693
13694 return QDF_STATUS_SUCCESS;
13695}
13696
Govind Singha4836fd2016-03-07 16:45:38 +053013697/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013698 * fill_arp_offload_params_tlv() - Fill ARP offload data
13699 * @wmi_handle: wmi handle
13700 * @offload_req: offload request
13701 * @buf_ptr: buffer pointer
13702 *
13703 * To fill ARP offload data to firmware
13704 * when target goes to wow mode.
13705 *
13706 * Return: None
13707 */
13708static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013709 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013710{
13711
13712 int i;
13713 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013714 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013715
13716 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13717 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13718 *buf_ptr += WMI_TLV_HDR_SIZE;
13719 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13720 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13721 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13722 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13723 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13724
13725 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013726 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013727 /* Copy the target ip addr and flags */
13728 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13729 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013730 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013731 WMI_IPV4_ADDR_LEN);
13732 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013733 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013734 }
13735 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13736 }
13737}
13738
13739#ifdef WLAN_NS_OFFLOAD
13740/**
13741 * fill_ns_offload_params_tlv() - Fill NS offload data
13742 * @wmi|_handle: wmi handle
13743 * @offload_req: offload request
13744 * @buf_ptr: buffer pointer
13745 *
13746 * To fill NS offload data to firmware
13747 * when target goes to wow mode.
13748 *
13749 * Return: None
13750 */
13751static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013752 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013753{
13754
13755 int i;
13756 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013757
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013758 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13759 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13760 *buf_ptr += WMI_TLV_HDR_SIZE;
13761 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13762 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13763 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13764 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13765 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13766
13767 /*
13768 * Fill data only for NS offload in the first ARP tuple for LA
13769 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013770 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013771 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13772 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013773 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013774 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013775 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013776 sizeof(WMI_IPV6_ADDR));
13777 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013778 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013779 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013780 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013781 ns_tuple->flags |=
13782 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13783 }
13784 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013785 i, &ns_req->self_ipv6_addr[i],
13786 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013787
13788 /* target MAC is optional, check if it is valid,
13789 * if this is not valid, the target will use the known
13790 * local MAC address rather than the tuple
13791 */
13792 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013793 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013794 &ns_tuple->target_mac);
13795 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13796 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13797 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13798 }
13799 }
13800 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13801 }
13802}
13803
13804
13805/**
13806 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13807 * @wmi: wmi handle
13808 * @offload_req: offload request
13809 * @buf_ptr: buffer pointer
13810 *
13811 * To fill extended NS offload extended data to firmware
13812 * when target goes to wow mode.
13813 *
13814 * Return: None
13815 */
13816static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013817 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013818{
13819 int i;
13820 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13821 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013822
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013823 count = ns_req->num_ns_offload_count;
13824 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013825 WMI_MAX_NS_OFFLOADS;
13826
13827 /* Populate extended NS offload tuples */
13828 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13829 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13830 *buf_ptr += WMI_TLV_HDR_SIZE;
13831 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13832 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13833 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13834 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13835 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13836
13837 /*
13838 * Fill data only for NS offload in the first ARP tuple for LA
13839 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013840 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013841 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13842 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013843 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013844 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013845 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013846 sizeof(WMI_IPV6_ADDR));
13847 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013848 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013849 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013850 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013851 ns_tuple->flags |=
13852 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13853 }
13854 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013855 i, &ns_req->self_ipv6_addr[i],
13856 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013857
13858 /* target MAC is optional, check if it is valid,
13859 * if this is not valid, the target will use the
13860 * known local MAC address rather than the tuple
13861 */
13862 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013863 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013864 &ns_tuple->target_mac);
13865 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13866 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13867 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13868 }
13869 }
13870 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13871 }
13872}
13873#else
13874static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013875 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013876{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013877}
13878
13879static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013880 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013881{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013882}
13883#endif
13884
13885/**
Govind Singha4836fd2016-03-07 16:45:38 +053013886 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13887 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013888 * @arp_offload_req: arp offload request
13889 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013890 * @arp_only: flag
13891 *
13892 * To configure ARP NS off load data to firmware
13893 * when target goes to wow mode.
13894 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013895 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013896 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013897static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013898 struct pmo_arp_offload_params *arp_offload_req,
13899 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013900 uint8_t vdev_id)
13901{
Govind Singha4836fd2016-03-07 16:45:38 +053013902 int32_t res;
13903 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013904 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013905 wmi_buf_t buf;
13906 int32_t len;
13907 uint32_t count = 0, num_ns_ext_tuples = 0;
13908
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013909 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013910
Govind Singha4836fd2016-03-07 16:45:38 +053013911 /*
13912 * TLV place holder size for array of NS tuples
13913 * TLV place holder size for array of ARP tuples
13914 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013915 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13916 WMI_TLV_HDR_SIZE +
13917 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13918 WMI_TLV_HDR_SIZE +
13919 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013920
13921 /*
13922 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13923 * extra length for extended NS offload tuples which follows ARP offload
13924 * tuples. Host needs to fill this structure in following format:
13925 * 2 NS ofload tuples
13926 * 2 ARP offload tuples
13927 * N numbers of extended NS offload tuples if HDD has given more than
13928 * 2 NS offload addresses
13929 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013930 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013931 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013932 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13933 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013934 }
13935
13936 buf = wmi_buf_alloc(wmi_handle, len);
13937 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013938 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013939 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013940 }
13941
Vivekc5823092018-03-22 23:27:21 +053013942 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013943 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13944 WMITLV_SET_HDR(&cmd->tlv_header,
13945 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13946 WMITLV_GET_STRUCT_TLVLEN
13947 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13948 cmd->flags = 0;
13949 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013950 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013951
Govind Singhb53420c2016-03-09 14:32:57 +053013952 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013953
Govind Singha4836fd2016-03-07 16:45:38 +053013954 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013955 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13956 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13957 if (num_ns_ext_tuples)
13958 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013959
13960 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13961 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13962 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013963 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013964 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013965 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013966 }
13967
Govind Singhb53420c2016-03-09 14:32:57 +053013968 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013969}
13970
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013971/**
13972 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13973 * @wmi_handle: wmi handle
13974 * @vdev_id: vdev id
13975 * @action: true for enable else false
13976 *
13977 * To enable enhance multicast offload to firmware
13978 * when target goes to wow mode.
13979 *
13980 * Return: QDF Status
13981 */
13982
13983static
13984QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13985 wmi_unified_t wmi_handle,
13986 uint8_t vdev_id, bool action)
13987{
13988 QDF_STATUS status;
13989 wmi_buf_t buf;
13990 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13991
13992 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13993 if (!buf) {
13994 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13995 return QDF_STATUS_E_NOMEM;
13996 }
13997
13998 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13999 wmi_buf_data(buf);
14000
14001 WMITLV_SET_HDR(&cmd->tlv_header,
14002 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14003 WMITLV_GET_STRUCT_TLVLEN(
14004 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14005
14006 cmd->vdev_id = vdev_id;
14007 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14008 ENHANCED_MCAST_FILTER_ENABLED);
14009 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14010 __func__, action, vdev_id);
14011 status = wmi_unified_cmd_send(wmi_handle, buf,
14012 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14013 if (status != QDF_STATUS_SUCCESS) {
14014 qdf_nbuf_free(buf);
14015 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14016 __func__);
14017 }
14018
14019 return status;
14020}
14021
14022/**
14023 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14024 * @wmi_handle: wmi handle
14025 * @param evt_buf: pointer to event buffer
14026 * @param hdr: Pointer to hold header
14027 * @param bufp: Pointer to hold pointer to rx param buffer
14028 *
14029 * Return: QDF_STATUS_SUCCESS for success or error code
14030 */
14031static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14032 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14033{
14034 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14035 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14036
14037 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14038 if (!param_buf) {
14039 WMI_LOGE("gtk param_buf is NULL");
14040 return QDF_STATUS_E_INVAL;
14041 }
14042
14043 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14044 WMI_LOGE("Invalid length for GTK status");
14045 return QDF_STATUS_E_INVAL;
14046 }
14047
14048 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14049 param_buf->fixed_param;
14050 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14051 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14052 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14053 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14054 &fixed_param->replay_counter,
14055 GTK_REPLAY_COUNTER_BYTES);
14056
14057 return QDF_STATUS_SUCCESS;
14058
14059}
14060
14061#ifdef FEATURE_WLAN_RA_FILTERING
14062/**
14063 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14064 * @wmi_handle: wmi handle
14065 * @vdev_id: vdev id
14066 *
14067 * Return: CDF status
14068 */
14069static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14070 uint8_t vdev_id, uint8_t default_pattern,
14071 uint16_t rate_limit_interval)
14072{
14073
14074 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14075 wmi_buf_t buf;
14076 uint8_t *buf_ptr;
14077 int32_t len;
14078 int ret;
14079
14080 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14081 WMI_TLV_HDR_SIZE +
14082 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14083 WMI_TLV_HDR_SIZE +
14084 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14085 WMI_TLV_HDR_SIZE +
14086 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14087 WMI_TLV_HDR_SIZE +
14088 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14089 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014090 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014091
14092 buf = wmi_buf_alloc(wmi_handle, len);
14093 if (!buf) {
14094 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14095 return QDF_STATUS_E_NOMEM;
14096 }
14097
14098 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14099 buf_ptr = (uint8_t *) cmd;
14100
14101 WMITLV_SET_HDR(&cmd->tlv_header,
14102 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14103 WMITLV_GET_STRUCT_TLVLEN
14104 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14105 cmd->vdev_id = vdev_id;
14106 cmd->pattern_id = default_pattern,
14107 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14108 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14109
14110 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14111 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14112 buf_ptr += WMI_TLV_HDR_SIZE;
14113
14114 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14115 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14116 buf_ptr += WMI_TLV_HDR_SIZE;
14117
14118 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14120 buf_ptr += WMI_TLV_HDR_SIZE;
14121
14122 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14123 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14124 buf_ptr += WMI_TLV_HDR_SIZE;
14125
14126 /* Fill TLV for pattern_info_timeout but no data. */
14127 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14128 buf_ptr += WMI_TLV_HDR_SIZE;
14129
14130 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014132 buf_ptr += WMI_TLV_HDR_SIZE;
14133
Vivekc5823092018-03-22 23:27:21 +053014134 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014135
14136 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14137 rate_limit_interval, vdev_id);
14138
14139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14140 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14141 if (ret) {
14142 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14143 wmi_buf_free(buf);
14144 return QDF_STATUS_E_FAILURE;
14145 }
14146
14147 return QDF_STATUS_SUCCESS;
14148
14149}
14150#endif /* FEATURE_WLAN_RA_FILTERING */
14151
14152/**
14153 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14154 * @wmi_handle: wmi handle
14155 * @vdev_id: vdev id
14156 * @multicastAddr: mcast address
14157 * @clearList: clear list flag
14158 *
14159 * Return: QDF_STATUS_SUCCESS for success or error code
14160 */
14161static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14162 uint8_t vdev_id,
14163 struct qdf_mac_addr multicast_addr,
14164 bool clearList)
14165{
14166 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14167 wmi_buf_t buf;
14168 int err;
14169
14170 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14171 if (!buf) {
14172 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14173 return QDF_STATUS_E_NOMEM;
14174 }
14175
14176 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14177 qdf_mem_zero(cmd, sizeof(*cmd));
14178
14179 WMITLV_SET_HDR(&cmd->tlv_header,
14180 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14181 WMITLV_GET_STRUCT_TLVLEN
14182 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14183 cmd->action =
14184 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14185 cmd->vdev_id = vdev_id;
14186 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14187
14188 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14189 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14190
14191 err = wmi_unified_cmd_send(wmi_handle, buf,
14192 sizeof(*cmd),
14193 WMI_SET_MCASTBCAST_FILTER_CMDID);
14194 if (err) {
14195 WMI_LOGE("Failed to send set_param cmd");
14196 wmi_buf_free(buf);
14197 return QDF_STATUS_E_FAILURE;
14198 }
14199
14200 return QDF_STATUS_SUCCESS;
14201}
14202
14203/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014204 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14205 * command to fw
14206 * @wmi_handle: wmi handle
14207 * @vdev_id: vdev id
14208 * @mcast_filter_params: mcast filter params
14209 *
14210 * Return: QDF_STATUS_SUCCESS for success or error code
14211 */
14212static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14213 wmi_unified_t wmi_handle,
14214 uint8_t vdev_id,
14215 struct pmo_mcast_filter_params *filter_param)
14216
14217{
14218 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14219 uint8_t *buf_ptr;
14220 wmi_buf_t buf;
14221 int err;
14222 int i;
14223 uint8_t *mac_addr_src_ptr = NULL;
14224 wmi_mac_addr *mac_addr_dst_ptr;
14225 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14226 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14227
14228 buf = wmi_buf_alloc(wmi_handle, len);
14229 if (!buf) {
14230 WMI_LOGE("Failed to allocate memory");
14231 return QDF_STATUS_E_NOMEM;
14232 }
14233
Vivekc5823092018-03-22 23:27:21 +053014234 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014235 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14236 wmi_buf_data(buf);
14237 qdf_mem_zero(cmd, sizeof(*cmd));
14238
14239 WMITLV_SET_HDR(&cmd->tlv_header,
14240 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14241 WMITLV_GET_STRUCT_TLVLEN
14242 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14243 cmd->operation =
14244 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14245 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14246 cmd->vdev_id = vdev_id;
14247 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14248
14249 buf_ptr += sizeof(*cmd);
14250 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14251 sizeof(wmi_mac_addr) *
14252 filter_param->multicast_addr_cnt);
14253
14254 if (filter_param->multicast_addr_cnt == 0)
14255 goto send_cmd;
14256
14257 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14258 mac_addr_dst_ptr = (wmi_mac_addr *)
14259 (buf_ptr + WMI_TLV_HDR_SIZE);
14260
14261 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14262 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14263 mac_addr_src_ptr += ATH_MAC_LEN;
14264 mac_addr_dst_ptr++;
14265 }
14266
14267send_cmd:
14268 err = wmi_unified_cmd_send(wmi_handle, buf,
14269 len,
14270 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14271 if (err) {
14272 WMI_LOGE("Failed to send set_param cmd");
14273 wmi_buf_free(buf);
14274 return QDF_STATUS_E_FAILURE;
14275 }
14276
14277 return QDF_STATUS_SUCCESS;
14278}
14279
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014280static void
14281fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
14282 uint8_t vdev_id,
14283 struct pmo_gtk_req *params)
14284{
14285 uint8_t *buf_ptr;
14286 wmi_gtk_offload_fils_tlv_param *ext_param;
14287
14288 buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
14289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14290 sizeof(*ext_param));
14291 buf_ptr += WMI_TLV_HDR_SIZE;
14292
14293 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14294 WMITLV_SET_HDR(&ext_param->tlv_header,
14295 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14296 WMITLV_GET_STRUCT_TLVLEN(
14297 wmi_gtk_offload_fils_tlv_param));
14298 ext_param->vdev_id = vdev_id;
14299 ext_param->flags = cmd->flags;
14300 ext_param->kek_len = params->kek_len;
14301 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14302 qdf_mem_copy(ext_param->KCK, params->kck,
14303 WMI_GTK_OFFLOAD_KCK_BYTES);
14304 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14305 GTK_REPLAY_COUNTER_BYTES);
14306}
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014307
14308/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014309 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14310 * @wmi_handle: wmi handle
14311 * @vdev_id: vdev id
14312 * @params: GTK offload parameters
14313 *
14314 * Return: CDF status
14315 */
14316static
14317QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14318 struct pmo_gtk_req *params,
14319 bool enable_offload,
14320 uint32_t gtk_offload_opcode)
14321{
14322 int len;
14323 wmi_buf_t buf;
14324 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14325 QDF_STATUS status = QDF_STATUS_SUCCESS;
14326
14327 WMI_LOGD("%s Enter", __func__);
14328
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014329 len = sizeof(*cmd);
14330
14331 if (params->is_fils_connection)
14332 len += WMI_TLV_HDR_SIZE +
14333 sizeof(wmi_gtk_offload_fils_tlv_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014334
14335 /* alloc wmi buffer */
14336 buf = wmi_buf_alloc(wmi_handle, len);
14337 if (!buf) {
14338 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14339 status = QDF_STATUS_E_NOMEM;
14340 goto out;
14341 }
14342
14343 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14344 WMITLV_SET_HDR(&cmd->tlv_header,
14345 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14346 WMITLV_GET_STRUCT_TLVLEN
14347 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14348
14349 cmd->vdev_id = vdev_id;
14350
14351 /* Request target to enable GTK offload */
14352 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14353 cmd->flags = gtk_offload_opcode;
14354
14355 /* Copy the keys and replay counter */
14356 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014357 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014358 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14359 GTK_REPLAY_COUNTER_BYTES);
14360 } else {
14361 cmd->flags = gtk_offload_opcode;
14362 }
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014363 if (params->is_fils_connection)
14364 fill_fils_tlv_params(cmd, vdev_id, params);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014365
14366 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 +053014367 /* send the wmi command */
14368 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14369 WMI_GTK_OFFLOAD_CMDID)) {
14370 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14371 wmi_buf_free(buf);
14372 status = QDF_STATUS_E_FAILURE;
14373 }
14374
14375out:
14376 WMI_LOGD("%s Exit", __func__);
14377 return status;
14378}
14379
14380/**
14381 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14382 * @wmi_handle: wmi handle
14383 * @params: GTK offload params
14384 *
14385 * Return: CDF status
14386 */
14387static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14388 wmi_unified_t wmi_handle,
14389 uint8_t vdev_id,
14390 uint64_t offload_req_opcode)
14391{
14392 int len;
14393 wmi_buf_t buf;
14394 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14395 QDF_STATUS status = QDF_STATUS_SUCCESS;
14396
14397 len = sizeof(*cmd);
14398
14399 /* alloc wmi buffer */
14400 buf = wmi_buf_alloc(wmi_handle, len);
14401 if (!buf) {
14402 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14403 status = QDF_STATUS_E_NOMEM;
14404 goto out;
14405 }
14406
14407 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14408 WMITLV_SET_HDR(&cmd->tlv_header,
14409 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14410 WMITLV_GET_STRUCT_TLVLEN
14411 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14412
14413 /* Request for GTK offload status */
14414 cmd->flags = offload_req_opcode;
14415 cmd->vdev_id = vdev_id;
14416
14417 /* send the wmi command */
14418 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14419 WMI_GTK_OFFLOAD_CMDID)) {
14420 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14421 wmi_buf_free(buf);
14422 status = QDF_STATUS_E_FAILURE;
14423 }
14424
14425out:
14426 return status;
14427}
14428
14429/**
14430 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14431 * @wmi_handle: wmi handler
14432 * @action_params: pointer to action_params
14433 *
14434 * Return: 0 for success, otherwise appropriate error code
14435 */
14436static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14437 struct pmo_action_wakeup_set_params *action_params)
14438{
14439 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14440 wmi_buf_t buf;
14441 int i;
14442 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014443 uint32_t len = 0, *cmd_args;
14444 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014445
Vivekc5823092018-03-22 23:27:21 +053014446 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014447 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14448 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014449 if (!buf) {
14450 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14451 return QDF_STATUS_E_NOMEM;
14452 }
14453 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014454 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014455 WMITLV_SET_HDR(&cmd->tlv_header,
14456 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14457 WMITLV_GET_STRUCT_TLVLEN(
14458 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14459
14460 cmd->vdev_id = action_params->vdev_id;
14461 cmd->operation = action_params->operation;
14462
14463 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14464 cmd->action_category_map[i] =
14465 action_params->action_category_map[i];
14466
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014467 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014469 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014470 buf_ptr += WMI_TLV_HDR_SIZE;
14471 cmd_args = (uint32_t *) buf_ptr;
14472 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14473 cmd_args[i] = action_params->action_per_category[i];
14474
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014475 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014476 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014477 if (err) {
14478 WMI_LOGE("Failed to send ap_ps_egap cmd");
14479 wmi_buf_free(buf);
14480 return QDF_STATUS_E_FAILURE;
14481 }
14482
14483 return QDF_STATUS_SUCCESS;
14484}
14485
14486#ifdef FEATURE_WLAN_LPHB
14487
14488/**
14489 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14490 * @wmi_handle: wmi handle
14491 * @lphb_conf_req: configuration info
14492 *
14493 * Return: CDF status
14494 */
14495static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14496 wmi_hb_set_enable_cmd_fixed_param *params)
14497{
14498 QDF_STATUS status;
14499 wmi_buf_t buf = NULL;
14500 uint8_t *buf_ptr;
14501 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14502 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14503
14504
14505 buf = wmi_buf_alloc(wmi_handle, len);
14506 if (!buf) {
14507 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14508 return QDF_STATUS_E_NOMEM;
14509 }
14510
14511 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14512 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14513 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14514 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14515 WMITLV_GET_STRUCT_TLVLEN
14516 (wmi_hb_set_enable_cmd_fixed_param));
14517
14518 /* fill in values */
14519 hb_enable_fp->vdev_id = params->session;
14520 hb_enable_fp->enable = params->enable;
14521 hb_enable_fp->item = params->item;
14522 hb_enable_fp->session = params->session;
14523
14524 status = wmi_unified_cmd_send(wmi_handle, buf,
14525 len, WMI_HB_SET_ENABLE_CMDID);
14526 if (QDF_IS_STATUS_ERROR(status)) {
14527 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14528 status);
14529 wmi_buf_free(buf);
14530 }
14531
14532 return status;
14533}
14534
14535/**
14536 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14537 * @wmi_handle: wmi handle
14538 * @lphb_conf_req: lphb config request
14539 *
14540 * Return: CDF status
14541 */
14542static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14543 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14544{
14545 QDF_STATUS status;
14546 wmi_buf_t buf = NULL;
14547 uint8_t *buf_ptr;
14548 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14549 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14550
14551 buf = wmi_buf_alloc(wmi_handle, len);
14552 if (!buf) {
14553 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14554 return QDF_STATUS_E_NOMEM;
14555 }
14556
14557 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14558 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14559 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14560 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14561 WMITLV_GET_STRUCT_TLVLEN
14562 (wmi_hb_set_tcp_params_cmd_fixed_param));
14563
14564 /* fill in values */
14565 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14566 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14567 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14568 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14569 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14570 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14571 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14572 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14573 hb_tcp_params_fp->session = lphb_conf_req->session;
14574 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14575 &lphb_conf_req->gateway_mac,
14576 sizeof(hb_tcp_params_fp->gateway_mac));
14577
14578 status = wmi_unified_cmd_send(wmi_handle, buf,
14579 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14580 if (QDF_IS_STATUS_ERROR(status)) {
14581 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14582 status);
14583 wmi_buf_free(buf);
14584 }
14585
14586 return status;
14587}
14588
14589/**
14590 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14591 * @wmi_handle: wmi handle
14592 * @lphb_conf_req: lphb config request
14593 *
14594 * Return: CDF status
14595 */
14596static
14597QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14598 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14599{
14600 QDF_STATUS status;
14601 wmi_buf_t buf = NULL;
14602 uint8_t *buf_ptr;
14603 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14604 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14605
14606 buf = wmi_buf_alloc(wmi_handle, len);
14607 if (!buf) {
14608 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14609 return QDF_STATUS_E_NOMEM;
14610 }
14611
14612 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14613 hb_tcp_filter_fp =
14614 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14615 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14616 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14617 WMITLV_GET_STRUCT_TLVLEN
14618 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14619
14620 /* fill in values */
14621 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14622 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14623 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14624 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14625 memcpy((void *)&hb_tcp_filter_fp->filter,
14626 (void *)&g_hb_tcp_filter_fp->filter,
14627 WMI_WLAN_HB_MAX_FILTER_SIZE);
14628
14629 status = wmi_unified_cmd_send(wmi_handle, buf,
14630 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14631 if (QDF_IS_STATUS_ERROR(status)) {
14632 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14633 status);
14634 wmi_buf_free(buf);
14635 }
14636
14637 return status;
14638}
14639
14640/**
14641 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14642 * @wmi_handle: wmi handle
14643 * @lphb_conf_req: lphb config request
14644 *
14645 * Return: CDF status
14646 */
14647static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14648 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14649{
14650 QDF_STATUS status;
14651 wmi_buf_t buf = NULL;
14652 uint8_t *buf_ptr;
14653 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14654 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14655
14656 buf = wmi_buf_alloc(wmi_handle, len);
14657 if (!buf) {
14658 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14659 return QDF_STATUS_E_NOMEM;
14660 }
14661
14662 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14663 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14664 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14665 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14666 WMITLV_GET_STRUCT_TLVLEN
14667 (wmi_hb_set_udp_params_cmd_fixed_param));
14668
14669 /* fill in values */
14670 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14671 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14672 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14673 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14674 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14675 hb_udp_params_fp->interval = lphb_conf_req->interval;
14676 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14677 hb_udp_params_fp->session = lphb_conf_req->session;
14678 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14679 &lphb_conf_req->gateway_mac,
14680 sizeof(lphb_conf_req->gateway_mac));
14681
14682 status = wmi_unified_cmd_send(wmi_handle, buf,
14683 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14684 if (QDF_IS_STATUS_ERROR(status)) {
14685 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14686 status);
14687 wmi_buf_free(buf);
14688 }
14689
14690 return status;
14691}
14692
14693/**
14694 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14695 * @wmi_handle: wmi handle
14696 * @lphb_conf_req: lphb config request
14697 *
14698 * Return: CDF status
14699 */
14700static
14701QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14702 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14703{
14704 QDF_STATUS status;
14705 wmi_buf_t buf = NULL;
14706 uint8_t *buf_ptr;
14707 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14708 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14709
14710 buf = wmi_buf_alloc(wmi_handle, len);
14711 if (!buf) {
14712 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14713 return QDF_STATUS_E_NOMEM;
14714 }
14715
14716 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14717 hb_udp_filter_fp =
14718 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14719 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14720 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14721 WMITLV_GET_STRUCT_TLVLEN
14722 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14723
14724 /* fill in values */
14725 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14726 hb_udp_filter_fp->length = lphb_conf_req->length;
14727 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14728 hb_udp_filter_fp->session = lphb_conf_req->session;
14729 memcpy((void *)&hb_udp_filter_fp->filter,
14730 (void *)&lphb_conf_req->filter,
14731 WMI_WLAN_HB_MAX_FILTER_SIZE);
14732
14733 status = wmi_unified_cmd_send(wmi_handle, buf,
14734 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14735 if (QDF_IS_STATUS_ERROR(status)) {
14736 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14737 status);
14738 wmi_buf_free(buf);
14739 }
14740
14741 return status;
14742}
14743#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014744
Dustin Brownf31f88b2017-05-12 14:01:44 -070014745static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14746 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014747{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014748 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014749 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014750 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014751
Dustin Brownf31f88b2017-05-12 14:01:44 -070014752 if (!req) {
14753 WMI_LOGE("req is null");
14754 return QDF_STATUS_E_INVAL;
14755 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014756
Dustin Brownf31f88b2017-05-12 14:01:44 -070014757 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14758 if (!wmi_buf) {
14759 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014760 return QDF_STATUS_E_NOMEM;
14761 }
14762
Dustin Brownf31f88b2017-05-12 14:01:44 -070014763 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014764 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014765 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14766 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14767 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014768 cmd->enable = req->enable;
14769 /* Set all modes in case of disable */
14770 if (!cmd->enable)
14771 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14772 else
14773 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014774
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014775 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14776 req->enable ? "enable" : "disable", req->mode_bitmap,
14777 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014778
Dustin Brownf31f88b2017-05-12 14:01:44 -070014779 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14780 WMI_HW_DATA_FILTER_CMDID);
14781 if (QDF_IS_STATUS_ERROR(status)) {
14782 WMI_LOGE("Failed to configure hw filter");
14783 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014784 }
14785
Dustin Brownf31f88b2017-05-12 14:01:44 -070014786 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014787}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014788
14789/**
14790 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14791 * @wmi_handle: wmi handle
14792 * @vdev_id: vdev id
14793 * @enable: Flag to enable/disable packet filter
14794 *
14795 * Return: QDF_STATUS_SUCCESS for success or error code
14796 */
14797static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14798 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14799{
14800 int32_t len;
14801 int ret = 0;
14802 wmi_buf_t buf;
14803 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14804
14805 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14806
14807 buf = wmi_buf_alloc(wmi_handle, len);
14808 if (!buf) {
14809 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14810 return QDF_STATUS_E_NOMEM;
14811 }
14812
14813 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14814 WMITLV_SET_HDR(&cmd->tlv_header,
14815 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14816 WMITLV_GET_STRUCT_TLVLEN(
14817 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14818
14819 cmd->vdev_id = vdev_id;
14820 if (enable)
14821 cmd->enable = PACKET_FILTER_SET_ENABLE;
14822 else
14823 cmd->enable = PACKET_FILTER_SET_DISABLE;
14824
14825 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14826 __func__, cmd->enable, vdev_id);
14827
14828 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14829 WMI_PACKET_FILTER_ENABLE_CMDID);
14830 if (ret) {
14831 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14832 wmi_buf_free(buf);
14833 }
14834
14835 return ret;
14836}
14837
14838/**
14839 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14840 * @wmi_handle: wmi handle
14841 * @vdev_id: vdev id
14842 * @rcv_filter_param: Packet filter parameters
14843 * @filter_id: Filter id
14844 * @enable: Flag to add/delete packet filter configuration
14845 *
14846 * Return: QDF_STATUS_SUCCESS for success or error code
14847 */
14848static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14849 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14850 uint8_t filter_id, bool enable)
14851{
14852 int len, i;
14853 int err = 0;
14854 wmi_buf_t buf;
14855 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14856
14857
14858 /* allocate the memory */
14859 len = sizeof(*cmd);
14860 buf = wmi_buf_alloc(wmi_handle, len);
14861 if (!buf) {
14862 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14863 return QDF_STATUS_E_NOMEM;
14864 }
14865
14866 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14867 WMITLV_SET_HDR(&cmd->tlv_header,
14868 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14869 WMITLV_GET_STRUCT_TLVLEN
14870 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14871
14872 cmd->vdev_id = vdev_id;
14873 cmd->filter_id = filter_id;
14874 if (enable)
14875 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14876 else
14877 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14878
14879 if (enable) {
14880 cmd->num_params = QDF_MIN(
14881 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14882 rcv_filter_param->num_params);
14883 cmd->filter_type = rcv_filter_param->filter_type;
14884 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14885
14886 for (i = 0; i < cmd->num_params; i++) {
14887 cmd->paramsData[i].proto_type =
14888 rcv_filter_param->params_data[i].protocol_layer;
14889 cmd->paramsData[i].cmp_type =
14890 rcv_filter_param->params_data[i].compare_flag;
14891 cmd->paramsData[i].data_length =
14892 rcv_filter_param->params_data[i].data_length;
14893 cmd->paramsData[i].data_offset =
14894 rcv_filter_param->params_data[i].data_offset;
14895 memcpy(&cmd->paramsData[i].compareData,
14896 rcv_filter_param->params_data[i].compare_data,
14897 sizeof(cmd->paramsData[i].compareData));
14898 memcpy(&cmd->paramsData[i].dataMask,
14899 rcv_filter_param->params_data[i].data_mask,
14900 sizeof(cmd->paramsData[i].dataMask));
14901 }
14902 }
14903
14904 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14905 cmd->filter_action, cmd->filter_id, cmd->num_params);
14906 /* send the command along with data */
14907 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14908 WMI_PACKET_FILTER_CONFIG_CMDID);
14909 if (err) {
14910 WMI_LOGE("Failed to send pkt_filter cmd");
14911 wmi_buf_free(buf);
14912 return QDF_STATUS_E_FAILURE;
14913 }
14914
14915 return QDF_STATUS_SUCCESS;
14916}
Wu Gao52c0b772018-05-17 16:14:00 +080014917#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014918
Govind Singha4836fd2016-03-07 16:45:38 +053014919/**
14920 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14921 * @wmi_handle: wmi handle
14922 * @request: SSID hotlist set request
14923 *
Govind Singhb53420c2016-03-09 14:32:57 +053014924 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014925 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014926static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014927send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14928 struct ssid_hotlist_request_params *request)
14929{
14930 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14931 wmi_buf_t wmi_buf;
14932 uint32_t len;
14933 uint32_t array_size;
14934 uint8_t *buf_ptr;
14935
14936 /* length of fixed portion */
14937 len = sizeof(*cmd);
14938
14939 /* length of variable portion */
14940 array_size =
14941 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14942 len += WMI_TLV_HDR_SIZE + array_size;
14943
14944 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14945 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014946 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14947 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014948 }
14949
14950 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14951 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14952 buf_ptr;
14953 WMITLV_SET_HDR
14954 (&cmd->tlv_header,
14955 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14956 WMITLV_GET_STRUCT_TLVLEN
14957 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14958
14959 cmd->request_id = request->request_id;
14960 cmd->requestor_id = 0;
14961 cmd->vdev_id = request->session_id;
14962 cmd->table_id = 0;
14963 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14964 cmd->total_entries = request->ssid_count;
14965 cmd->num_entries_in_page = request->ssid_count;
14966 cmd->first_entry_index = 0;
14967
14968 buf_ptr += sizeof(*cmd);
14969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14970
14971 if (request->ssid_count) {
14972 wmi_extscan_hotlist_ssid_entry *entry;
14973 int i;
14974
14975 buf_ptr += WMI_TLV_HDR_SIZE;
14976 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14977 for (i = 0; i < request->ssid_count; i++) {
14978 WMITLV_SET_HDR
14979 (entry,
14980 WMITLV_TAG_ARRAY_STRUC,
14981 WMITLV_GET_STRUCT_TLVLEN
14982 (wmi_extscan_hotlist_ssid_entry));
14983 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014984 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014985 request->ssids[i].ssid.mac_ssid,
14986 request->ssids[i].ssid.length);
14987 entry->band = request->ssids[i].band;
14988 entry->min_rssi = request->ssids[i].rssi_low;
14989 entry->max_rssi = request->ssids[i].rssi_high;
14990 entry++;
14991 }
14992 cmd->mode = WMI_EXTSCAN_MODE_START;
14993 } else {
14994 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14995 }
14996
14997 if (wmi_unified_cmd_send
14998 (wmi_handle, wmi_buf, len,
14999 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015000 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015001 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015002 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015003 }
15004
Govind Singhb53420c2016-03-09 14:32:57 +053015005 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015006}
15007
15008/**
15009 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15010 * @wmi_handle: wmi handle
15011 * @vdev_id: vdev id
15012 *
15013 * This function sends roam synch complete event to fw.
15014 *
15015 * Return: CDF STATUS
15016 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015017static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015018 uint8_t vdev_id)
15019{
15020 wmi_roam_synch_complete_fixed_param *cmd;
15021 wmi_buf_t wmi_buf;
15022 uint8_t *buf_ptr;
15023 uint16_t len;
15024 len = sizeof(wmi_roam_synch_complete_fixed_param);
15025
15026 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15027 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015028 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15029 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015030 }
15031 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15032 buf_ptr = (uint8_t *) cmd;
15033 WMITLV_SET_HDR(&cmd->tlv_header,
15034 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15035 WMITLV_GET_STRUCT_TLVLEN
15036 (wmi_roam_synch_complete_fixed_param));
15037 cmd->vdev_id = vdev_id;
15038 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15039 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015040 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015041 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015042 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015043 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015044 }
15045
Govind Singhb53420c2016-03-09 14:32:57 +053015046 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015047}
15048
15049/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015050 * send_fw_test_cmd_tlv() - send fw test command to fw.
15051 * @wmi_handle: wmi handle
15052 * @wmi_fwtest: fw test command
15053 *
15054 * This function sends fw test command to fw.
15055 *
15056 * Return: CDF STATUS
15057 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015058static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015059QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15060 struct set_fwtest_params *wmi_fwtest)
15061{
15062 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15063 wmi_buf_t wmi_buf;
15064 uint16_t len;
15065
15066 len = sizeof(*cmd);
15067
15068 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15069 if (!wmi_buf) {
15070 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15071 return QDF_STATUS_E_NOMEM;
15072 }
15073
15074 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15075 WMITLV_SET_HDR(&cmd->tlv_header,
15076 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15077 WMITLV_GET_STRUCT_TLVLEN(
15078 wmi_fwtest_set_param_cmd_fixed_param));
15079 cmd->param_id = wmi_fwtest->arg;
15080 cmd->param_value = wmi_fwtest->value;
15081
15082 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15083 WMI_FWTEST_CMDID)) {
15084 WMI_LOGP("%s: failed to send fw test command", __func__);
15085 qdf_nbuf_free(wmi_buf);
15086 return QDF_STATUS_E_FAILURE;
15087 }
15088
15089 return QDF_STATUS_SUCCESS;
15090}
15091
15092/**
Govind Singha4836fd2016-03-07 16:45:38 +053015093 * send_unit_test_cmd_tlv() - send unit test command to fw.
15094 * @wmi_handle: wmi handle
15095 * @wmi_utest: unit test command
15096 *
15097 * This function send unit test command to fw.
15098 *
15099 * Return: CDF STATUS
15100 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015101static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015102 struct wmi_unit_test_cmd *wmi_utest)
15103{
15104 wmi_unit_test_cmd_fixed_param *cmd;
15105 wmi_buf_t wmi_buf;
15106 uint8_t *buf_ptr;
15107 int i;
15108 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015109 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015110
15111 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015112 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015113 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15114
15115 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15116 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015117 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15118 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015119 }
15120
15121 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15122 buf_ptr = (uint8_t *) cmd;
15123 WMITLV_SET_HDR(&cmd->tlv_header,
15124 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15125 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15126 cmd->vdev_id = wmi_utest->vdev_id;
15127 cmd->module_id = wmi_utest->module_id;
15128 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015129 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015130 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15132 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015133 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015134 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15135 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15136 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015137 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015138 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015139 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015140 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015141 }
15142 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15143 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015144 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015145 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015146 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015147 }
15148
Govind Singhb53420c2016-03-09 14:32:57 +053015149 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015150}
15151
15152/**
15153 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15154 * @wmi_handle: wma handle
15155 * @roaminvoke: roam invoke command
15156 *
15157 * Send roam invoke command to fw for fastreassoc.
15158 *
15159 * Return: CDF STATUS
15160 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015161static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015162 struct wmi_roam_invoke_cmd *roaminvoke,
15163 uint32_t ch_hz)
15164{
15165 wmi_roam_invoke_cmd_fixed_param *cmd;
15166 wmi_buf_t wmi_buf;
15167 u_int8_t *buf_ptr;
15168 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015169 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015170 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015171 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015172
15173 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015174 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015175 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15176 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015177 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15178 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15179 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015180 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15181 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015182 }
15183
15184 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15185 buf_ptr = (u_int8_t *) cmd;
15186 WMITLV_SET_HDR(&cmd->tlv_header,
15187 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15188 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15189 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015190 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015191 if (roaminvoke->is_same_bssid)
15192 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15193 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015194
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015195 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015196 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015197 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15198 cmd->num_buf = 1;
15199 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015200 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015201 cmd->num_buf = 0;
15202 }
Naveen Rawat77797922017-01-20 17:00:07 -080015203
Govind Singha4836fd2016-03-07 16:45:38 +053015204 cmd->roam_ap_sel_mode = 0;
15205 cmd->roam_delay = 0;
15206 cmd->num_chan = 1;
15207 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015208
Govind Singha4836fd2016-03-07 16:45:38 +053015209 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15210 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15211 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015212 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015213 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015214 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015215 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15216 (sizeof(wmi_mac_addr)));
15217 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15218 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015219
15220 /* move to next tlv i.e. bcn_prb_buf_list */
15221 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15222
15223 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15224 sizeof(wmi_tlv_buf_len_param));
15225
15226 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15227 buf_len_tlv->buf_len = roaminvoke->frame_len;
15228
15229 /* move to next tlv i.e. bcn_prb_frm */
15230 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15231 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15232 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15233
15234 /* copy frame after the header */
15235 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15236 roaminvoke->frame_buf,
15237 roaminvoke->frame_len);
15238
15239 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015240 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015241 buf_ptr + WMI_TLV_HDR_SIZE,
15242 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015243 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15244 cmd->flags, cmd->roam_scan_mode,
15245 cmd->roam_ap_sel_mode, cmd->roam_delay,
15246 cmd->num_chan, cmd->num_bssid);
15247 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015248
Govind Singha4836fd2016-03-07 16:45:38 +053015249 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15250 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015251 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015252 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015253 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015254 }
15255
Govind Singhb53420c2016-03-09 14:32:57 +053015256 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015257}
15258
15259/**
15260 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15261 * @wmi_handle: wmi handle
15262 * @command: command
15263 * @vdev_id: vdev id
15264 *
15265 * This function set roam offload command to fw.
15266 *
15267 * Return: CDF status
15268 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015269static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015270 uint32_t command, uint32_t vdev_id)
15271{
Govind Singh67922e82016-04-01 16:48:57 +053015272 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015273 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15274 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015275 int len;
15276 uint8_t *buf_ptr;
15277
15278 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15279 buf = wmi_buf_alloc(wmi_handle, len);
15280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015281 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15282 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015283 }
15284
15285 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15286
15287 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15288 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15289 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15290 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15291 cmd_fp->vdev_id = vdev_id;
15292 cmd_fp->command_arg = command;
15293
15294 status = wmi_unified_cmd_send(wmi_handle, buf,
15295 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015296 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015297 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015298 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015299 goto error;
15300 }
15301
Govind Singhb53420c2016-03-09 14:32:57 +053015302 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15303 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015304
15305error:
15306 wmi_buf_free(buf);
15307
Govind Singh67922e82016-04-01 16:48:57 +053015308 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015309}
15310
15311/**
15312 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15313 * @wmi_handle: wmi handle
15314 * @ap_profile_p: ap profile
15315 * @vdev_id: vdev id
15316 *
15317 * Send WMI_ROAM_AP_PROFILE to firmware
15318 *
15319 * Return: CDF status
15320 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015321static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015322 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015323{
Govind Singha4836fd2016-03-07 16:45:38 +053015324 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015325 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015326 int len;
15327 uint8_t *buf_ptr;
15328 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015329 wmi_roam_cnd_scoring_param *score_param;
15330 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015331
15332 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015333 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015334 buf = wmi_buf_alloc(wmi_handle, len);
15335 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015336 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15337 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015338 }
15339
15340 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15341 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15342 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15343 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15344 WMITLV_GET_STRUCT_TLVLEN
15345 (wmi_roam_ap_profile_fixed_param));
15346 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015347 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015348 roam_ap_profile_fp->id = 0;
15349 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15350
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015351 profile = (wmi_ap_profile *)buf_ptr;
15352 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015353 WMITLV_TAG_STRUC_wmi_ap_profile,
15354 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015355 profile->flags = ap_profile->profile.flags;
15356 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15357 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15358 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15359 profile->ssid.ssid_len);
15360 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15361 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15362 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15363 profile->rsn_mcastmgmtcipherset =
15364 ap_profile->profile.rsn_mcastmgmtcipherset;
15365 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15366
15367 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",
15368 profile->flags, profile->rssi_threshold,
15369 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15370 profile->rsn_authmode, profile->rsn_ucastcipherset,
15371 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15372 profile->rssi_abs_thresh);
15373
15374 buf_ptr += sizeof(wmi_ap_profile);
15375
15376 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15377 WMITLV_SET_HDR(&score_param->tlv_header,
15378 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15379 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15380 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15381 score_param->rssi_weightage_pcnt =
15382 ap_profile->param.rssi_weightage;
15383 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15384 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15385 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15386 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15387 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15388 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15389 score_param->esp_qbss_weightage_pcnt =
15390 ap_profile->param.esp_qbss_weightage;
15391 score_param->beamforming_weightage_pcnt =
15392 ap_profile->param.beamforming_weightage;
15393 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15394 score_param->oce_wan_weightage_pcnt =
15395 ap_profile->param.oce_wan_weightage;
15396
15397 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",
15398 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15399 score_param->ht_weightage_pcnt,
15400 score_param->vht_weightage_pcnt,
15401 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15402 score_param->band_weightage_pcnt,
15403 score_param->nss_weightage_pcnt,
15404 score_param->esp_qbss_weightage_pcnt,
15405 score_param->beamforming_weightage_pcnt,
15406 score_param->pcl_weightage_pcnt,
15407 score_param->oce_wan_weightage_pcnt);
15408
15409 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15410 score_param->band_scoring.score_pcnt =
15411 ap_profile->param.band_index_score;
15412 score_param->nss_scoring.score_pcnt =
15413 ap_profile->param.nss_index_score;
15414
15415 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15416 score_param->bw_scoring.score_pcnt,
15417 score_param->band_scoring.score_pcnt,
15418 score_param->nss_scoring.score_pcnt);
15419
15420 score_param->rssi_scoring.best_rssi_threshold =
15421 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15422 score_param->rssi_scoring.good_rssi_threshold =
15423 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15424 score_param->rssi_scoring.bad_rssi_threshold =
15425 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15426 score_param->rssi_scoring.good_rssi_pcnt =
15427 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15428 score_param->rssi_scoring.bad_rssi_pcnt =
15429 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15430 score_param->rssi_scoring.good_bucket_size =
15431 ap_profile->param.rssi_scoring.good_bucket_size;
15432 score_param->rssi_scoring.bad_bucket_size =
15433 ap_profile->param.rssi_scoring.bad_bucket_size;
15434 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15435 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15436
15437 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15438 score_param->rssi_scoring.best_rssi_threshold,
15439 score_param->rssi_scoring.good_rssi_threshold,
15440 score_param->rssi_scoring.bad_rssi_threshold,
15441 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15442 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15443 score_param->rssi_scoring.good_rssi_pcnt,
15444 score_param->rssi_scoring.bad_rssi_pcnt,
15445 score_param->rssi_scoring.good_bucket_size,
15446 score_param->rssi_scoring.bad_bucket_size);
15447
15448 score_param->esp_qbss_scoring.num_slot =
15449 ap_profile->param.esp_qbss_scoring.num_slot;
15450 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15451 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15452 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15453 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15454 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15455 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15456 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15457 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15458
15459 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15460 score_param->esp_qbss_scoring.num_slot,
15461 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15462 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15463 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15464 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15465
15466 score_param->oce_wan_scoring.num_slot =
15467 ap_profile->param.oce_wan_scoring.num_slot;
15468 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15469 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15470 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15471 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15472 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15473 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15474 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15475 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15476
15477 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15478 score_param->oce_wan_scoring.num_slot,
15479 score_param->oce_wan_scoring.score_pcnt3_to_0,
15480 score_param->oce_wan_scoring.score_pcnt7_to_4,
15481 score_param->oce_wan_scoring.score_pcnt11_to_8,
15482 score_param->oce_wan_scoring.score_pcnt15_to_12);
15483
Govind Singha4836fd2016-03-07 16:45:38 +053015484 status = wmi_unified_cmd_send(wmi_handle, buf,
15485 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015486 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015487 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015488 status);
Govind Singh67922e82016-04-01 16:48:57 +053015489 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015490 }
15491
Govind Singhb53420c2016-03-09 14:32:57 +053015492 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015493
Govind Singh67922e82016-04-01 16:48:57 +053015494 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015495}
15496
15497/**
15498 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15499 * @wmi_handle: wmi handle
15500 * @scan_period: scan period
15501 * @scan_age: scan age
15502 * @vdev_id: vdev id
15503 *
15504 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15505 *
15506 * Return: CDF status
15507 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015508static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015509 uint32_t scan_period,
15510 uint32_t scan_age,
15511 uint32_t vdev_id)
15512{
Govind Singh67922e82016-04-01 16:48:57 +053015513 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015514 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015515 int len;
15516 uint8_t *buf_ptr;
15517 wmi_roam_scan_period_fixed_param *scan_period_fp;
15518
15519 /* Send scan period values */
15520 len = sizeof(wmi_roam_scan_period_fixed_param);
15521 buf = wmi_buf_alloc(wmi_handle, len);
15522 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015523 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15524 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015525 }
15526
15527 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15528 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15529 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15530 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15531 WMITLV_GET_STRUCT_TLVLEN
15532 (wmi_roam_scan_period_fixed_param));
15533 /* fill in scan period values */
15534 scan_period_fp->vdev_id = vdev_id;
15535 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15536 scan_period_fp->roam_scan_age = scan_age;
15537
15538 status = wmi_unified_cmd_send(wmi_handle, buf,
15539 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015540 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015541 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015542 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015543 goto error;
15544 }
15545
Govind Singhb53420c2016-03-09 14:32:57 +053015546 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015547 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015548 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015549error:
15550 wmi_buf_free(buf);
15551
Govind Singh67922e82016-04-01 16:48:57 +053015552 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015553}
15554
15555/**
15556 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15557 * @wmi_handle: wmi handle
15558 * @chan_count: channel count
15559 * @chan_list: channel list
15560 * @list_type: list type
15561 * @vdev_id: vdev id
15562 *
15563 * Set roam offload channel list.
15564 *
15565 * Return: CDF status
15566 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015567static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015568 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015569 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015570 uint8_t list_type, uint32_t vdev_id)
15571{
Govind Singha4836fd2016-03-07 16:45:38 +053015572 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015573 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015574 int len, list_tlv_len;
15575 int i;
15576 uint8_t *buf_ptr;
15577 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015578 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015579
15580 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015581 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015582 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015583 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015584 }
15585 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015586 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015587 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15588 buf = wmi_buf_alloc(wmi_handle, len);
15589 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015590 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15591 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015592 }
15593
15594 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15595 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15596 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15597 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15598 WMITLV_GET_STRUCT_TLVLEN
15599 (wmi_roam_chan_list_fixed_param));
15600 chan_list_fp->vdev_id = vdev_id;
15601 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015602 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015603 /* external app is controlling channel list */
15604 chan_list_fp->chan_list_type =
15605 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15606 } else {
15607 /* umac supplied occupied channel list in LFR */
15608 chan_list_fp->chan_list_type =
15609 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15610 }
15611
15612 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15613 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15614 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015615 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015616 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015617 for (i = 0; ((i < chan_list_fp->num_chan) &&
15618 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15619 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015620 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015621 }
15622
15623 status = wmi_unified_cmd_send(wmi_handle, buf,
15624 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015625 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015626 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015627 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015628 goto error;
15629 }
15630
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015631 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015632 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015633error:
15634 wmi_buf_free(buf);
15635
Govind Singh67922e82016-04-01 16:48:57 +053015636 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015637}
15638
15639/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015640 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15641 * @wmi_handle: wmi handle
15642 * @req_buf: per roam config buffer
15643 *
15644 * Return: QDF status
15645 */
15646static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15647 struct wmi_per_roam_config_req *req_buf)
15648{
15649 wmi_buf_t buf = NULL;
15650 QDF_STATUS status;
15651 int len;
15652 uint8_t *buf_ptr;
15653 wmi_roam_per_config_fixed_param *wmi_per_config;
15654
15655 len = sizeof(wmi_roam_per_config_fixed_param);
15656 buf = wmi_buf_alloc(wmi_handle, len);
15657 if (!buf) {
15658 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15659 return QDF_STATUS_E_NOMEM;
15660 }
15661
15662 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15663 wmi_per_config =
15664 (wmi_roam_per_config_fixed_param *) buf_ptr;
15665 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15666 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15667 WMITLV_GET_STRUCT_TLVLEN
15668 (wmi_roam_per_config_fixed_param));
15669
15670 /* fill in per roam config values */
15671 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015672
15673 wmi_per_config->enable = req_buf->per_config.enable;
15674 wmi_per_config->high_rate_thresh =
15675 (req_buf->per_config.tx_high_rate_thresh << 16) |
15676 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15677 wmi_per_config->low_rate_thresh =
15678 (req_buf->per_config.tx_low_rate_thresh << 16) |
15679 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15680 wmi_per_config->pkt_err_rate_thresh_pct =
15681 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15682 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15683 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015684 wmi_per_config->pkt_err_rate_mon_time =
15685 (req_buf->per_config.tx_per_mon_time << 16) |
15686 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015687 wmi_per_config->min_candidate_rssi =
15688 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015689
15690 /* Send per roam config parameters */
15691 status = wmi_unified_cmd_send(wmi_handle, buf,
15692 len, WMI_ROAM_PER_CONFIG_CMDID);
15693 if (QDF_IS_STATUS_ERROR(status)) {
15694 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15695 status);
15696 wmi_buf_free(buf);
15697 return status;
15698 }
15699
15700 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15701 req_buf->per_config.enable, req_buf->vdev_id);
15702 return QDF_STATUS_SUCCESS;
15703}
15704
15705/**
Govind Singha4836fd2016-03-07 16:45:38 +053015706 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15707 * @wmi_handle: wmi handle
15708 * @rssi_change_thresh: RSSI Change threshold
15709 * @bcn_rssi_weight: beacon RSSI weight
15710 * @vdev_id: vdev id
15711 *
15712 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15713 *
15714 * Return: CDF status
15715 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015716static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015717 uint32_t vdev_id,
15718 int32_t rssi_change_thresh,
15719 uint32_t bcn_rssi_weight,
15720 uint32_t hirssi_delay_btw_scans)
15721{
Govind Singha4836fd2016-03-07 16:45:38 +053015722 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015723 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015724 int len;
15725 uint8_t *buf_ptr;
15726 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15727
15728 /* Send rssi change parameters */
15729 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15730 buf = wmi_buf_alloc(wmi_handle, len);
15731 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015732 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15733 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015734 }
15735
15736 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15737 rssi_change_fp =
15738 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15739 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15740 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15741 WMITLV_GET_STRUCT_TLVLEN
15742 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15743 /* fill in rssi change threshold (hysteresis) values */
15744 rssi_change_fp->vdev_id = vdev_id;
15745 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15746 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15747 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15748
15749 status = wmi_unified_cmd_send(wmi_handle, buf,
15750 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015751 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015752 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015753 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015754 goto error;
15755 }
15756
Govind Singhb53420c2016-03-09 14:32:57 +053015757 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015758 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015759 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15760 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015761error:
15762 wmi_buf_free(buf);
15763
Govind Singh67922e82016-04-01 16:48:57 +053015764 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015765}
15766
Govind Singhbca3b1b2016-05-02 17:59:24 +053015767/**
15768 * send_power_dbg_cmd_tlv() - send power debug commands
15769 * @wmi_handle: wmi handle
15770 * @param: wmi power debug parameter
15771 *
15772 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15773 *
15774 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15775 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015776static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15777 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015778{
15779 wmi_buf_t buf = NULL;
15780 QDF_STATUS status;
15781 int len, args_tlv_len;
15782 uint8_t *buf_ptr;
15783 uint8_t i;
15784 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15785 uint32_t *cmd_args;
15786
15787 /* Prepare and send power debug cmd parameters */
15788 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15789 len = sizeof(*cmd) + args_tlv_len;
15790 buf = wmi_buf_alloc(wmi_handle, len);
15791 if (!buf) {
15792 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15793 return QDF_STATUS_E_NOMEM;
15794 }
15795
15796 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15797 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15798 WMITLV_SET_HDR(&cmd->tlv_header,
15799 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15800 WMITLV_GET_STRUCT_TLVLEN
15801 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15802
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015803 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15804 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015805 cmd->module_id = param->module_id;
15806 cmd->num_args = param->num_args;
15807 buf_ptr += sizeof(*cmd);
15808 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15809 (param->num_args * sizeof(uint32_t)));
15810 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15811 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015812 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015813 cmd_args[i] = param->args[i];
15814 WMI_LOGI("%d,", param->args[i]);
15815 }
15816
15817 status = wmi_unified_cmd_send(wmi_handle, buf,
15818 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15819 if (QDF_IS_STATUS_ERROR(status)) {
15820 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15821 status);
15822 goto error;
15823 }
15824
15825 return QDF_STATUS_SUCCESS;
15826error:
15827 wmi_buf_free(buf);
15828
15829 return status;
15830}
15831
Govind Singhe7f2f342016-05-23 12:12:52 +053015832/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015833 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15834 * @wmi_handle: wmi handle
15835 * @param: wmi multiple vdev restart req param
15836 *
15837 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15838 *
15839 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15840 */
15841static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15842 wmi_unified_t wmi_handle,
15843 struct multiple_vdev_restart_params *param)
15844{
15845 wmi_buf_t buf;
15846 QDF_STATUS qdf_status;
15847 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15848 int i;
15849 uint8_t *buf_ptr;
15850 uint32_t *vdev_ids;
15851 wmi_channel *chan_info;
15852 struct channel_param *tchan_info;
15853 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15854
15855 len += sizeof(wmi_channel);
15856 if (param->num_vdevs)
15857 len += sizeof(uint32_t) * param->num_vdevs;
15858
15859 buf = wmi_buf_alloc(wmi_handle, len);
15860 if (!buf) {
15861 WMI_LOGE("Failed to allocate memory\n");
15862 qdf_status = QDF_STATUS_E_NOMEM;
15863 goto end;
15864 }
15865
15866 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15867 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15868 buf_ptr;
15869
15870 WMITLV_SET_HDR(&cmd->tlv_header,
15871 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15872 WMITLV_GET_STRUCT_TLVLEN
15873 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015874 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15875 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015876 cmd->requestor_id = param->requestor_id;
15877 cmd->disable_hw_ack = param->disable_hw_ack;
15878 cmd->cac_duration_ms = param->cac_duration_ms;
15879 cmd->num_vdevs = param->num_vdevs;
15880
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015881 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15882 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15883 " cmd->num_vdevs: %d ",
15884 __func__, cmd->pdev_id, cmd->requestor_id,
15885 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015886 buf_ptr += sizeof(*cmd);
15887
15888 WMITLV_SET_HDR(buf_ptr,
15889 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015890 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015891 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15892 for (i = 0; i < param->num_vdevs; i++) {
15893 vdev_ids[i] = param->vdev_ids[i];
15894 }
15895
Vivekc5823092018-03-22 23:27:21 +053015896 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015897
15898 WMITLV_SET_HDR(buf_ptr,
15899 WMITLV_TAG_STRUC_wmi_channel,
15900 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015901 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015902 tchan_info = &(param->ch_param);
15903 chan_info->mhz = tchan_info->mhz;
15904 chan_info->band_center_freq1 = tchan_info->cfreq1;
15905 chan_info->band_center_freq2 = tchan_info->cfreq2;
15906 if (tchan_info->is_chan_passive)
15907 WMI_SET_CHANNEL_FLAG(chan_info,
15908 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015909 if (tchan_info->dfs_set)
15910 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15911
Sathish Kumar45e991b2017-02-27 10:35:40 +053015912 if (tchan_info->allow_vht)
15913 WMI_SET_CHANNEL_FLAG(chan_info,
15914 WMI_CHAN_FLAG_ALLOW_VHT);
15915 else if (tchan_info->allow_ht)
15916 WMI_SET_CHANNEL_FLAG(chan_info,
15917 WMI_CHAN_FLAG_ALLOW_HT);
15918 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15919 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15920 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15921 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15922 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15923 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015924 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015925
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015926 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15927 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15928 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15929 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15930 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15931 "tchan_info->reg_class_id: %d ,"
15932 "tchan_info->maxregpower : %d ", __func__,
15933 tchan_info->is_chan_passive, tchan_info->dfs_set,
15934 tchan_info->allow_vht, tchan_info->allow_ht,
15935 tchan_info->antennamax, tchan_info->phy_mode,
15936 tchan_info->minpower, tchan_info->maxpower,
15937 tchan_info->maxregpower, tchan_info->reg_class_id,
15938 tchan_info->maxregpower);
15939
Sathish Kumar45e991b2017-02-27 10:35:40 +053015940 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15941 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15942
15943 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15944 WMI_LOGE("%s: Failed to send\n", __func__);
15945 wmi_buf_free(buf);
15946 }
15947
15948end:
15949 return qdf_status;
15950}
15951
15952/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015953 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15954 * @wmi_handle: wmi handle
15955 * @pdev_id: pdev id
15956 *
15957 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15958 *
15959 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15960 */
15961static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15962 uint32_t pdev_id)
15963{
15964 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15965 wmi_buf_t buf;
15966 uint16_t len;
15967 QDF_STATUS ret;
15968
15969 len = sizeof(*cmd);
15970 buf = wmi_buf_alloc(wmi_handle, len);
15971
15972 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15973
15974 if (!buf) {
15975 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15976 return QDF_STATUS_E_NOMEM;
15977 }
15978
15979 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15980 wmi_buf_data(buf);
15981
15982 WMITLV_SET_HDR(&cmd->tlv_header,
15983 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15984 WMITLV_GET_STRUCT_TLVLEN(
15985 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15986
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015987 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015988 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15989 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15990 if (QDF_IS_STATUS_ERROR(ret)) {
15991 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15992 __func__, ret, pdev_id);
15993 wmi_buf_free(buf);
15994 return QDF_STATUS_E_FAILURE;
15995 }
15996
15997 return QDF_STATUS_SUCCESS;
15998}
15999
16000/**
16001 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16002 * @wmi_handle: wmi handle
16003 * @pdev_id: pdev id
16004 *
16005 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16006 *
16007 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16008 */
16009static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16010 uint32_t pdev_id)
16011{
16012 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16013 wmi_buf_t buf;
16014 uint16_t len;
16015 QDF_STATUS ret;
16016
16017 len = sizeof(*cmd);
16018 buf = wmi_buf_alloc(wmi_handle, len);
16019
16020 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16021
16022 if (!buf) {
16023 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16024 return QDF_STATUS_E_NOMEM;
16025 }
16026
16027 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16028 wmi_buf_data(buf);
16029
16030 WMITLV_SET_HDR(&cmd->tlv_header,
16031 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16032 WMITLV_GET_STRUCT_TLVLEN(
16033 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16034
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016035 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16037 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16038 if (QDF_IS_STATUS_ERROR(ret)) {
16039 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16040 __func__, ret, pdev_id);
16041 wmi_buf_free(buf);
16042 return QDF_STATUS_E_FAILURE;
16043 }
16044
16045 return QDF_STATUS_SUCCESS;
16046}
16047
16048/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016049 * init_cmd_send_tlv() - send initialization cmd to fw
16050 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016051 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016052 *
16053 * Return: QDF_STATUS_SUCCESS for success or error code
16054 */
16055static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016056 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016057{
16058 wmi_buf_t buf;
16059 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016060 uint8_t *buf_ptr;
16061 wmi_resource_config *resource_cfg;
16062 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016063 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016064 uint16_t idx;
16065 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016066 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016067
Kiran Venkatappa26117052016-12-23 19:58:54 +053016068 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16069 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016070 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016071
16072 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16073 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16074 WMI_TLV_HDR_SIZE +
16075 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16076
16077 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016078 if (!buf) {
16079 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16080 return QDF_STATUS_E_FAILURE;
16081 }
16082
16083 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16084 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16085 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16086
16087 host_mem_chunks = (wlan_host_memory_chunk *)
16088 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16089 + WMI_TLV_HDR_SIZE);
16090
16091 WMITLV_SET_HDR(&cmd->tlv_header,
16092 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16093 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16094
Kiran Venkatappa26117052016-12-23 19:58:54 +053016095 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016096 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16097 WMITLV_TAG_STRUC_wmi_resource_config,
16098 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16099
Kiran Venkatappa26117052016-12-23 19:58:54 +053016100 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016101 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16102 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16103 WMITLV_GET_STRUCT_TLVLEN
16104 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016105 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16106 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16107 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016108 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16109 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016110 idx, host_mem_chunks[idx].size,
16111 host_mem_chunks[idx].ptr);
16112 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016113 cmd->num_host_mem_chunks = param->num_mem_chunks;
16114 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16115
Govind Singhe7f2f342016-05-23 12:12:52 +053016116 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16117 WMITLV_TAG_ARRAY_STRUC,
16118 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016119 param->num_mem_chunks));
16120
16121 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016122 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016123
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016124 /* Fill fw_abi_vers */
16125 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016126
Abhishek Singh716c46c2016-05-04 16:24:07 +053016127 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16128 if (QDF_IS_STATUS_ERROR(ret)) {
16129 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16130 ret);
16131 wmi_buf_free(buf);
16132 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016133
Abhishek Singh716c46c2016-05-04 16:24:07 +053016134 return ret;
16135
Govind Singhe7f2f342016-05-23 12:12:52 +053016136}
16137
16138/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016139 * send_addba_send_cmd_tlv() - send addba send command to fw
16140 * @wmi_handle: wmi handle
16141 * @param: pointer to delba send params
16142 * @macaddr: peer mac address
16143 *
16144 * Send WMI_ADDBA_SEND_CMDID command to firmware
16145 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16146 */
16147static QDF_STATUS
16148send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16149 uint8_t macaddr[IEEE80211_ADDR_LEN],
16150 struct addba_send_params *param)
16151{
16152 wmi_addba_send_cmd_fixed_param *cmd;
16153 wmi_buf_t buf;
16154 uint16_t len;
16155 QDF_STATUS ret;
16156
16157 len = sizeof(*cmd);
16158
16159 buf = wmi_buf_alloc(wmi_handle, len);
16160 if (!buf) {
16161 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16162 return QDF_STATUS_E_NOMEM;
16163 }
16164
16165 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16166
16167 WMITLV_SET_HDR(&cmd->tlv_header,
16168 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16169 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16170
16171 cmd->vdev_id = param->vdev_id;
16172 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16173 cmd->tid = param->tidno;
16174 cmd->buffersize = param->buffersize;
16175
16176 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16177 if (QDF_IS_STATUS_ERROR(ret)) {
16178 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16179 wmi_buf_free(buf);
16180 return QDF_STATUS_E_FAILURE;
16181 }
16182
16183 return QDF_STATUS_SUCCESS;
16184}
16185
16186/**
16187 * send_delba_send_cmd_tlv() - send delba send command to fw
16188 * @wmi_handle: wmi handle
16189 * @param: pointer to delba send params
16190 * @macaddr: peer mac address
16191 *
16192 * Send WMI_DELBA_SEND_CMDID command to firmware
16193 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16194 */
16195static QDF_STATUS
16196send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16197 uint8_t macaddr[IEEE80211_ADDR_LEN],
16198 struct delba_send_params *param)
16199{
16200 wmi_delba_send_cmd_fixed_param *cmd;
16201 wmi_buf_t buf;
16202 uint16_t len;
16203 QDF_STATUS ret;
16204
16205 len = sizeof(*cmd);
16206
16207 buf = wmi_buf_alloc(wmi_handle, len);
16208 if (!buf) {
16209 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16210 return QDF_STATUS_E_NOMEM;
16211 }
16212
16213 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16214
16215 WMITLV_SET_HDR(&cmd->tlv_header,
16216 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16217 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16218
16219 cmd->vdev_id = param->vdev_id;
16220 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16221 cmd->tid = param->tidno;
16222 cmd->initiator = param->initiator;
16223 cmd->reasoncode = param->reasoncode;
16224
16225 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16226 if (QDF_IS_STATUS_ERROR(ret)) {
16227 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16228 wmi_buf_free(buf);
16229 return QDF_STATUS_E_FAILURE;
16230 }
16231
16232 return QDF_STATUS_SUCCESS;
16233}
16234
16235/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016236 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16237 * to fw
16238 * @wmi_handle: wmi handle
16239 * @param: pointer to addba clearresp params
16240 * @macaddr: peer mac address
16241 * Return: 0 for success or error code
16242 */
16243static QDF_STATUS
16244send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16245 uint8_t macaddr[IEEE80211_ADDR_LEN],
16246 struct addba_clearresponse_params *param)
16247{
16248 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16249 wmi_buf_t buf;
16250 uint16_t len;
16251 QDF_STATUS ret;
16252
16253 len = sizeof(*cmd);
16254
16255 buf = wmi_buf_alloc(wmi_handle, len);
16256 if (!buf) {
16257 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16258 return QDF_STATUS_E_FAILURE;
16259 }
16260 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16261
16262 WMITLV_SET_HDR(&cmd->tlv_header,
16263 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16264 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16265
16266 cmd->vdev_id = param->vdev_id;
16267 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16268
16269 ret = wmi_unified_cmd_send(wmi_handle,
16270 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16271 if (QDF_IS_STATUS_ERROR(ret)) {
16272 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16273 wmi_buf_free(buf);
16274 return QDF_STATUS_E_FAILURE;
16275 }
16276
16277 return QDF_STATUS_SUCCESS;
16278}
16279
16280/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016281 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16282 * @wmi_handle: wmi handle
16283 * @bcn_ctrl_param: pointer to bcn_offload_control param
16284 *
16285 * Return: QDF_STATUS_SUCCESS for success or error code
16286 */
16287static
16288QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16289 struct bcn_offload_control *bcn_ctrl_param)
16290{
16291 wmi_buf_t buf;
16292 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16293 QDF_STATUS ret;
16294 uint32_t len;
16295
16296 len = sizeof(*cmd);
16297
16298 buf = wmi_buf_alloc(wmi_handle, len);
16299 if (!buf) {
16300 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16301 return QDF_STATUS_E_FAILURE;
16302 }
16303
16304 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16305 WMITLV_SET_HDR(&cmd->tlv_header,
16306 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16307 WMITLV_GET_STRUCT_TLVLEN
16308 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16309 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016310 switch (bcn_ctrl_param->bcn_ctrl_op) {
16311 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016312 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016313 break;
16314 case BCN_OFFLD_CTRL_TX_ENABLE:
16315 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16316 break;
16317 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16318 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16319 break;
16320 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16321 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16322 break;
16323 default:
16324 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16325 bcn_ctrl_param->bcn_ctrl_op);
16326 wmi_buf_free(buf);
16327 return QDF_STATUS_E_FAILURE;
16328 break;
16329 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016330 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16331 WMI_BCN_OFFLOAD_CTRL_CMDID);
16332
16333 if (QDF_IS_STATUS_ERROR(ret)) {
16334 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16335 ret);
16336 wmi_buf_free(buf);
16337 }
16338
16339 return ret;
16340}
16341
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016342#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16343static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16344 struct nan_datapath_initiator_req *ndp_req)
16345{
16346 uint16_t len;
16347 wmi_buf_t buf;
16348 uint8_t *tlv_ptr;
16349 QDF_STATUS status;
16350 wmi_channel *ch_tlv;
16351 wmi_ndp_initiator_req_fixed_param *cmd;
16352 uint32_t passphrase_len, service_name_len;
16353 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016354 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016355
16356 /*
16357 * WMI command expects 4 byte alligned len:
16358 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16359 */
16360 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16361 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16362 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16363 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16364 service_name_len =
16365 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16366 /* allocated memory for fixed params as well as variable size data */
16367 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16368 + ndp_cfg_len + ndp_app_info_len + pmk_len
16369 + passphrase_len + service_name_len;
16370
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016371 if (ndp_req->is_ipv6_addr_present)
16372 len += sizeof(*tcp_ip_param);
16373
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016374 buf = wmi_buf_alloc(wmi_handle, len);
16375 if (!buf) {
16376 WMI_LOGE("wmi_buf_alloc failed");
16377 return QDF_STATUS_E_NOMEM;
16378 }
16379
16380 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16381 WMITLV_SET_HDR(&cmd->tlv_header,
16382 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16383 WMITLV_GET_STRUCT_TLVLEN(
16384 wmi_ndp_initiator_req_fixed_param));
16385 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16386 cmd->transaction_id = ndp_req->transaction_id;
16387 cmd->service_instance_id = ndp_req->service_instance_id;
16388 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16389 &cmd->peer_discovery_mac_addr);
16390
16391 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16392 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16393 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16394 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16395 cmd->nan_csid = ndp_req->ncs_sk_type;
16396 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16397 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16398
16399 ch_tlv = (wmi_channel *)&cmd[1];
16400 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16401 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16402 ch_tlv->mhz = ndp_req->channel;
16403 tlv_ptr = (uint8_t *)&ch_tlv[1];
16404
16405 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16406 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16407 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16408 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16409
16410 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16411 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16412 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16413 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16414
16415 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16416 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16417 cmd->nan_pmk_len);
16418 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16419
16420 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16421 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16422 cmd->nan_passphrase_len);
16423 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16424
16425 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16426 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16427 ndp_req->service_name.service_name,
16428 cmd->nan_servicename_len);
16429 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16430
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016431 if (ndp_req->is_ipv6_addr_present) {
16432 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16433 WMITLV_SET_HDR(tcp_ip_param,
16434 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16435 WMITLV_GET_STRUCT_TLVLEN(
16436 wmi_ndp_transport_ip_param));
16437 tcp_ip_param->ipv6_addr_present = true;
16438 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16439 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16440 }
16441 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16442 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16443
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016444 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16445 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16446 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16447 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16448 cmd->peer_discovery_mac_addr.mac_addr31to0,
16449 cmd->peer_discovery_mac_addr.mac_addr47to32);
16450
16451 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016452 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016453 ndp_req->ndp_config.ndp_cfg,
16454 ndp_req->ndp_config.ndp_cfg_len);
16455
16456 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016457 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016458 ndp_req->ndp_info.ndp_app_info,
16459 ndp_req->ndp_info.ndp_app_info_len);
16460
16461 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016462 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016463 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16464
16465 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016466 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016467 ndp_req->passphrase.passphrase,
16468 cmd->nan_passphrase_len);
16469
16470 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016471 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016472 ndp_req->service_name.service_name,
16473 cmd->nan_servicename_len);
16474
16475 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16476 WMI_NDP_INITIATOR_REQ_CMDID);
16477
16478 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16479 WMI_NDP_INITIATOR_REQ_CMDID);
16480 if (QDF_IS_STATUS_ERROR(status)) {
16481 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16482 wmi_buf_free(buf);
16483 }
16484
16485 return status;
16486}
16487
16488static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16489 struct nan_datapath_responder_req *req)
16490{
16491 uint16_t len;
16492 wmi_buf_t buf;
16493 uint8_t *tlv_ptr;
16494 QDF_STATUS status;
16495 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016496 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016497 uint32_t passphrase_len, service_name_len;
16498 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16499
16500 vdev_id = wlan_vdev_get_id(req->vdev);
16501 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16502 vdev_id, req->transaction_id,
16503 req->ndp_rsp,
16504 req->ndp_instance_id,
16505 req->ndp_info.ndp_app_info_len);
16506
16507 /*
16508 * WMI command expects 4 byte alligned len:
16509 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16510 */
16511 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16512 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16513 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16514 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16515 service_name_len =
16516 qdf_roundup(req->service_name.service_name_len, 4);
16517
16518 /* allocated memory for fixed params as well as variable size data */
16519 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16520 + pmk_len + passphrase_len + service_name_len;
16521
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016522 if (req->is_ipv6_addr_present || req->is_port_present ||
16523 req->is_protocol_present)
16524 len += sizeof(*tcp_ip_param);
16525
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016526 buf = wmi_buf_alloc(wmi_handle, len);
16527 if (!buf) {
16528 WMI_LOGE("wmi_buf_alloc failed");
16529 return QDF_STATUS_E_NOMEM;
16530 }
16531 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16532 WMITLV_SET_HDR(&cmd->tlv_header,
16533 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16534 WMITLV_GET_STRUCT_TLVLEN(
16535 wmi_ndp_responder_req_fixed_param));
16536 cmd->vdev_id = vdev_id;
16537 cmd->transaction_id = req->transaction_id;
16538 cmd->ndp_instance_id = req->ndp_instance_id;
16539 cmd->rsp_code = req->ndp_rsp;
16540 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16541 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16542 cmd->nan_pmk_len = req->pmk.pmk_len;
16543 cmd->nan_csid = req->ncs_sk_type;
16544 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16545 cmd->nan_servicename_len = req->service_name.service_name_len;
16546
16547 tlv_ptr = (uint8_t *)&cmd[1];
16548 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16549 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16550 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16551
16552 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16553 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16554 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16555 req->ndp_info.ndp_app_info,
16556 req->ndp_info.ndp_app_info_len);
16557
16558 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16559 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16560 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16561 cmd->nan_pmk_len);
16562
16563 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16564 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16565 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16566 req->passphrase.passphrase,
16567 cmd->nan_passphrase_len);
16568 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16569
16570 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16571 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16572 req->service_name.service_name,
16573 cmd->nan_servicename_len);
16574
16575 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16576
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016577 if (req->is_ipv6_addr_present || req->is_port_present ||
16578 req->is_protocol_present) {
16579 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16580 WMITLV_SET_HDR(tcp_ip_param,
16581 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16582 WMITLV_GET_STRUCT_TLVLEN(
16583 wmi_ndp_transport_ip_param));
16584 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16585 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16586 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16587
16588 tcp_ip_param->trans_port_present = req->is_port_present;
16589 tcp_ip_param->transport_port = req->port;
16590
16591 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16592 tcp_ip_param->transport_protocol = req->protocol;
16593 }
16594 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16595 req->is_ipv6_addr_present, req->ipv6_addr);
16596 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16597 WMI_LOGD(FL("protocol: %d present: %d"),
16598 req->is_protocol_present, req->protocol);
16599
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016600 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16601 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16602
16603 WMI_LOGD("ndp_config len: %d",
16604 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016605 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016606 req->ndp_config.ndp_cfg,
16607 req->ndp_config.ndp_cfg_len);
16608
16609 WMI_LOGD("ndp_app_info len: %d",
16610 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016611 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016612 req->ndp_info.ndp_app_info,
16613 req->ndp_info.ndp_app_info_len);
16614
16615 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016616 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016617 req->pmk.pmk, cmd->nan_pmk_len);
16618
16619 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016620 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016621 req->passphrase.passphrase,
16622 cmd->nan_passphrase_len);
16623
16624 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016625 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016626 req->service_name.service_name,
16627 cmd->nan_servicename_len);
16628
16629 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16630 WMI_NDP_RESPONDER_REQ_CMDID);
16631 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16632 WMI_NDP_RESPONDER_REQ_CMDID);
16633 if (QDF_IS_STATUS_ERROR(status)) {
16634 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16635 wmi_buf_free(buf);
16636 }
16637 return status;
16638}
16639
16640static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16641 struct nan_datapath_end_req *req)
16642{
16643 uint16_t len;
16644 wmi_buf_t buf;
16645 QDF_STATUS status;
16646 uint32_t ndp_end_req_len, i;
16647 wmi_ndp_end_req *ndp_end_req_lst;
16648 wmi_ndp_end_req_fixed_param *cmd;
16649
16650 /* len of tlv following fixed param */
16651 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16652 /* above comes out to 4 byte alligned already, no need of padding */
16653 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16654 buf = wmi_buf_alloc(wmi_handle, len);
16655 if (!buf) {
16656 WMI_LOGE("Malloc failed");
16657 return QDF_STATUS_E_NOMEM;
16658 }
16659
16660 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16661 WMITLV_SET_HDR(&cmd->tlv_header,
16662 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16663 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16664
16665 cmd->transaction_id = req->transaction_id;
16666
16667 /* set tlv pointer to end of fixed param */
16668 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16669 ndp_end_req_len);
16670
16671 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16672 WMI_TLV_HDR_SIZE);
16673 for (i = 0; i < req->num_ndp_instances; i++) {
16674 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16675 WMITLV_TAG_ARRAY_FIXED_STRUC,
16676 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16677
16678 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16679 }
16680
16681 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16682 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16683 WMI_NDP_END_REQ_CMDID);
16684 if (QDF_IS_STATUS_ERROR(status)) {
16685 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16686 wmi_buf_free(buf);
16687 }
16688
16689 return status;
16690}
16691
16692static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016693 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016694{
16695 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16696 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16697
16698 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16699 fixed_params = event->fixed_param;
16700
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016701 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016702 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16703 fixed_params->vdev_id,
16704 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016705 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016706 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016707 return QDF_STATUS_E_INVAL;
16708 }
16709
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016710 rsp->transaction_id = fixed_params->transaction_id;
16711 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16712 rsp->status = fixed_params->rsp_status;
16713 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016714
16715 return QDF_STATUS_SUCCESS;
16716}
16717
16718static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016719 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016720{
16721 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16722 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016723 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016724
16725 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16726 fixed_params =
16727 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16728
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016729 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16730 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16731 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16732 return QDF_STATUS_E_INVAL;
16733 }
16734
16735 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16736 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16737 fixed_params->ndp_app_info_len,
16738 event->num_ndp_app_info);
16739 return QDF_STATUS_E_INVAL;
16740 }
16741
gaolezab037cf2018-05-23 14:40:32 +080016742 if (fixed_params->ndp_cfg_len >
16743 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16744 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16745 __func__, fixed_params->ndp_cfg_len);
16746 return QDF_STATUS_E_INVAL;
16747 }
16748
16749 total_array_len = fixed_params->ndp_cfg_len +
16750 sizeof(*fixed_params);
16751
16752 if (fixed_params->ndp_app_info_len >
16753 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16754 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16755 __func__, fixed_params->ndp_app_info_len);
16756 return QDF_STATUS_E_INVAL;
16757 }
16758 total_array_len += fixed_params->ndp_app_info_len;
16759
16760 if (fixed_params->nan_scid_len >
16761 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16762 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16763 __func__, fixed_params->nan_scid_len);
16764 return QDF_STATUS_E_INVAL;
16765 }
16766
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016767 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016768 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16769 fixed_params->vdev_id,
16770 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016771 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016772 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016773 return QDF_STATUS_E_INVAL;
16774 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016775 rsp->service_instance_id = fixed_params->service_instance_id;
16776 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16777 rsp->role = fixed_params->self_ndp_role;
16778 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016779
16780 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016781 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016782 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016783 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016784
16785 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16786 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16787 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16788 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16789 fixed_params->service_instance_id,
16790 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16791 fixed_params->accept_policy,
16792 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016793 rsp->peer_mac_addr.bytes,
16794 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016795
16796 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016797 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016798 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16799
16800 WMI_LOGD("ndp_app_info - %d bytes",
16801 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016802 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016803 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16804
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016805 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16806 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16807 rsp->ncs_sk_type = fixed_params->nan_csid;
16808 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016809
16810 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16811 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016812 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16813 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016814
16815 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16816 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016817 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16818 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016819
16820 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16821 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016822 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016823
16824 if (event->ndp_transport_ip_param &&
16825 event->num_ndp_transport_ip_param) {
16826 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16827 rsp->is_ipv6_addr_present = true;
16828 qdf_mem_copy(rsp->ipv6_addr,
16829 event->ndp_transport_ip_param->ipv6_intf_addr,
16830 WMI_NDP_IPV6_INTF_ADDR_LEN);
16831 }
16832 }
16833 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16834 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16835
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016836 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016837 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016838 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016839
16840 return QDF_STATUS_SUCCESS;
16841}
16842
16843static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016844 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016845{
Naveen Rawat38b21462018-05-31 15:04:16 -070016846 uint8_t i;
16847 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016848 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16849 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016850 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016851
16852 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16853 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016854 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 -080016855 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16856 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16857 fixed_params->reason_code,
16858 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016859 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016860
16861 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16862 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16863 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16864 return QDF_STATUS_E_INVAL;
16865 }
16866
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016867 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016868 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016869 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16870
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016871 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16872 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16873 fixed_params->ndp_app_info_len,
16874 event->num_ndp_app_info);
16875 return QDF_STATUS_E_INVAL;
16876 }
16877
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016878 WMI_LOGD("ndp_app_info - %d bytes",
16879 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016880 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016881 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16882
gaolezab037cf2018-05-23 14:40:32 +080016883 if (fixed_params->ndp_cfg_len >
16884 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16885 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16886 __func__, fixed_params->ndp_cfg_len);
16887 return QDF_STATUS_E_INVAL;
16888 }
16889
16890 total_array_len = fixed_params->ndp_cfg_len +
16891 sizeof(*fixed_params);
16892
16893 if (fixed_params->ndp_app_info_len >
16894 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16895 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16896 __func__, fixed_params->ndp_app_info_len);
16897 return QDF_STATUS_E_INVAL;
16898 }
16899
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016900 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016901 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16902 fixed_params->vdev_id,
16903 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016904 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016905 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016906 return QDF_STATUS_E_INVAL;
16907 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016908 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16909 rsp->rsp_code = fixed_params->rsp_code;
16910 rsp->reason_code = fixed_params->reason_code;
16911 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016912 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016913 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016914 rsp->peer_ndi_mac_addr.bytes);
16915 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16916 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16917 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016918
Naveen Rawat38b21462018-05-31 15:04:16 -070016919 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16920 WMI_LOGE(FL("too many channels"));
16921 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16922 }
16923
16924 for (i = 0; i < rsp->num_channels; i++) {
16925 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16926 rsp->ch[i].nss = event->nss_list[i];
16927 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16928 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16929 ch_mode);
16930 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16931 rsp->ch[i].channel,
16932 rsp->ch[i].ch_width,
16933 rsp->ch[i].nss);
16934 }
16935
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016936 if (event->ndp_transport_ip_param &&
16937 event->num_ndp_transport_ip_param) {
16938 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16939 rsp->is_ipv6_addr_present = true;
16940 qdf_mem_copy(rsp->ipv6_addr,
16941 event->ndp_transport_ip_param->ipv6_intf_addr,
16942 WMI_NDP_IPV6_INTF_ADDR_LEN);
16943 }
16944
16945 if (event->ndp_transport_ip_param->trans_port_present) {
16946 rsp->is_port_present = true;
16947 rsp->port =
16948 event->ndp_transport_ip_param->transport_port;
16949 }
16950
16951 if (event->ndp_transport_ip_param->trans_proto_present) {
16952 rsp->is_protocol_present = true;
16953 rsp->protocol =
16954 event->ndp_transport_ip_param->transport_protocol;
16955 }
16956 }
16957 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16958 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16959 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
16960 WMI_LOGD(FL("protocol: %d present: %d"),
16961 rsp->protocol, rsp->is_protocol_present);
16962
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016963 return QDF_STATUS_SUCCESS;
16964}
16965
16966static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016967 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016968{
16969 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
16970 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
16971
16972 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
16973 fixed_params = event->fixed_param;
16974
16975 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",
16976 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016977 rsp->peer_mac_addr.bytes, rsp->transaction_id,
16978 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016979
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016980 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016981 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16982 fixed_params->vdev_id,
16983 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016984 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016985 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016986 return QDF_STATUS_E_INVAL;
16987 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016988 rsp->transaction_id = fixed_params->transaction_id;
16989 rsp->reason = fixed_params->reason_code;
16990 rsp->status = fixed_params->rsp_status;
16991 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016992 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016993 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016994
16995 return QDF_STATUS_SUCCESS;
16996}
16997
16998static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016999 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017000{
17001 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17002 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17003
17004 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17005 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017006 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 -080017007 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17008 fixed_params->rsp_status, fixed_params->reason_code);
17009
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017010 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017011 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017012 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017013 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017014 return QDF_STATUS_E_INVAL;
17015 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017016 rsp->transaction_id = fixed_params->transaction_id;
17017 rsp->reason = fixed_params->reason_code;
17018 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017019
17020 return QDF_STATUS_SUCCESS;
17021}
17022
17023static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17024 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17025{
17026 uint32_t i, buf_size;
17027 wmi_ndp_end_indication *ind;
17028 struct qdf_mac_addr peer_addr;
17029 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17030
17031 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17032 ind = event->ndp_end_indication_list;
17033
17034 if (event->num_ndp_end_indication_list == 0) {
17035 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017036 return QDF_STATUS_E_INVAL;
17037 }
17038
17039 WMI_LOGD("number of ndp instances = %d",
17040 event->num_ndp_end_indication_list);
17041
17042 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17043 sizeof((*rsp)->ndp_map[0]))) {
17044 WMI_LOGE("num_ndp_end_ind_list %d too large",
17045 event->num_ndp_end_indication_list);
17046 return QDF_STATUS_E_INVAL;
17047 }
17048
17049 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17050 sizeof((*rsp)->ndp_map[0]);
17051 *rsp = qdf_mem_malloc(buf_size);
17052 if (!(*rsp)) {
17053 WMI_LOGE("Failed to allocate memory");
17054 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017055 }
17056
17057 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17058 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17059 if (!(*rsp)->vdev) {
17060 WMI_LOGE("vdev is null");
17061 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017062 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017063 return QDF_STATUS_E_INVAL;
17064 }
17065
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017066 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17067 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17068 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17069 peer_addr.bytes);
17070 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17071 i, ind[i].type, ind[i].reason_code,
17072 ind[i].ndp_instance_id,
17073 ind[i].num_active_ndps_on_peer);
17074 /* Add each instance entry to the list */
17075 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17076 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17077 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17078 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17079 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17080 ind[i].num_active_ndps_on_peer;
17081 (*rsp)->ndp_map[i].type = ind[i].type;
17082 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17083 }
17084
17085 return QDF_STATUS_SUCCESS;
17086}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017087
17088static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17089 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17090{
17091 uint8_t i;
17092 WMI_HOST_WLAN_PHY_MODE ch_mode;
17093 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17094 wmi_ndl_schedule_update_fixed_param *fixed_params;
17095
17096 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17097 fixed_params = event->fixed_param;
17098
17099 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17100 fixed_params->flags, fixed_params->num_channels,
17101 fixed_params->num_ndp_instances);
17102
17103 ind->vdev =
17104 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17105 fixed_params->vdev_id,
17106 WLAN_NAN_ID);
17107 if (!ind->vdev) {
17108 WMI_LOGE("vdev is null");
17109 return QDF_STATUS_E_INVAL;
17110 }
17111
17112 ind->flags = fixed_params->flags;
17113 ind->num_channels = fixed_params->num_channels;
17114 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17115 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17116 ind->peer_addr.bytes);
17117
17118 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17119 WMI_LOGE(FL("uint32 overflow"));
17120 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17121 return QDF_STATUS_E_INVAL;
17122 }
17123
17124 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17125 sizeof(uint32_t) * ind->num_ndp_instances);
17126
17127 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17128 WMI_LOGE(FL("too many channels"));
17129 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17130 }
17131 for (i = 0; i < ind->num_channels; i++) {
17132 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17133 ind->ch[i].nss = event->nss_list[i];
17134 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17135 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17136 ch_mode);
17137 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17138 ind->ch[i].channel,
17139 ind->ch[i].ch_width,
17140 ind->ch[i].nss);
17141 }
17142
17143 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17144 WMI_LOGD(FL("instance_id[%d]: %d"),
17145 i, event->ndp_instance_list[i]);
17146
17147 return QDF_STATUS_SUCCESS;
17148}
17149
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017150#endif
17151
Naveen Rawat963ee942018-04-13 16:38:36 -070017152#ifdef QCA_SUPPORT_CP_STATS
17153/**
17154 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17155 * @wmi_handle: wma handle
17156 * @evt_buf: event buffer
17157 * @out_buff: buffer to populated after stats extraction
17158 *
17159 * Return: status of operation
17160 */
17161static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17162 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17163{
17164 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17165 wmi_congestion_stats *congestion_stats;
17166
17167 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17168 congestion_stats = param_buf->congestion_stats;
17169 if (!congestion_stats) {
17170 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17171 return QDF_STATUS_E_INVAL;
17172 }
17173
17174 out_buff->vdev_id = congestion_stats->vdev_id;
17175 out_buff->congestion = congestion_stats->congestion;
17176
17177 WMI_LOGD("%s: cca stats event processed", __func__);
17178 return QDF_STATUS_SUCCESS;
17179}
17180#endif /* QCA_SUPPORT_CP_STATS */
17181
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017182/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017183 * save_service_bitmap_tlv() - save service bitmap
17184 * @wmi_handle: wmi handle
17185 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017186 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017187 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017188 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017189 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017190static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017191QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017192 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017193{
17194 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017195 struct wmi_soc *soc = wmi_handle->soc;
17196
Govind Singhe7f2f342016-05-23 12:12:52 +053017197 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17198
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017199 /* If it is already allocated, use that buffer. This can happen
17200 * during target stop/start scenarios where host allocation is skipped.
17201 */
17202 if (!soc->wmi_service_bitmap) {
17203 soc->wmi_service_bitmap =
17204 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17205 if (!soc->wmi_service_bitmap) {
17206 WMI_LOGE("Failed memory allocation for service bitmap");
17207 return QDF_STATUS_E_NOMEM;
17208 }
17209 }
17210
17211 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017212 param_buf->wmi_service_bitmap,
17213 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017214
17215 if (bitmap_buf)
17216 qdf_mem_copy(bitmap_buf,
17217 param_buf->wmi_service_bitmap,
17218 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017219
17220 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017221}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017222
17223/**
17224 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17225 * @wmi_handle: wmi handle
17226 * @param evt_buf: pointer to event buffer
17227 * @param bitmap_buf: bitmap buffer, for converged legacy support
17228 *
17229 * Return: QDF_STATUS
17230 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017231static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017232QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017233 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017234{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017235 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17236 wmi_service_available_event_fixed_param *ev;
17237 struct wmi_soc *soc = wmi_handle->soc;
17238
17239 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17240
17241 ev = param_buf->fixed_param;
17242
17243 /* If it is already allocated, use that buffer. This can happen
17244 * during target stop/start scenarios where host allocation is skipped.
17245 */
17246 if (!soc->wmi_ext_service_bitmap) {
17247 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17248 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17249 if (!soc->wmi_ext_service_bitmap) {
17250 WMI_LOGE("Failed memory allocation for service bitmap");
17251 return QDF_STATUS_E_NOMEM;
17252 }
17253 }
17254
17255 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17256 ev->wmi_service_segment_bitmap,
17257 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017258
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017259 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17260 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17261 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17262
Rajeev Kumar77901472017-02-12 02:12:17 -080017263 if (bitmap_buf)
17264 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017265 soc->wmi_ext_service_bitmap,
17266 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017267
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017268 return QDF_STATUS_SUCCESS;
17269}
Govind Singhe7f2f342016-05-23 12:12:52 +053017270/**
17271 * is_service_enabled_tlv() - Check if service enabled
17272 * @param wmi_handle: wmi handle
17273 * @param service_id: service identifier
17274 *
17275 * Return: 1 enabled, 0 disabled
17276 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017277static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17278 uint32_t service_id)
17279{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017280 struct wmi_soc *soc = wmi_handle->soc;
17281
17282 if (!soc->wmi_service_bitmap) {
17283 WMI_LOGE("WMI service bit map is not saved yet\n");
17284 return false;
17285 }
17286
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017287 /* if wmi_service_enabled was received with extended bitmap,
17288 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017289 */
17290 if (soc->wmi_ext_service_bitmap)
17291 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17292 soc->wmi_ext_service_bitmap,
17293 service_id);
17294
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017295 if (service_id >= WMI_MAX_SERVICE) {
17296 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17297 service_id);
17298 return false;
17299 }
17300
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017301 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17302 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017303}
Govind Singhe7f2f342016-05-23 12:12:52 +053017304
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017305static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17306 struct wlan_psoc_target_capability_info *cap)
17307{
17308 /* except LDPC all flags are common betwen legacy and here
17309 * also IBFEER is not defined for TLV
17310 */
17311 cap->ht_cap_info |= ev_target_cap & (
17312 WMI_HT_CAP_ENABLED
17313 | WMI_HT_CAP_HT20_SGI
17314 | WMI_HT_CAP_DYNAMIC_SMPS
17315 | WMI_HT_CAP_TX_STBC
17316 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17317 | WMI_HT_CAP_RX_STBC
17318 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17319 | WMI_HT_CAP_LDPC
17320 | WMI_HT_CAP_L_SIG_TXOP_PROT
17321 | WMI_HT_CAP_MPDU_DENSITY
17322 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17323 | WMI_HT_CAP_HT40_SGI);
17324 if (ev_target_cap & WMI_HT_CAP_LDPC)
17325 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17326 WMI_HOST_HT_CAP_TX_LDPC;
17327}
Govind Singhe7f2f342016-05-23 12:12:52 +053017328/**
17329 * extract_service_ready_tlv() - extract service ready event
17330 * @wmi_handle: wmi handle
17331 * @param evt_buf: pointer to received event buffer
17332 * @param cap: pointer to hold target capability information extracted from even
17333 *
17334 * Return: QDF_STATUS_SUCCESS for success or error code
17335 */
17336static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017337 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017338{
17339 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17340 wmi_service_ready_event_fixed_param *ev;
17341
17342
17343 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17344
17345 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17346 if (!ev) {
17347 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17348 return QDF_STATUS_E_FAILURE;
17349 }
17350
17351 cap->phy_capability = ev->phy_capability;
17352 cap->max_frag_entry = ev->max_frag_entry;
17353 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017354 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017355 cap->vht_cap_info = ev->vht_cap_info;
17356 cap->vht_supp_mcs = ev->vht_supp_mcs;
17357 cap->hw_min_tx_power = ev->hw_min_tx_power;
17358 cap->hw_max_tx_power = ev->hw_max_tx_power;
17359 cap->sys_cap_info = ev->sys_cap_info;
17360 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17361 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17362 cap->max_num_scan_channels = ev->max_num_scan_channels;
17363 cap->max_supported_macs = ev->max_supported_macs;
17364 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17365 cap->txrx_chainmask = ev->txrx_chainmask;
17366 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17367 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017368 cap->fw_version = ev->fw_build_vers;
17369 /* fw_version_1 is not available in TLV. */
17370 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017371
17372 return QDF_STATUS_SUCCESS;
17373}
17374
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017375/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17376 * to host internal WMI_HOST_REGDMN_MODE values.
17377 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17378 * host currently. Add this in the future if required.
17379 * 11AX (Phase II) : 11ax related values are not currently
17380 * advertised separately by FW. As part of phase II regulatory bring-up,
17381 * finalize the advertisement mechanism.
17382 * @target_wireless_mode: target wireless mode received in message
17383 *
17384 * Return: returns the host internal wireless mode.
17385 */
17386static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17387{
17388
17389 uint32_t wireless_modes = 0;
17390
17391 if (target_wireless_mode & REGDMN_MODE_11A)
17392 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17393
17394 if (target_wireless_mode & REGDMN_MODE_TURBO)
17395 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17396
17397 if (target_wireless_mode & REGDMN_MODE_11B)
17398 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17399
17400 if (target_wireless_mode & REGDMN_MODE_PUREG)
17401 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17402
17403 if (target_wireless_mode & REGDMN_MODE_11G)
17404 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17405
17406 if (target_wireless_mode & REGDMN_MODE_108G)
17407 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17408
17409 if (target_wireless_mode & REGDMN_MODE_108A)
17410 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17411
17412 if (target_wireless_mode & REGDMN_MODE_XR)
17413 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17414
17415 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17416 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17417
17418 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17419 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17420
17421 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17422 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17423
17424 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17425 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17426
17427 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17428 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17429
17430 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17431 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17432
17433 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17434 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17435
17436 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17437 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17438
17439 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17440 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17441
17442 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17443 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17444
17445 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17446 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17447
17448 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17449 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17450
17451 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17452 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17453
17454 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17455 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17456
17457 return wireless_modes;
17458}
17459
Govind Singhe7f2f342016-05-23 12:12:52 +053017460/**
17461 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17462 * @wmi_handle: wmi handle
17463 * @param evt_buf: Pointer to event buffer
17464 * @param cap: pointer to hold HAL reg capabilities
17465 *
17466 * Return: QDF_STATUS_SUCCESS for success or error code
17467 */
17468static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017469 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017470{
17471 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17472
17473 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17474
17475 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17476 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017477 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017478
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017479 cap->wireless_modes = convert_wireless_modes_tlv(
17480 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017481
Govind Singhe7f2f342016-05-23 12:12:52 +053017482 return QDF_STATUS_SUCCESS;
17483}
17484
17485/**
17486 * extract_host_mem_req_tlv() - Extract host memory request event
17487 * @wmi_handle: wmi handle
17488 * @param evt_buf: pointer to event buffer
17489 * @param num_entries: pointer to hold number of entries requested
17490 *
17491 * Return: Number of entries requested
17492 */
17493static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17494 void *evt_buf, uint8_t *num_entries)
17495{
17496 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17497 wmi_service_ready_event_fixed_param *ev;
17498
17499 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17500
17501 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17502 if (!ev) {
17503 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17504 return NULL;
17505 }
17506
17507 *num_entries = ev->num_mem_reqs;
17508
17509 return (host_mem_req *)param_buf->mem_reqs;
17510}
17511
17512/**
17513 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17514 * ready function
17515 * @wmi_handle: wmi handle
17516 * @param evt_buf: pointer to event buffer
17517 *
17518 * Return: QDF_STATUS_SUCCESS for success or error code
17519 */
17520static QDF_STATUS
17521save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17522{
17523 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17524 wmi_service_ready_event_fixed_param *ev;
17525
17526
17527 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17528
17529 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17530 if (!ev) {
17531 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17532 return QDF_STATUS_E_FAILURE;
17533 }
17534
17535 /*Save fw version from service ready message */
17536 /*This will be used while sending INIT message */
17537 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17538 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017539
Govind Singhe7f2f342016-05-23 12:12:52 +053017540 return QDF_STATUS_SUCCESS;
17541}
17542
17543/**
17544 * ready_extract_init_status_tlv() - Extract init status from ready event
17545 * @wmi_handle: wmi handle
17546 * @param evt_buf: Pointer to event buffer
17547 *
17548 * Return: ready status
17549 */
17550static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17551 void *evt_buf)
17552{
17553 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17554 wmi_ready_event_fixed_param *ev = NULL;
17555
Govind Singhe7f2f342016-05-23 12:12:52 +053017556 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17557 ev = param_buf->fixed_param;
17558
17559 qdf_print("%s:%d\n", __func__, ev->status);
17560
17561 return ev->status;
17562}
17563
17564/**
17565 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17566 * @wmi_handle: wmi handle
17567 * @param evt_buf: pointer to event buffer
17568 * @param macaddr: Pointer to hold MAC address
17569 *
17570 * Return: QDF_STATUS_SUCCESS for success or error code
17571 */
17572static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17573 void *evt_buf, uint8_t *macaddr)
17574{
17575 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17576 wmi_ready_event_fixed_param *ev = NULL;
17577
17578
17579 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17580 ev = param_buf->fixed_param;
17581
17582 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17583
17584 return QDF_STATUS_SUCCESS;
17585}
17586
17587/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017588 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17589 * @wmi_handle: wmi handle
17590 * @param evt_buf: pointer to event buffer
17591 * @param macaddr: Pointer to hold number of MAC addresses
17592 *
17593 * Return: Pointer to addr list
17594 */
17595static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17596 void *evt_buf, uint8_t *num_mac)
17597{
17598 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17599 wmi_ready_event_fixed_param *ev = NULL;
17600
17601 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17602 ev = param_buf->fixed_param;
17603
17604 *num_mac = ev->num_extra_mac_addr;
17605
17606 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17607}
17608
17609/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017610 * extract_ready_params_tlv() - Extract data from ready event apart from
17611 * status, macaddr and version.
17612 * @wmi_handle: Pointer to WMI handle.
17613 * @evt_buf: Pointer to Ready event buffer.
17614 * @ev_param: Pointer to host defined struct to copy the data from event.
17615 *
17616 * Return: QDF_STATUS_SUCCESS on success.
17617 */
17618static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17619 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17620{
17621 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17622 wmi_ready_event_fixed_param *ev = NULL;
17623
17624 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17625 ev = param_buf->fixed_param;
17626
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017627 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017628 ev_param->num_dscp_table = ev->num_dscp_table;
17629 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17630 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017631 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017632 /* Agile_cap in ready event is not supported in TLV target */
17633 ev_param->agile_capability = false;
17634
17635 return QDF_STATUS_SUCCESS;
17636}
17637
17638/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017639 * extract_dbglog_data_len_tlv() - extract debuglog data length
17640 * @wmi_handle: wmi handle
17641 * @param evt_buf: pointer to event buffer
17642 *
17643 * Return: length
17644 */
17645static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017646 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017647{
17648 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17649
17650 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17651
17652 *len = param_buf->num_bufp;
17653
17654 return param_buf->bufp;
17655}
17656
17657/**
17658 * extract_vdev_start_resp_tlv() - extract vdev start response
17659 * @wmi_handle: wmi handle
17660 * @param evt_buf: pointer to event buffer
17661 * @param vdev_rsp: Pointer to hold vdev response
17662 *
17663 * Return: QDF_STATUS_SUCCESS for success or error code
17664 */
17665static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17666 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17667{
17668 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17669 wmi_vdev_start_response_event_fixed_param *ev;
17670
17671 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17672 if (!param_buf) {
17673 qdf_print("Invalid start response event buffer\n");
17674 return QDF_STATUS_E_INVAL;
17675 }
17676
17677 ev = param_buf->fixed_param;
17678 if (!ev) {
17679 qdf_print("Invalid start response event buffer\n");
17680 return QDF_STATUS_E_INVAL;
17681 }
17682
17683 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17684
17685 vdev_rsp->vdev_id = ev->vdev_id;
17686 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017687 switch (ev->resp_type) {
17688 case WMI_VDEV_START_RESP_EVENT:
17689 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17690 break;
17691 case WMI_VDEV_RESTART_RESP_EVENT:
17692 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17693 break;
17694 default:
17695 qdf_print("Invalid start response event buffer\n");
17696 break;
17697 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017698 vdev_rsp->status = ev->status;
17699 vdev_rsp->chain_mask = ev->chain_mask;
17700 vdev_rsp->smps_mode = ev->smps_mode;
17701 vdev_rsp->mac_id = ev->mac_id;
17702 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17703 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17704
17705 return QDF_STATUS_SUCCESS;
17706}
17707
17708/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017709 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17710 * @wmi_handle: wmi handle
17711 * @param evt_buf: pointer to event buffer
17712 * @param delete_rsp: Pointer to hold vdev delete response
17713 *
17714 * Return: QDF_STATUS_SUCCESS for success or error code
17715 */
17716static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17717 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17718{
17719 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17720 wmi_vdev_delete_resp_event_fixed_param *ev;
17721
17722 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17723 if (!param_buf) {
17724 WMI_LOGE("Invalid vdev delete response event buffer\n");
17725 return QDF_STATUS_E_INVAL;
17726 }
17727
17728 ev = param_buf->fixed_param;
17729 if (!ev) {
17730 WMI_LOGE("Invalid vdev delete response event\n");
17731 return QDF_STATUS_E_INVAL;
17732 }
17733
17734 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17735 delete_rsp->vdev_id = ev->vdev_id;
17736
17737 return QDF_STATUS_SUCCESS;
17738}
17739
17740
17741/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017742 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017743 * @wmi_handle: wmi handle
17744 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017745 * @param num_vdevs: Pointer to hold num vdev
17746 *
17747 * Return: QDF_STATUS_SUCCESS for success or error code
17748 */
17749static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17750 void *evt_buf, uint32_t *num_vdevs)
17751{
17752 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17753 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17754 uint32_t vdev_map;
17755
17756 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17757 if (!param_buf) {
17758 qdf_print("Invalid tbtt update ext event buffer\n");
17759 return QDF_STATUS_E_INVAL;
17760 }
17761 tbtt_offset_event = param_buf->fixed_param;
17762 vdev_map = tbtt_offset_event->vdev_map;
17763 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17764
17765 return QDF_STATUS_SUCCESS;
17766}
17767
17768/**
17769 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17770 * @wmi_handle: wmi handle
17771 * @param evt_buf: pointer to event buffer
17772 * @param num_vdevs: Pointer to hold num vdev
17773 *
17774 * Return: QDF_STATUS_SUCCESS for success or error code
17775 */
17776static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17777 void *evt_buf, uint32_t *num_vdevs)
17778{
17779 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17780 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17781
17782 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17783 if (!param_buf) {
17784 qdf_print("Invalid tbtt update ext event buffer\n");
17785 return QDF_STATUS_E_INVAL;
17786 }
17787 tbtt_offset_ext_event = param_buf->fixed_param;
17788
17789 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17790
17791 return QDF_STATUS_SUCCESS;
17792}
17793
17794/**
17795 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17796 * @wmi_handle: wmi handle
17797 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017798 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017799 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017800 *
17801 * Return: QDF_STATUS_SUCCESS for success or error code
17802 */
17803static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017804 void *evt_buf, uint8_t idx,
17805 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017806{
17807 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17808 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017809 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017810
17811 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17812 if (!param_buf) {
17813 qdf_print("Invalid tbtt update event buffer\n");
17814 return QDF_STATUS_E_INVAL;
17815 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017816
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017817 tbtt_offset_event = param_buf->fixed_param;
17818 vdev_map = tbtt_offset_event->vdev_map;
17819 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17820 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17821 return QDF_STATUS_E_INVAL;
17822 tbtt_param->tbttoffset =
17823 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17824
17825 return QDF_STATUS_SUCCESS;
17826}
17827
17828/**
17829 * extract_ext_tbttoffset_update_params_tlv() - extract ext 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
17834 *
17835 * Return: QDF_STATUS_SUCCESS for success or error code
17836 */
17837static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17838 void *evt_buf, uint8_t idx,
17839 struct tbttoffset_params *tbtt_param)
17840{
17841 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17842 wmi_tbtt_offset_info *tbtt_offset_info;
17843
17844 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17845 if (!param_buf) {
17846 qdf_print("Invalid tbtt update event buffer\n");
17847 return QDF_STATUS_E_INVAL;
17848 }
17849 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17850
17851 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17852 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017853
17854 return QDF_STATUS_SUCCESS;
17855}
17856
17857/**
17858 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17859 * @wmi_handle: wmi handle
17860 * @param evt_buf: pointer to event buffer
17861 * @param hdr: Pointer to hold header
17862 * @param bufp: Pointer to hold pointer to rx param buffer
17863 *
17864 * Return: QDF_STATUS_SUCCESS for success or error code
17865 */
17866static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017867 void *evt_buf, struct mgmt_rx_event_params *hdr,
17868 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017869{
17870 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17871 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017872 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017873
17874 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17875 if (!param_tlvs) {
17876 WMI_LOGE("Get NULL point message from FW");
17877 return QDF_STATUS_E_INVAL;
17878 }
17879
17880 ev_hdr = param_tlvs->hdr;
17881 if (!hdr) {
17882 WMI_LOGE("Rx event is NULL");
17883 return QDF_STATUS_E_INVAL;
17884 }
17885
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017886 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17887 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017888
17889 hdr->channel = ev_hdr->channel;
17890 hdr->snr = ev_hdr->snr;
17891 hdr->rate = ev_hdr->rate;
17892 hdr->phy_mode = ev_hdr->phy_mode;
17893 hdr->buf_len = ev_hdr->buf_len;
17894 hdr->status = ev_hdr->status;
17895 hdr->flags = ev_hdr->flags;
17896 hdr->rssi = ev_hdr->rssi;
17897 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017898 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17899 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017900
17901 *bufp = param_tlvs->bufp;
17902
17903 return QDF_STATUS_SUCCESS;
17904}
17905
17906/**
17907 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17908 * @wmi_handle: wmi handle
17909 * @param evt_buf: pointer to event buffer
17910 * @param vdev_id: Pointer to hold vdev identifier
17911 *
17912 * Return: QDF_STATUS_SUCCESS for success or error code
17913 */
17914static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17915 void *evt_buf, uint32_t *vdev_id)
17916{
17917 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17918 wmi_vdev_stopped_event_fixed_param *resp_event;
17919
17920 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17921 if (!param_buf) {
17922 WMI_LOGE("Invalid event buffer");
17923 return QDF_STATUS_E_INVAL;
17924 }
17925 resp_event = param_buf->fixed_param;
17926 *vdev_id = resp_event->vdev_id;
17927
17928 return QDF_STATUS_SUCCESS;
17929}
17930
17931/**
17932 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17933 * @wmi_handle: wmi handle
17934 * @param evt_buf: pointer to event buffer
17935 * @param param: Pointer to hold roam param
17936 *
17937 * Return: QDF_STATUS_SUCCESS for success or error code
17938 */
17939static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17940 void *evt_buf, wmi_host_roam_event *param)
17941{
17942 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17943 wmi_roam_event_fixed_param *evt;
17944
17945 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17946 if (!param_buf) {
17947 WMI_LOGE("Invalid roam event buffer");
17948 return QDF_STATUS_E_INVAL;
17949 }
17950
17951 evt = param_buf->fixed_param;
17952 qdf_mem_zero(param, sizeof(*param));
17953
17954 param->vdev_id = evt->vdev_id;
17955 param->reason = evt->reason;
17956 param->rssi = evt->rssi;
17957
17958 return QDF_STATUS_SUCCESS;
17959}
17960
17961/**
17962 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
17963 * @wmi_handle: wmi handle
17964 * @param evt_buf: pointer to event buffer
17965 * @param param: Pointer to hold vdev scan param
17966 *
17967 * Return: QDF_STATUS_SUCCESS for success or error code
17968 */
17969static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017970 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017971{
17972 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
17973 wmi_scan_event_fixed_param *evt = NULL;
17974
17975 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
17976 evt = param_buf->fixed_param;
17977
17978 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017979
Govind Singhe7f2f342016-05-23 12:12:52 +053017980 switch (evt->event) {
17981 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017982 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017983 break;
17984 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017985 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017986 break;
17987 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017988 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017989 break;
17990 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017991 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017992 break;
17993 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017994 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017995 break;
17996 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017997 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017998 break;
17999 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018000 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018001 break;
18002 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018003 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018004 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018005 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018006 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018007 break;
18008 case WMI_SCAN_EVENT_MAX:
18009 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018010 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018011 break;
18012 };
18013
18014 switch (evt->reason) {
18015 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018016 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018017 break;
18018 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018019 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018020 break;
18021 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018022 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018023 break;
18024 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018025 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018026 break;
18027 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018028 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018029 break;
18030 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018031 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018032 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018033 case WMI_SCAN_REASON_SUSPENDED:
18034 param->reason = SCAN_REASON_SUSPENDED;
18035 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018036 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018037 param->reason = SCAN_REASON_MAX;
18038 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018039 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018040 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018041 break;
18042 };
18043
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018044 param->chan_freq = evt->channel_freq;
18045 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018046 param->scan_id = evt->scan_id;
18047 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018048 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018049
18050 return QDF_STATUS_SUCCESS;
18051}
18052
Frank Liu3d5e9992017-03-15 17:51:43 +080018053#ifdef CONVERGED_TDLS_ENABLE
18054/**
18055 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18056 * @wmi_handle: wmi handle
18057 * @param evt_buf: pointer to event buffer
18058 * @param param: Pointer to hold vdev tdls param
18059 *
18060 * Return: QDF_STATUS_SUCCESS for success or error code
18061 */
18062static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18063 void *evt_buf, struct tdls_event_info *param)
18064{
18065 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18066 wmi_tdls_peer_event_fixed_param *evt;
18067
18068 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18069 if (!param_buf) {
18070 WMI_LOGE("%s: NULL param_buf", __func__);
18071 return QDF_STATUS_E_NULL_VALUE;
18072 }
18073
18074 evt = param_buf->fixed_param;
18075
18076 qdf_mem_zero(param, sizeof(*param));
18077
18078 param->vdev_id = evt->vdev_id;
18079 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18080 param->peermac.bytes);
18081 switch (evt->peer_status) {
18082 case WMI_TDLS_SHOULD_DISCOVER:
18083 param->message_type = TDLS_SHOULD_DISCOVER;
18084 break;
18085 case WMI_TDLS_SHOULD_TEARDOWN:
18086 param->message_type = TDLS_SHOULD_TEARDOWN;
18087 break;
18088 case WMI_TDLS_PEER_DISCONNECTED:
18089 param->message_type = TDLS_PEER_DISCONNECTED;
18090 break;
18091 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18092 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18093 break;
18094 default:
18095 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18096 __func__, evt->peer_status);
18097 return QDF_STATUS_E_INVAL;
18098 };
18099
18100 switch (evt->peer_reason) {
18101 case WMI_TDLS_TEARDOWN_REASON_TX:
18102 param->peer_reason = TDLS_TEARDOWN_TX;
18103 break;
18104 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18105 param->peer_reason = TDLS_TEARDOWN_RSSI;
18106 break;
18107 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18108 param->peer_reason = TDLS_TEARDOWN_SCAN;
18109 break;
18110 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18111 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18112 break;
18113 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18114 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18115 break;
18116 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18117 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18118 break;
18119 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18120 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18121 break;
18122 case WMI_TDLS_ENTER_BUF_STA:
18123 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18124 break;
18125 case WMI_TDLS_EXIT_BUF_STA:
18126 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18127 break;
18128 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18129 param->peer_reason = TDLS_ENTER_BT_BUSY;
18130 break;
18131 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18132 param->peer_reason = TDLS_EXIT_BT_BUSY;
18133 break;
18134 case WMI_TDLS_SCAN_STARTED_EVENT:
18135 param->peer_reason = TDLS_SCAN_STARTED;
18136 break;
18137 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18138 param->peer_reason = TDLS_SCAN_COMPLETED;
18139 break;
18140
18141 default:
18142 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18143 __func__, evt->peer_reason, evt->peer_status);
18144 return QDF_STATUS_E_INVAL;
18145 };
18146
18147 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18148 __func__, param->peermac.bytes, param->message_type,
18149 param->peer_reason, param->vdev_id);
18150
18151 return QDF_STATUS_SUCCESS;
18152}
18153#endif
18154
Govind Singhe7f2f342016-05-23 12:12:52 +053018155/**
18156 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18157 * @wmi_handle: wmi handle
18158 * @param evt_buf: pointer to event buffer
18159 * @param param: Pointer to hold MGMT TX completion params
18160 *
18161 * Return: QDF_STATUS_SUCCESS for success or error code
18162 */
18163static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18164 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18165{
18166 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18167 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18168
18169 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18170 evt_buf;
18171 if (!param_buf) {
18172 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18173 return QDF_STATUS_E_INVAL;
18174 }
18175 cmpl_params = param_buf->fixed_param;
18176
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018177 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18178 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018179 param->desc_id = cmpl_params->desc_id;
18180 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018181 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018182
18183 return QDF_STATUS_SUCCESS;
18184}
18185
18186/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018187 * extract_offchan_data_tx_compl_param_tlv() -
18188 * extract Offchan data tx completion event params
18189 * @wmi_handle: wmi handle
18190 * @param evt_buf: pointer to event buffer
18191 * @param param: Pointer to hold offchan data TX completion params
18192 *
18193 * Return: QDF_STATUS_SUCCESS for success or error code
18194 */
18195static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18196 wmi_unified_t wmi_handle, void *evt_buf,
18197 struct wmi_host_offchan_data_tx_compl_event *param)
18198{
18199 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18200 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18201
18202 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18203 evt_buf;
18204 if (!param_buf) {
18205 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18206 return QDF_STATUS_E_INVAL;
18207 }
18208 cmpl_params = param_buf->fixed_param;
18209
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018210 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18211 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018212 param->desc_id = cmpl_params->desc_id;
18213 param->status = cmpl_params->status;
18214
18215 return QDF_STATUS_SUCCESS;
18216}
18217
18218/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018219 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18220 * status tlv
18221 * @wmi_handle: wmi handle
18222 * @param evt_buf: pointer to event buffer
18223 * @param param: Pointer to hold csa switch count status event param
18224 *
18225 * Return: QDF_STATUS_SUCCESS for success or error code
18226 */
18227static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18228 wmi_unified_t wmi_handle,
18229 void *evt_buf,
18230 struct pdev_csa_switch_count_status *param)
18231{
18232 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18233 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18234
18235 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18236 evt_buf;
18237 if (!param_buf) {
18238 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18239 return QDF_STATUS_E_INVAL;
18240 }
18241
18242 csa_status = 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 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018246 param->current_switch_count = csa_status->current_switch_count;
18247 param->num_vdevs = csa_status->num_vdevs;
18248 param->vdev_ids = param_buf->vdev_ids;
18249
18250 return QDF_STATUS_SUCCESS;
18251}
18252
18253/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018254 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18255 * param from event
18256 * @wmi_handle: wmi handle
18257 * @param evt_buf: pointer to event buffer
18258 * @param param: Pointer to hold tpc configuration
18259 *
18260 * Return: 0 for success or error code
18261 */
18262static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18263 void *evt_buf,
18264 wmi_host_pdev_tpc_config_event *param)
18265{
18266 wmi_pdev_tpc_config_event_fixed_param *event =
18267 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18268
18269 if (!event) {
18270 WMI_LOGE("Invalid event buffer");
18271 return QDF_STATUS_E_INVAL;
18272 }
18273
18274 param->pdev_id = event->pdev_id;
18275 param->regDomain = event->regDomain;
18276 param->chanFreq = event->chanFreq;
18277 param->phyMode = event->phyMode;
18278 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018279 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018280 param->twiceMaxRDPower = event->twiceMaxRDPower;
18281 param->powerLimit = event->powerLimit;
18282 param->rateMax = event->rateMax;
18283 param->numTxChain = event->numTxChain;
18284 param->ctl = event->ctl;
18285 param->flags = event->flags;
18286
18287 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18288 sizeof(param->maxRegAllowedPower));
18289 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18290 event->maxRegAllowedPowerAGCDD,
18291 sizeof(param->maxRegAllowedPowerAGCDD));
18292 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18293 event->maxRegAllowedPowerAGSTBC,
18294 sizeof(param->maxRegAllowedPowerAGSTBC));
18295 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18296 event->maxRegAllowedPowerAGTXBF,
18297 sizeof(param->maxRegAllowedPowerAGTXBF));
18298 WMI_LOGD("%s:extract success", __func__);
18299
18300 return QDF_STATUS_SUCCESS;
18301}
18302
18303/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018304 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018305 * @wmi_handle: wmi handle
18306 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018307 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018308 *
18309 * Return: QDF_STATUS_SUCCESS for success or error code
18310 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018311static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18312 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018313{
18314 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18315 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018316 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018317
18318 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18319 if (!param_buf) {
18320 WMI_LOGE("Invalid swba event buffer");
18321 return QDF_STATUS_E_INVAL;
18322 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018323
Govind Singhe7f2f342016-05-23 12:12:52 +053018324 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018325 *num_vdevs = swba_event->num_vdevs;
18326 if (!(*num_vdevs)) {
18327 vdev_map = swba_event->vdev_map;
18328 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18329 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018330
18331 return QDF_STATUS_SUCCESS;
18332}
18333
18334/**
18335 * extract_swba_tim_info_tlv() - extract swba tim info from event
18336 * @wmi_handle: wmi handle
18337 * @param evt_buf: pointer to event buffer
18338 * @param idx: Index to bcn info
18339 * @param tim_info: Pointer to hold tim info
18340 *
18341 * Return: QDF_STATUS_SUCCESS for success or error code
18342 */
18343static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18344 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18345{
18346 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18347 wmi_tim_info *tim_info_ev;
18348
18349 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18350 if (!param_buf) {
18351 WMI_LOGE("Invalid swba event buffer");
18352 return QDF_STATUS_E_INVAL;
18353 }
18354
18355 tim_info_ev = &param_buf->tim_info[idx];
18356
18357 tim_info->tim_len = tim_info_ev->tim_len;
18358 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18359 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18360 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18361 tim_info->tim_changed = tim_info_ev->tim_changed;
18362 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018363 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018364
18365 return QDF_STATUS_SUCCESS;
18366}
18367
18368/**
18369 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18370 * @wmi_handle: wmi handle
18371 * @param evt_buf: pointer to event buffer
18372 * @param idx: Index to bcn info
18373 * @param p2p_desc: Pointer to hold p2p NoA info
18374 *
18375 * Return: QDF_STATUS_SUCCESS for success or error code
18376 */
18377static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18378 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18379{
18380 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18381 wmi_p2p_noa_info *p2p_noa_info;
18382 uint8_t i = 0;
18383
18384 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18385 if (!param_buf) {
18386 WMI_LOGE("Invalid swba event buffer");
18387 return QDF_STATUS_E_INVAL;
18388 }
18389
18390 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18391
18392 p2p_desc->modified = false;
18393 p2p_desc->num_descriptors = 0;
18394 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18395 p2p_desc->modified = true;
18396 p2p_desc->index =
18397 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18398 p2p_desc->oppPS =
18399 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18400 p2p_desc->ctwindow =
18401 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18402 p2p_desc->num_descriptors =
18403 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18404 (p2p_noa_info);
18405 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18406 p2p_desc->noa_descriptors[i].type_count =
18407 (uint8_t) p2p_noa_info->noa_descriptors[i].
18408 type_count;
18409 p2p_desc->noa_descriptors[i].duration =
18410 p2p_noa_info->noa_descriptors[i].duration;
18411 p2p_desc->noa_descriptors[i].interval =
18412 p2p_noa_info->noa_descriptors[i].interval;
18413 p2p_desc->noa_descriptors[i].start_time =
18414 p2p_noa_info->noa_descriptors[i].start_time;
18415 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018416 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018417 }
18418
18419 return QDF_STATUS_SUCCESS;
18420}
18421
Wu Gaocd3a8512017-03-13 20:17:34 +080018422#ifdef CONVERGED_P2P_ENABLE
18423/**
18424 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18425 * @wmi_handle: wmi handle
18426 * @param evt_buf: pointer to event buffer
18427 * @param param: Pointer to hold p2p noa info
18428 *
18429 * Return: QDF_STATUS_SUCCESS for success or error code
18430 */
18431static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18432 wmi_unified_t wmi_handle, void *evt_buf,
18433 struct p2p_noa_info *param)
18434{
18435 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18436 wmi_p2p_noa_event_fixed_param *fixed_param;
18437 uint8_t i;
18438 wmi_p2p_noa_info *wmi_noa_info;
18439 uint8_t *buf_ptr;
18440 uint32_t descriptors;
18441
18442 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18443 if (!param_tlvs) {
18444 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18445 return QDF_STATUS_E_INVAL;
18446 }
18447
18448 if (!param) {
18449 WMI_LOGE("noa information param is null");
18450 return QDF_STATUS_E_INVAL;
18451 }
18452
18453 fixed_param = param_tlvs->fixed_param;
18454 buf_ptr = (uint8_t *) fixed_param;
18455 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18456 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18457
18458 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18459 WMI_LOGE("%s: noa attr is not modified", __func__);
18460 return QDF_STATUS_E_INVAL;
18461 }
18462
18463 param->vdev_id = fixed_param->vdev_id;
18464 param->index =
18465 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18466 param->opps_ps =
18467 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18468 param->ct_window =
18469 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18470 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18471 param->num_desc = (uint8_t) descriptors;
18472
18473 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18474 param->index, param->opps_ps, param->ct_window,
18475 param->num_desc);
18476 for (i = 0; i < param->num_desc; i++) {
18477 param->noa_desc[i].type_count =
18478 (uint8_t) wmi_noa_info->noa_descriptors[i].
18479 type_count;
18480 param->noa_desc[i].duration =
18481 wmi_noa_info->noa_descriptors[i].duration;
18482 param->noa_desc[i].interval =
18483 wmi_noa_info->noa_descriptors[i].interval;
18484 param->noa_desc[i].start_time =
18485 wmi_noa_info->noa_descriptors[i].start_time;
18486 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18487 __func__, i, param->noa_desc[i].type_count,
18488 param->noa_desc[i].duration,
18489 param->noa_desc[i].interval,
18490 param->noa_desc[i].start_time);
18491 }
18492
18493 return QDF_STATUS_SUCCESS;
18494}
18495
18496/**
18497 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18498 * information from event
18499 * @wmi_handle: wmi handle
18500 * @param evt_buf: pointer to event buffer
18501 * @param param: Pointer to hold p2p lo stop event information
18502 *
18503 * Return: QDF_STATUS_SUCCESS for success or error code
18504 */
18505static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18506 wmi_unified_t wmi_handle, void *evt_buf,
18507 struct p2p_lo_event *param)
18508{
18509 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18510 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18511
18512 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18513 evt_buf;
18514 if (!param_tlvs) {
18515 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18516 return QDF_STATUS_E_INVAL;
18517 }
18518
18519 if (!param) {
18520 WMI_LOGE("lo stop event param is null");
18521 return QDF_STATUS_E_INVAL;
18522 }
18523
18524 lo_param = param_tlvs->fixed_param;
18525 param->vdev_id = lo_param->vdev_id;
18526 param->reason_code = lo_param->reason;
18527 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18528 param->vdev_id, param->reason_code);
18529
18530 return QDF_STATUS_SUCCESS;
18531}
18532#endif /* End of CONVERGED_P2P_ENABLE */
18533
Govind Singhe7f2f342016-05-23 12:12:52 +053018534/**
18535 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18536 * @wmi_handle: wmi handle
18537 * @param evt_buf: pointer to event buffer
18538 * @param ev: Pointer to hold peer param
18539 *
18540 * Return: QDF_STATUS_SUCCESS for success or error code
18541 */
18542static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18543 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18544{
18545 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18546 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18547
18548 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18549 kickout_event = param_buf->fixed_param;
18550
18551 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18552 ev->peer_macaddr);
18553
18554 ev->reason = kickout_event->reason;
18555 ev->rssi = kickout_event->rssi;
18556
18557 return QDF_STATUS_SUCCESS;
18558}
18559
18560/**
18561 * extract_all_stats_counts_tlv() - extract all stats count from event
18562 * @wmi_handle: wmi handle
18563 * @param evt_buf: pointer to event buffer
18564 * @param stats_param: Pointer to hold stats count
18565 *
18566 * Return: QDF_STATUS_SUCCESS for success or error code
18567 */
18568static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18569 void *evt_buf, wmi_host_stats_event *stats_param)
18570{
Govind Singhe7f2f342016-05-23 12:12:52 +053018571 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018572 wmi_per_chain_rssi_stats *rssi_event;
18573 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018574
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018575 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018576 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018577 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018578 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018579 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018580 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018581 return QDF_STATUS_E_FAILURE;
18582 }
18583
18584 switch (ev->stats_id) {
18585 case WMI_REQUEST_PEER_STAT:
18586 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18587 break;
18588
18589 case WMI_REQUEST_AP_STAT:
18590 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18591 break;
18592
18593 case WMI_REQUEST_PDEV_STAT:
18594 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18595 break;
18596
18597 case WMI_REQUEST_VDEV_STAT:
18598 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18599 break;
18600
18601 case WMI_REQUEST_BCNFLT_STAT:
18602 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18603 break;
18604
18605 case WMI_REQUEST_VDEV_RATE_STAT:
18606 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18607 break;
18608
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018609 case WMI_REQUEST_BCN_STAT:
18610 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18611 break;
18612
Govind Singhe7f2f342016-05-23 12:12:52 +053018613 default:
18614 stats_param->stats_id = 0;
18615 break;
18616
18617 }
18618
18619 stats_param->num_pdev_stats = ev->num_pdev_stats;
18620 stats_param->num_pdev_ext_stats = 0;
18621 stats_param->num_vdev_stats = ev->num_vdev_stats;
18622 stats_param->num_peer_stats = ev->num_peer_stats;
18623 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18624 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018625 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018626 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18627 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018628
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018629 /* if chain_stats is not populated */
18630 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18631 return QDF_STATUS_SUCCESS;
18632
18633 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18634 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18635 return QDF_STATUS_SUCCESS;
18636
18637 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018638 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018639 return QDF_STATUS_SUCCESS;
18640
18641 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18642
Govind Singhe7f2f342016-05-23 12:12:52 +053018643 return QDF_STATUS_SUCCESS;
18644}
18645
18646/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018647 * extract_pdev_tx_stats() - extract pdev tx stats from event
18648 */
18649static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18650{
18651 /* Tx Stats */
18652 tx->comp_queued = tx_stats->comp_queued;
18653 tx->comp_delivered = tx_stats->comp_delivered;
18654 tx->msdu_enqued = tx_stats->msdu_enqued;
18655 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18656 tx->wmm_drop = tx_stats->wmm_drop;
18657 tx->local_enqued = tx_stats->local_enqued;
18658 tx->local_freed = tx_stats->local_freed;
18659 tx->hw_queued = tx_stats->hw_queued;
18660 tx->hw_reaped = tx_stats->hw_reaped;
18661 tx->underrun = tx_stats->underrun;
18662 tx->tx_abort = tx_stats->tx_abort;
18663 tx->mpdus_requed = tx_stats->mpdus_requed;
18664 tx->data_rc = tx_stats->data_rc;
18665 tx->self_triggers = tx_stats->self_triggers;
18666 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18667 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18668 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18669 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18670 tx->pdev_resets = tx_stats->pdev_resets;
18671 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18672 tx->phy_underrun = tx_stats->phy_underrun;
18673 tx->txop_ovf = tx_stats->txop_ovf;
18674
18675 return;
18676}
18677
18678
18679/**
18680 * extract_pdev_rx_stats() - extract pdev rx stats from event
18681 */
18682static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18683{
18684 /* Rx Stats */
18685 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18686 rx->status_rcvd = rx_stats->status_rcvd;
18687 rx->r0_frags = rx_stats->r0_frags;
18688 rx->r1_frags = rx_stats->r1_frags;
18689 rx->r2_frags = rx_stats->r2_frags;
18690 /* Only TLV */
18691 rx->r3_frags = 0;
18692 rx->htt_msdus = rx_stats->htt_msdus;
18693 rx->htt_mpdus = rx_stats->htt_mpdus;
18694 rx->loc_msdus = rx_stats->loc_msdus;
18695 rx->loc_mpdus = rx_stats->loc_mpdus;
18696 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18697 rx->phy_errs = rx_stats->phy_errs;
18698 rx->phy_err_drop = rx_stats->phy_err_drop;
18699 rx->mpdu_errs = rx_stats->mpdu_errs;
18700
18701 return;
18702}
18703
18704/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018705 * extract_pdev_stats_tlv() - extract pdev stats from event
18706 * @wmi_handle: wmi handle
18707 * @param evt_buf: pointer to event buffer
18708 * @param index: Index into pdev stats
18709 * @param pdev_stats: Pointer to hold pdev stats
18710 *
18711 * Return: QDF_STATUS_SUCCESS for success or error code
18712 */
18713static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18714 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18715{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018716 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18717 wmi_stats_event_fixed_param *ev_param;
18718 uint8_t *data;
18719
18720 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18721 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18722
18723 data = param_buf->data;
18724
18725 if (index < ev_param->num_pdev_stats) {
18726 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18727 (index * sizeof(wmi_pdev_stats)));
18728
18729 pdev_stats->chan_nf = ev->chan_nf;
18730 pdev_stats->tx_frame_count = ev->tx_frame_count;
18731 pdev_stats->rx_frame_count = ev->rx_frame_count;
18732 pdev_stats->rx_clear_count = ev->rx_clear_count;
18733 pdev_stats->cycle_count = ev->cycle_count;
18734 pdev_stats->phy_err_count = ev->phy_err_count;
18735 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18736
18737 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18738 &(ev->pdev_stats.tx));
18739 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18740 &(ev->pdev_stats.rx));
18741 }
18742
Govind Singhe7f2f342016-05-23 12:12:52 +053018743 return QDF_STATUS_SUCCESS;
18744}
18745
18746/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018747 * extract_unit_test_tlv() - extract unit test data
18748 * @wmi_handle: wmi handle
18749 * @param evt_buf: pointer to event buffer
18750 * @param unit_test: pointer to hold unit test data
18751 * @param maxspace: Amount of space in evt_buf
18752 *
18753 * Return: QDF_STATUS_SUCCESS for success or error code
18754 */
18755static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18756 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18757{
18758 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18759 wmi_unit_test_event_fixed_param *ev_param;
18760 uint32_t num_bufp;
18761 uint32_t copy_size;
18762 uint8_t *bufp;
18763
18764 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18765 ev_param = param_buf->fixed_param;
18766 bufp = param_buf->bufp;
18767 num_bufp = param_buf->num_bufp;
18768 unit_test->vdev_id = ev_param->vdev_id;
18769 unit_test->module_id = ev_param->module_id;
18770 unit_test->diag_token = ev_param->diag_token;
18771 unit_test->flag = ev_param->flag;
18772 unit_test->payload_len = ev_param->payload_len;
18773 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18774 ev_param->vdev_id,
18775 ev_param->module_id,
18776 ev_param->diag_token,
18777 ev_param->flag);
18778 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18779 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18780 bufp, num_bufp);
18781 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18782 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18783 unit_test->buffer_len = copy_size;
18784
18785 return QDF_STATUS_SUCCESS;
18786}
18787
18788/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018789 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18790 * @wmi_handle: wmi handle
18791 * @param evt_buf: pointer to event buffer
18792 * @param index: Index into extended pdev stats
18793 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18794 *
18795 * Return: QDF_STATUS_SUCCESS for success or error code
18796 */
18797static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18798 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18799{
18800 return QDF_STATUS_SUCCESS;
18801}
18802
18803/**
18804 * extract_vdev_stats_tlv() - extract vdev stats from event
18805 * @wmi_handle: wmi handle
18806 * @param evt_buf: pointer to event buffer
18807 * @param index: Index into vdev stats
18808 * @param vdev_stats: Pointer to hold vdev stats
18809 *
18810 * Return: QDF_STATUS_SUCCESS for success or error code
18811 */
18812static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18813 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18814{
18815 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18816 wmi_stats_event_fixed_param *ev_param;
18817 uint8_t *data;
18818
18819 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18820 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18821 data = (uint8_t *) param_buf->data;
18822
18823 if (index < ev_param->num_vdev_stats) {
18824 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18825 ((ev_param->num_pdev_stats) *
18826 sizeof(wmi_pdev_stats)) +
18827 (index * sizeof(wmi_vdev_stats)));
18828
18829 vdev_stats->vdev_id = ev->vdev_id;
18830 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18831 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18832
18833 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18834 sizeof(ev->tx_frm_cnt));
18835 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18836 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18837 ev->multiple_retry_cnt,
18838 sizeof(ev->multiple_retry_cnt));
18839 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18840 sizeof(ev->fail_cnt));
18841 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18842 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18843 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18844 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18845 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18846 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18847 sizeof(ev->tx_rate_history));
18848 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18849 sizeof(ev->bcn_rssi_history));
18850
18851 }
18852
18853 return QDF_STATUS_SUCCESS;
18854}
18855
18856/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018857 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18858 * buffer
18859 * @wmi_handle: wmi handle
18860 * @evt_buf: pointer to event buffer
18861 * @index: Index into vdev stats
18862 * @rssi_stats: Pointer to hold rssi stats
18863 *
18864 * Return: QDF_STATUS_SUCCESS for success or error code
18865 */
18866static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18867 void *evt_buf, uint32_t index,
18868 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18869{
18870 uint8_t *data;
18871 wmi_rssi_stats *fw_rssi_stats;
18872 wmi_per_chain_rssi_stats *rssi_event;
18873 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18874
18875 if (!evt_buf) {
18876 WMI_LOGE("evt_buf is null");
18877 return QDF_STATUS_E_NULL_VALUE;
18878 }
18879
18880 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18881 rssi_event = param_buf->chain_stats;
18882
18883 if (index >= rssi_event->num_per_chain_rssi_stats) {
18884 WMI_LOGE("invalid index");
18885 return QDF_STATUS_E_INVAL;
18886 }
18887
18888 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18889 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18890
18891 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18892 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18893 fw_rssi_stats->rssi_avg_beacon,
18894 sizeof(fw_rssi_stats->rssi_avg_beacon));
18895 qdf_mem_copy(rssi_stats->rssi_avg_data,
18896 fw_rssi_stats->rssi_avg_data,
18897 sizeof(fw_rssi_stats->rssi_avg_data));
18898 qdf_mem_copy(&rssi_stats->peer_macaddr,
18899 &fw_rssi_stats->peer_macaddr,
18900 sizeof(fw_rssi_stats->peer_macaddr));
18901
18902 return QDF_STATUS_SUCCESS;
18903}
18904
18905
18906
18907/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018908 * extract_bcn_stats_tlv() - extract bcn stats from event
18909 * @wmi_handle: wmi handle
18910 * @param evt_buf: pointer to event buffer
18911 * @param index: Index into vdev stats
18912 * @param bcn_stats: Pointer to hold bcn stats
18913 *
18914 * Return: QDF_STATUS_SUCCESS for success or error code
18915 */
18916static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18917 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18918{
18919 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18920 wmi_stats_event_fixed_param *ev_param;
18921 uint8_t *data;
18922
18923 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18924 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18925 data = (uint8_t *) param_buf->data;
18926
18927 if (index < ev_param->num_bcn_stats) {
18928 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18929 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18930 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18931 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18932 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18933 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18934 (index * sizeof(wmi_bcn_stats)));
18935
18936 bcn_stats->vdev_id = ev->vdev_id;
18937 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18938 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18939 }
18940
18941 return QDF_STATUS_SUCCESS;
18942}
18943
18944/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018945 * extract_peer_stats_tlv() - extract peer stats from event
18946 * @wmi_handle: wmi handle
18947 * @param evt_buf: pointer to event buffer
18948 * @param index: Index into peer stats
18949 * @param peer_stats: Pointer to hold peer stats
18950 *
18951 * Return: QDF_STATUS_SUCCESS for success or error code
18952 */
18953static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
18954 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
18955{
18956 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18957 wmi_stats_event_fixed_param *ev_param;
18958 uint8_t *data;
18959
18960 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18961 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18962 data = (uint8_t *) param_buf->data;
18963
18964 if (index < ev_param->num_peer_stats) {
18965 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
18966 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18967 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18968 (index * sizeof(wmi_peer_stats)));
18969
18970 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
18971
18972 OS_MEMCPY(&(peer_stats->peer_macaddr),
18973 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
18974
18975 peer_stats->peer_rssi = ev->peer_rssi;
18976 peer_stats->peer_tx_rate = ev->peer_tx_rate;
18977 peer_stats->peer_rx_rate = ev->peer_rx_rate;
18978 }
18979
18980 return QDF_STATUS_SUCCESS;
18981}
18982
18983/**
18984 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
18985 * @wmi_handle: wmi handle
18986 * @param evt_buf: pointer to event buffer
18987 * @param index: Index into bcn fault stats
18988 * @param bcnflt_stats: Pointer to hold bcn fault stats
18989 *
18990 * Return: QDF_STATUS_SUCCESS for success or error code
18991 */
18992static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
18993 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
18994{
18995 return QDF_STATUS_SUCCESS;
18996}
18997
18998/**
18999 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19000 * @wmi_handle: wmi handle
19001 * @param evt_buf: pointer to event buffer
19002 * @param index: Index into extended peer stats
19003 * @param peer_extd_stats: Pointer to hold extended peer stats
19004 *
19005 * Return: QDF_STATUS_SUCCESS for success or error code
19006 */
19007static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19008 void *evt_buf, uint32_t index,
19009 wmi_host_peer_extd_stats *peer_extd_stats)
19010{
19011 return QDF_STATUS_SUCCESS;
19012}
19013
19014/**
19015 * extract_chan_stats_tlv() - extract chan stats from event
19016 * @wmi_handle: wmi handle
19017 * @param evt_buf: pointer to event buffer
19018 * @param index: Index into chan stats
19019 * @param vdev_extd_stats: Pointer to hold chan stats
19020 *
19021 * Return: QDF_STATUS_SUCCESS for success or error code
19022 */
19023static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19024 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19025{
19026 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19027 wmi_stats_event_fixed_param *ev_param;
19028 uint8_t *data;
19029
19030 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19031 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19032 data = (uint8_t *) param_buf->data;
19033
19034 if (index < ev_param->num_chan_stats) {
19035 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19036 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19037 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19038 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19039 (index * sizeof(wmi_chan_stats)));
19040
19041
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019042 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019043 chan_stats->chan_mhz = ev->chan_mhz;
19044 chan_stats->sampling_period_us = ev->sampling_period_us;
19045 chan_stats->rx_clear_count = ev->rx_clear_count;
19046 chan_stats->tx_duration_us = ev->tx_duration_us;
19047 chan_stats->rx_duration_us = ev->rx_duration_us;
19048 }
19049
19050 return QDF_STATUS_SUCCESS;
19051}
19052
19053/**
19054 * extract_profile_ctx_tlv() - extract profile context from event
19055 * @wmi_handle: wmi handle
19056 * @param evt_buf: pointer to event buffer
19057 * @idx: profile stats index to extract
19058 * @param profile_ctx: Pointer to hold profile context
19059 *
19060 * Return: QDF_STATUS_SUCCESS for success or error code
19061 */
19062static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19063 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19064{
19065 return QDF_STATUS_SUCCESS;
19066}
19067
19068/**
19069 * extract_profile_data_tlv() - extract profile data from event
19070 * @wmi_handle: wmi handle
19071 * @param evt_buf: pointer to event buffer
19072 * @param profile_data: Pointer to hold profile data
19073 *
19074 * Return: QDF_STATUS_SUCCESS for success or error code
19075 */
19076static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19077 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19078{
19079
19080 return QDF_STATUS_SUCCESS;
19081}
19082
19083/**
19084 * extract_chan_info_event_tlv() - extract chan information from event
19085 * @wmi_handle: wmi handle
19086 * @param evt_buf: pointer to event buffer
19087 * @param chan_info: Pointer to hold chan information
19088 *
19089 * Return: QDF_STATUS_SUCCESS for success or error code
19090 */
19091static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19092 void *evt_buf, wmi_host_chan_info_event *chan_info)
19093{
19094 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19095 wmi_chan_info_event_fixed_param *ev;
19096
19097 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19098
19099 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19100 if (!ev) {
19101 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19102 return QDF_STATUS_E_FAILURE;
19103 }
19104
19105 chan_info->err_code = ev->err_code;
19106 chan_info->freq = ev->freq;
19107 chan_info->cmd_flags = ev->cmd_flags;
19108 chan_info->noise_floor = ev->noise_floor;
19109 chan_info->rx_clear_count = ev->rx_clear_count;
19110 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019111 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19112 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019113 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19114 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19115 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019116 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19117 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19118 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19119 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19120 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19121 chan_info->rx_frame_count = ev->rx_frame_count;
19122 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19123 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019124
19125 return QDF_STATUS_SUCCESS;
19126}
19127
19128/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019129 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19130 * @wmi_handle: WMI handle
19131 * @param evt_buf: Pointer to event buffer
19132 * @param param: Pointer to hold data
19133 *
19134 * Return : QDF_STATUS_SUCCESS for success or error code
19135 */
19136static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19137 uint8_t *evt_buf,
19138 struct wmi_host_pdev_utf_event *event)
19139{
19140 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019141 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019142
19143 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19144 event->data = param_buf->data;
19145 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019146 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019147 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019148 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019149 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019150
19151 return QDF_STATUS_SUCCESS;
19152}
Govind Singhe7f2f342016-05-23 12:12:52 +053019153
Kiran Venkatappa06520822016-08-10 23:55:40 +053019154/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019155 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19156 * @wmi_handle: wmi handle
19157 * @param evt_buf: pointer to event buffer
19158 * @param param: Pointer to hold evt buf
19159 *
19160 * Return: QDF_STATUS_SUCCESS for success or error code
19161 */
19162static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19163 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19164{
19165 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19166 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19167 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19168 uint8_t i = 0, j = 0;
19169
19170 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19171 if (!param_buf)
19172 return QDF_STATUS_E_INVAL;
19173
19174 hw_caps = param_buf->soc_hw_mode_caps;
19175 if (!hw_caps)
19176 return QDF_STATUS_E_INVAL;
19177
19178 if (!hw_caps->num_chainmask_tables)
19179 return QDF_STATUS_E_INVAL;
19180
19181 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19182
19183 if (chainmask_caps == NULL)
19184 return QDF_STATUS_E_INVAL;
19185
19186 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19187
19188 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19189 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19190
19191 chainmask_table[i].cap_list[j].chainmask =
19192 chainmask_caps->chainmask;
19193
19194 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19195 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19196
19197 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19198 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19199
19200 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19201 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19202
19203 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19204 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19205
19206 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19207 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19208
19209 chainmask_table[i].cap_list[j].chain_mask_2G =
19210 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19211
19212 chainmask_table[i].cap_list[j].chain_mask_5G =
19213 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19214
19215 chainmask_table[i].cap_list[j].chain_mask_tx =
19216 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19217
19218 chainmask_table[i].cap_list[j].chain_mask_rx =
19219 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19220
19221 chainmask_table[i].cap_list[j].supports_aDFS =
19222 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19223
19224 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19225 chainmask_caps->supported_flags,
19226 chainmask_caps->chainmask
19227 );
19228 chainmask_caps++;
19229 }
19230 }
19231
19232 return QDF_STATUS_SUCCESS;
19233}
19234
19235/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019236 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19237 * from event
19238 * @wmi_handle: wmi handle
19239 * @param evt_buf: pointer to event buffer
19240 * @param param: Pointer to hold evt buf
19241 *
19242 * Return: QDF_STATUS_SUCCESS for success or error code
19243 */
19244static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019245 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019246{
19247 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19248 wmi_service_ready_ext_event_fixed_param *ev;
19249 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19250 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019251 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19252 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019253
19254 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19255 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019256 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019257
19258 ev = param_buf->fixed_param;
19259 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019260 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019261
19262 /* Move this to host based bitmap */
19263 param->default_conc_scan_config_bits =
19264 ev->default_conc_scan_config_bits;
19265 param->default_fw_config_bits = ev->default_fw_config_bits;
19266 param->he_cap_info = ev->he_cap_info;
19267 param->mpdu_density = ev->mpdu_density;
19268 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019269 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019270 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019271 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19272
19273 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019274 if (hw_caps)
19275 param->num_hw_modes = hw_caps->num_hw_modes;
19276 else
19277 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019278
19279 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019280 if (reg_caps)
19281 param->num_phy = reg_caps->num_phy;
19282 else
19283 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019284
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019285 if (hw_caps) {
19286 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19287 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19288 } else
19289 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019290
19291 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19292
19293 if (chain_mask_combo == NULL)
19294 return QDF_STATUS_SUCCESS;
19295
19296 qdf_print("Dumping chain mask combo data\n");
19297
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019298 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019299
19300 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19301 chain_mask_combo->chainmask_table_id,
19302 chain_mask_combo->num_valid_chainmask
19303 );
19304
19305 param->chainmask_table[i].table_id =
19306 chain_mask_combo->chainmask_table_id;
19307 param->chainmask_table[i].num_valid_chainmasks =
19308 chain_mask_combo->num_valid_chainmask;
19309 chain_mask_combo++;
19310 }
19311 qdf_print("chain mask combo end\n");
19312
Kiran Venkatappa06520822016-08-10 23:55:40 +053019313 return QDF_STATUS_SUCCESS;
19314}
19315
19316/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019317 * extract_sar_cap_service_ready_ext_tlv() -
19318 * extract SAR cap from service ready event
19319 * @wmi_handle: wmi handle
19320 * @event: pointer to event buffer
19321 * @ext_param: extended target info
19322 *
19323 * Return: QDF_STATUS_SUCCESS for success or error code
19324 */
19325static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19326 wmi_unified_t wmi_handle,
19327 uint8_t *event,
19328 struct wlan_psoc_host_service_ext_param *ext_param)
19329{
19330 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19331 WMI_SAR_CAPABILITIES *sar_caps;
19332
19333 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19334
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019335 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019336 return QDF_STATUS_E_INVAL;
19337
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019338 sar_caps = param_buf->sar_caps;
19339 if (sar_caps)
19340 ext_param->sar_version = sar_caps->active_version;
19341 else
19342 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019343
19344 return QDF_STATUS_SUCCESS;
19345}
19346
19347/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019348 * extract_hw_mode_cap_service_ready_ext_tlv() -
19349 * extract HW mode cap from service ready event
19350 * @wmi_handle: wmi handle
19351 * @param evt_buf: pointer to event buffer
19352 * @param param: Pointer to hold evt buf
19353 * @param hw_mode_idx: hw mode idx should be less than num_mode
19354 *
19355 * Return: QDF_STATUS_SUCCESS for success or error code
19356 */
19357static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19358 wmi_unified_t wmi_handle,
19359 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019360 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019361{
19362 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19363 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19364
19365 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19366 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019367 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019368
19369 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019370 if (!hw_caps)
19371 return QDF_STATUS_E_INVAL;
19372
Kiran Venkatappa06520822016-08-10 23:55:40 +053019373 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019374 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019375
19376 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19377 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19378
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019379 param->hw_mode_config_type =
19380 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19381
Kiran Venkatappa06520822016-08-10 23:55:40 +053019382 return QDF_STATUS_SUCCESS;
19383}
19384
19385/**
19386 * extract_mac_phy_cap_service_ready_ext_tlv() -
19387 * extract MAC phy cap from service ready event
19388 * @wmi_handle: wmi handle
19389 * @param evt_buf: pointer to event buffer
19390 * @param param: Pointer to hold evt buf
19391 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019392 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019393 *
19394 * Return: QDF_STATUS_SUCCESS for success or error code
19395 */
19396static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19397 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019398 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019399 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019400{
19401 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019402 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019403 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19404 uint32_t phy_map;
19405 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019406
19407 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19408 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019409 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019410
19411 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019412 if (!hw_caps)
19413 return QDF_STATUS_E_INVAL;
19414
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019415 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19416 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19417 break;
19418
19419 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19420 while (phy_map) {
19421 phy_map >>= 1;
19422 phy_idx++;
19423 }
19424 }
19425
19426 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019427 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019428
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019429 phy_idx += phy_id;
19430 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019431 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019432
19433 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019434
19435 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019436 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19437 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019438 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019439 param->supports_11b =
19440 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19441 param->supports_11g =
19442 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19443 param->supports_11a =
19444 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19445 param->supports_11n =
19446 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19447 param->supports_11ac =
19448 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19449 param->supports_11ax =
19450 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019451
19452 param->supported_bands = mac_phy_caps->supported_bands;
19453 param->ampdu_density = mac_phy_caps->ampdu_density;
19454 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19455 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19456 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19457 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19458 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19459 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19460 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19461 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19462 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19463 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19464 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19465 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19466 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19467 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19468 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19469 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019470 qdf_mem_copy(&param->he_cap_phy_info_2G,
19471 &mac_phy_caps->he_cap_phy_info_2G,
19472 sizeof(param->he_cap_phy_info_2G));
19473 qdf_mem_copy(&param->he_cap_phy_info_5G,
19474 &mac_phy_caps->he_cap_phy_info_5G,
19475 sizeof(param->he_cap_phy_info_5G));
19476 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19477 sizeof(param->he_ppet2G));
19478 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19479 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019480 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019481
19482 return QDF_STATUS_SUCCESS;
19483}
19484
19485/**
19486 * extract_reg_cap_service_ready_ext_tlv() -
19487 * extract REG cap from service ready event
19488 * @wmi_handle: wmi handle
19489 * @param evt_buf: pointer to event buffer
19490 * @param param: Pointer to hold evt buf
19491 * @param phy_idx: phy idx should be less than num_mode
19492 *
19493 * Return: QDF_STATUS_SUCCESS for success or error code
19494 */
19495static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19496 wmi_unified_t wmi_handle,
19497 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019498 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019499{
19500 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19501 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19502 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19503
19504 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19505 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019506 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019507
19508 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019509 if (!reg_caps)
19510 return QDF_STATUS_E_INVAL;
19511
Kiran Venkatappa06520822016-08-10 23:55:40 +053019512 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019513 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019514
19515 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19516
19517 param->phy_id = ext_reg_cap->phy_id;
19518 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19519 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19520 param->regcap1 = ext_reg_cap->regcap1;
19521 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019522 param->wireless_modes = convert_wireless_modes_tlv(
19523 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019524 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19525 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19526 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19527 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19528
19529 return QDF_STATUS_SUCCESS;
19530}
19531
Sathish Kumarf396c722017-11-17 17:30:41 +053019532static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19533 wmi_unified_t wmi_handle,
19534 uint8_t *event, uint8_t idx,
19535 struct wlan_psoc_host_dbr_ring_caps *param)
19536{
19537 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19538 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19539
19540 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19541 if (!param_buf)
19542 return QDF_STATUS_E_INVAL;
19543
19544 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19545
19546 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19547 dbr_ring_caps->pdev_id);
19548 param->mod_id = dbr_ring_caps->mod_id;
19549 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19550 param->min_buf_size = dbr_ring_caps->min_buf_size;
19551 param->min_buf_align = dbr_ring_caps->min_buf_align;
19552
19553 return QDF_STATUS_SUCCESS;
19554}
19555
19556static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19557 uint8_t *event, struct direct_buf_rx_rsp *param)
19558{
19559 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19560 wmi_dma_buf_release_fixed_param *ev;
19561
19562 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19563 if (!param_buf)
19564 return QDF_STATUS_E_INVAL;
19565
19566 ev = param_buf->fixed_param;
19567 if (!ev)
19568 return QDF_STATUS_E_INVAL;
19569
19570 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19571 ev->pdev_id);
19572 param->mod_id = ev->mod_id;
19573 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019574 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019575 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19576 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19577
19578 return QDF_STATUS_SUCCESS;
19579}
19580
19581static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19582 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19583{
19584 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19585 wmi_dma_buf_release_entry *entry;
19586
19587 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19588 if (!param_buf)
19589 return QDF_STATUS_E_INVAL;
19590
19591 entry = &param_buf->entries[idx];
19592
19593 if (!entry) {
19594 WMI_LOGE("%s: Entry is NULL\n", __func__);
19595 return QDF_STATUS_E_FAILURE;
19596 }
19597
19598 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19599
19600 param->paddr_lo = entry->paddr_lo;
19601 param->paddr_hi = entry->paddr_hi;
19602
19603 return QDF_STATUS_SUCCESS;
19604}
19605
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019606static QDF_STATUS extract_dbr_buf_metadata_tlv(
19607 wmi_unified_t wmi_handle, uint8_t *event,
19608 uint8_t idx, struct direct_buf_rx_metadata *param)
19609{
19610 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19611 wmi_dma_buf_release_spectral_meta_data *entry;
19612
19613 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19614 if (!param_buf)
19615 return QDF_STATUS_E_INVAL;
19616
19617 entry = &param_buf->meta_data[idx];
19618
19619 if (!entry) {
19620 WMI_LOGE("%s: Entry is NULL\n", __func__);
19621 return QDF_STATUS_E_FAILURE;
19622 }
19623
19624 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19625 sizeof(entry->noise_floor));
19626 return QDF_STATUS_SUCCESS;
19627}
19628
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019629/**
19630 * extract_dcs_interference_type_tlv() - extract dcs interference type
19631 * from event
19632 * @wmi_handle: wmi handle
19633 * @param evt_buf: pointer to event buffer
19634 * @param param: Pointer to hold dcs interference param
19635 *
19636 * Return: 0 for success or error code
19637 */
19638static QDF_STATUS extract_dcs_interference_type_tlv(
19639 wmi_unified_t wmi_handle,
19640 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19641{
19642 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19643
19644 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19645 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019646 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019647
19648 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019649 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19650 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019651
19652 return QDF_STATUS_SUCCESS;
19653}
19654
19655/*
19656 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19657 * @wmi_handle: wmi handle
19658 * @param evt_buf: pointer to event buffer
19659 * @param cw_int: Pointer to hold cw interference
19660 *
19661 * Return: 0 for success or error code
19662 */
19663static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19664 void *evt_buf,
19665 wmi_host_ath_dcs_cw_int *cw_int)
19666{
19667 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19668 wlan_dcs_cw_int *ev;
19669
19670 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19671 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019672 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019673
19674 ev = param_buf->cw_int;
19675
19676 cw_int->channel = ev->channel;
19677
19678 return QDF_STATUS_SUCCESS;
19679}
19680
19681/**
19682 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19683 * @wmi_handle: wmi handle
19684 * @param evt_buf: pointer to event buffer
19685 * @param wlan_stat: Pointer to hold wlan stats
19686 *
19687 * Return: 0 for success or error code
19688 */
19689static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19690 void *evt_buf,
19691 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19692{
19693 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19694 wlan_dcs_im_tgt_stats_t *ev;
19695
19696 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19697 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019698 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019699
19700 ev = param_buf->wlan_stat;
19701 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19702 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19703 wlan_stat->tx_waste_time = ev->tx_waste_time;
19704 wlan_stat->rx_time = ev->rx_time;
19705 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19706 wlan_stat->mib_stats.listen_time = ev->listen_time;
19707 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19708 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19709 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19710 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19711 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19712 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19713 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19714 wlan_stat->chan_nf = ev->chan_nf;
19715 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19716
19717 return QDF_STATUS_SUCCESS;
19718}
19719
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019720/**
19721 * extract_thermal_stats_tlv() - extract thermal stats from event
19722 * @wmi_handle: wmi handle
19723 * @param evt_buf: Pointer to event buffer
19724 * @param temp: Pointer to hold extracted temperature
19725 * @param level: Pointer to hold extracted level
19726 *
19727 * Return: 0 for success or error code
19728 */
19729static QDF_STATUS
19730extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19731 void *evt_buf, uint32_t *temp,
19732 uint32_t *level, uint32_t *pdev_id)
19733{
19734 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19735 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19736
19737 param_buf =
19738 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19739 if (!param_buf)
19740 return QDF_STATUS_E_INVAL;
19741
19742 tt_stats_event = param_buf->fixed_param;
19743
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019744 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19745 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019746 *temp = tt_stats_event->temp;
19747 *level = tt_stats_event->level;
19748
19749 return QDF_STATUS_SUCCESS;
19750}
19751
19752/**
19753 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19754 * @wmi_handle: wmi handle
19755 * @param evt_buf: pointer to event buffer
19756 * @param idx: Index to level stats
19757 * @param levelcount: Pointer to hold levelcount
19758 * @param dccount: Pointer to hold dccount
19759 *
19760 * Return: 0 for success or error code
19761 */
19762static QDF_STATUS
19763extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19764 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19765 uint32_t *dccount)
19766{
19767 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19768 wmi_therm_throt_level_stats_info *tt_level_info;
19769
19770 param_buf =
19771 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19772 if (!param_buf)
19773 return QDF_STATUS_E_INVAL;
19774
19775 tt_level_info = param_buf->therm_throt_level_stats_info;
19776
19777 if (idx < THERMAL_LEVELS) {
19778 *levelcount = tt_level_info[idx].level_count;
19779 *dccount = tt_level_info[idx].dc_count;
19780 return QDF_STATUS_SUCCESS;
19781 }
19782
19783 return QDF_STATUS_E_FAILURE;
19784}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019785#ifdef BIG_ENDIAN_HOST
19786/**
19787 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19788 * @param data_len - data length
19789 * @param data - pointer to data
19790 *
19791 * Return: QDF_STATUS - success or error status
19792 */
19793static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19794{
19795 uint8_t *data_aligned = NULL;
19796 int c;
19797 unsigned char *data_unaligned;
19798
19799 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19800 FIPS_ALIGN));
19801 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019802 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019803 if (data_unaligned == NULL)
19804 return QDF_STATUS_E_FAILURE;
19805
19806 /* Checking if space is alligned */
19807 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19808 /* align the data space */
19809 data_aligned =
19810 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19811 } else {
19812 data_aligned = (u_int8_t *)data_unaligned;
19813 }
19814
19815 /* memset and copy content from data to data aligned */
19816 OS_MEMSET(data_aligned, 0, data_len);
19817 OS_MEMCPY(data_aligned, data, data_len);
19818 /* Endianness to LE */
19819 for (c = 0; c < data_len/4; c++) {
19820 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019821 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019822 }
19823
19824 /* Copy content to event->data */
19825 OS_MEMCPY(data, data_aligned, data_len);
19826
19827 /* clean up allocated space */
19828 qdf_mem_free(data_unaligned);
19829 data_aligned = NULL;
19830 data_unaligned = NULL;
19831
19832 /*************************************************************/
19833
19834 return QDF_STATUS_SUCCESS;
19835}
19836#else
19837/**
19838 * fips_conv_data_be() - DUMMY for LE platform
19839 *
19840 * Return: QDF_STATUS - success
19841 */
19842static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19843{
19844 return QDF_STATUS_SUCCESS;
19845}
19846#endif
19847
19848/**
19849 * extract_fips_event_data_tlv() - extract fips event data
19850 * @wmi_handle: wmi handle
19851 * @param evt_buf: pointer to event buffer
19852 * @param param: pointer FIPS event params
19853 *
19854 * Return: 0 for success or error code
19855 */
19856static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19857 void *evt_buf, struct wmi_host_fips_event_param *param)
19858{
19859 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19860 wmi_pdev_fips_event_fixed_param *event;
19861
19862 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19863 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19864
19865 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19866 QDF_STATUS_SUCCESS)
19867 return QDF_STATUS_E_FAILURE;
19868
19869 param->data = (uint32_t *)param_buf->data;
19870 param->data_len = event->data_len;
19871 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019872 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19873 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019874
19875 return QDF_STATUS_SUCCESS;
19876}
19877
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019878/*
19879 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19880 * @wmi_handle: wmi handle
19881 * @param evt_buf: pointer to event buffer
19882 * @param vdev_id: Pointer to hold vdev_id
19883 * @param mac_addr: Pointer to hold peer mac address
19884 *
19885 * Return: QDF_STATUS_SUCCESS for success or error code
19886 */
19887static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19888 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19889{
19890 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19891 wmi_peer_delete_resp_event_fixed_param *ev;
19892
19893 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19894
19895 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19896 if (!ev) {
19897 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19898 return QDF_STATUS_E_FAILURE;
19899 }
19900
19901 param->vdev_id = ev->vdev_id;
19902 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19903 &param->mac_address.bytes[0]);
19904
19905 return QDF_STATUS_SUCCESS;
19906}
19907
Govind Singhecf03cd2016-05-12 12:45:51 +053019908static bool is_management_record_tlv(uint32_t cmd_id)
19909{
jiad36c94d22018-01-22 15:37:03 +080019910 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19911 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19912 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019913 return true;
jiad36c94d22018-01-22 15:37:03 +080019914 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019915
Govind Singhecf03cd2016-05-12 12:45:51 +053019916 return false;
19917}
19918
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019919static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19920{
19921 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19922
19923 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19924
19925 switch (set_cmd->param_id) {
19926 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19927 case WMI_VDEV_PARAM_DTIM_POLICY:
19928 return HTC_TX_PACKET_TAG_AUTO_PM;
19929 default:
19930 break;
19931 }
19932
19933 return 0;
19934}
19935
19936static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19937{
19938 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19939
19940 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19941
19942 switch (ps_cmd->param) {
19943 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19944 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19945 case WMI_STA_PS_ENABLE_QPOWER:
19946 return HTC_TX_PACKET_TAG_AUTO_PM;
19947 default:
19948 break;
19949 }
19950
19951 return 0;
19952}
19953
19954static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
19955 uint32_t cmd_id)
19956{
19957 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
19958 return 0;
19959
19960 switch (cmd_id) {
19961 case WMI_VDEV_SET_PARAM_CMDID:
19962 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
19963 case WMI_STA_POWERSAVE_PARAM_CMDID:
19964 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
19965 default:
19966 break;
19967 }
19968
19969 return 0;
19970}
19971
19972static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
19973{
19974 uint16_t tag = 0;
19975
19976 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
19977 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
19978 __func__);
19979 return tag;
19980 }
19981
19982 if (wmi_handle->tag_crash_inject)
19983 tag = HTC_TX_PACKET_TAG_AUTO_PM;
19984
19985 wmi_handle->tag_crash_inject = false;
19986 return tag;
19987}
19988
19989/**
19990 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
19991 * @wmi_handle: WMI handle
19992 * @buf: WMI buffer
19993 * @cmd_id: WMI command Id
19994 *
19995 * Return htc_tx_tag
19996 */
19997static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
19998 wmi_buf_t buf,
19999 uint32_t cmd_id)
20000{
20001 uint16_t htc_tx_tag = 0;
20002
20003 switch (cmd_id) {
20004 case WMI_WOW_ENABLE_CMDID:
20005 case WMI_PDEV_SUSPEND_CMDID:
20006 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20007 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20008 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20009 case WMI_PDEV_RESUME_CMDID:
20010 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20011 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20012#ifdef FEATURE_WLAN_D0WOW
20013 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20014#endif
20015 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20016 break;
20017 case WMI_FORCE_FW_HANG_CMDID:
20018 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20019 break;
20020 case WMI_VDEV_SET_PARAM_CMDID:
20021 case WMI_STA_POWERSAVE_PARAM_CMDID:
20022 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20023 default:
20024 break;
20025 }
20026
20027 return htc_tx_tag;
20028}
20029
Sathish Kumard3ab1002017-02-07 17:10:59 +053020030/**
20031 * extract_channel_hopping_event_tlv() - extract channel hopping param
20032 * from event
20033 * @wmi_handle: wmi handle
20034 * @param evt_buf: pointer to event buffer
20035 * @param ch_hopping: Pointer to hold channel hopping param
20036 *
20037 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20038 */
20039static QDF_STATUS extract_channel_hopping_event_tlv(
20040 wmi_unified_t wmi_handle, void *evt_buf,
20041 wmi_host_pdev_channel_hopping_event *ch_hopping)
20042{
20043 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20044 wmi_pdev_channel_hopping_event_fixed_param *event;
20045
20046 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20047 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20048 param_buf->fixed_param;
20049
20050 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20051 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020052 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20053 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020054
20055 return QDF_STATUS_SUCCESS;
20056}
20057
20058/**
20059 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20060 * @wmi_handle: wmi handle
20061 * @param evt_buf: pointer to event buffer
20062 * @param param: Pointer to hold tpc param
20063 *
20064 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20065 */
20066static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20067 void *evt_buf,
20068 wmi_host_pdev_tpc_event *param)
20069{
20070 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20071 wmi_pdev_tpc_event_fixed_param *event;
20072
20073 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20074 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20075
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020076 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20077 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020078 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20079
20080 return QDF_STATUS_SUCCESS;
20081}
20082
nobeljf74583b2018-01-25 16:35:36 -080020083/**
20084 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20085 * power param from event
20086 * @wmi_handle: wmi handle
20087 * @param evt_buf: pointer to event buffer
20088 * @param param: Pointer to hold nf cal power param
20089 *
20090 * Return: 0 for success or error code
20091 */
20092static QDF_STATUS
20093extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20094 void *evt_buf,
20095 wmi_host_pdev_nfcal_power_all_channels_event *param)
20096{
20097 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20098 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20099 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20100 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20101 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20102 uint32_t i;
20103
20104 param_buf =
20105 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20106 event = param_buf->fixed_param;
20107 ch_nfdbr = param_buf->nfdbr;
20108 ch_nfdbm = param_buf->nfdbm;
20109 ch_freqnum = param_buf->freqnum;
20110
20111 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20112 event->pdev_id, param_buf->num_nfdbr,
20113 param_buf->num_nfdbm, param_buf->num_freqnum);
20114
20115 if (param_buf->num_nfdbr >
20116 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20117 WMI_LOGE("invalid number of nfdBr");
20118 return QDF_STATUS_E_FAILURE;
20119 }
20120
20121 if (param_buf->num_nfdbm >
20122 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20123 WMI_LOGE("invalid number of nfdBm");
20124 return QDF_STATUS_E_FAILURE;
20125 }
20126
20127 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20128 WMI_LOGE("invalid number of freqNum");
20129 return QDF_STATUS_E_FAILURE;
20130 }
20131
20132 for (i = 0; i < param_buf->num_nfdbr; i++) {
20133 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20134 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20135 ch_nfdbr++;
20136 ch_nfdbm++;
20137 }
20138
20139 for (i = 0; i < param_buf->num_freqnum; i++) {
20140 param->freqnum[i] = ch_freqnum->freqNum;
20141 ch_freqnum++;
20142 }
20143
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020144 param->pdev_id = wmi_handle->ops->
20145 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020146
20147 return QDF_STATUS_SUCCESS;
20148}
20149
Sathish Kumard3ab1002017-02-07 17:10:59 +053020150
20151#ifdef BIG_ENDIAN_HOST
20152/**
20153 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20154 * @param data_len - data length
20155 * @param data - pointer to data
20156 *
20157 * Return: QDF_STATUS - success or error status
20158 */
20159static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20160{
20161 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020162 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020163 /* Skip swapping the first word */
20164 datap += sizeof(uint32_t);
20165 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20166 i++, datap += sizeof(uint32_t)) {
20167 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20168 }
20169
20170 return QDF_STATUS_SUCCESS;
20171}
20172#else
20173/**
20174 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20175 * @param data_len - data length
20176 * @param data - pointer to data
20177 *
20178 * Return: QDF_STATUS - success or error status
20179 */
20180static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20181{
20182 return QDF_STATUS_SUCCESS;
20183}
20184#endif
20185
20186/**
20187 * extract_wds_addr_event_tlv() - extract wds address from event
20188 * @wmi_handle: wmi handle
20189 * @param evt_buf: pointer to event buffer
20190 * @param wds_ev: Pointer to hold wds address
20191 *
20192 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20193 */
20194static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20195 void *evt_buf,
20196 uint16_t len, wds_addr_event_t *wds_ev)
20197{
20198 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20199 wmi_wds_addr_event_fixed_param *ev;
20200 int i;
20201
20202 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20203 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20204
20205 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20206 return QDF_STATUS_E_FAILURE;
20207
20208 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20209 sizeof(wds_ev->event_type));
20210 for (i = 0; i < 4; i++) {
20211 wds_ev->peer_mac[i] =
20212 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20213 wds_ev->dest_mac[i] =
20214 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20215 }
20216 for (i = 0; i < 2; i++) {
20217 wds_ev->peer_mac[4+i] =
20218 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20219 wds_ev->dest_mac[4+i] =
20220 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20221 }
20222 return QDF_STATUS_SUCCESS;
20223}
20224
20225/**
20226 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20227 * from event
20228 * @wmi_handle: wmi handle
20229 * @param evt_buf: pointer to event buffer
20230 * @param ev: Pointer to hold peer param and ps state
20231 *
20232 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20233 */
20234static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20235 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20236{
20237 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20238 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20239
20240 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20241 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20242 param_buf->fixed_param;
20243
20244 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20245 ev->peer_ps_state = event->peer_ps_state;
20246
20247 return QDF_STATUS_SUCCESS;
20248}
20249
20250/**
20251 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20252 * @wmi_handle: wmi handle
20253 * @param evt_buf: pointer to event buffer
20254 * @param inst_rssi_resp: Pointer to hold inst rssi response
20255 *
20256 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20257 */
20258static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20259 wmi_unified_t wmi_handle, void *evt_buf,
20260 wmi_host_inst_stats_resp *inst_rssi_resp)
20261{
20262 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20263 wmi_inst_rssi_stats_resp_fixed_param *event;
20264
20265 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20266 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20267
20268 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20269 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20270 inst_rssi_resp->iRSSI = event->iRSSI;
20271
20272 return QDF_STATUS_SUCCESS;
20273}
20274
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020275static struct cur_reg_rule
20276*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20277 wmi_regulatory_rule_struct *wmi_reg_rule)
20278{
20279 struct cur_reg_rule *reg_rule_ptr;
20280 uint32_t count;
20281
20282 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20283
20284 if (NULL == reg_rule_ptr) {
20285 WMI_LOGE("memory allocation failure");
20286 return NULL;
20287 }
20288
20289 for (count = 0; count < num_reg_rules; count++) {
20290 reg_rule_ptr[count].start_freq =
20291 WMI_REG_RULE_START_FREQ_GET(
20292 wmi_reg_rule[count].freq_info);
20293 reg_rule_ptr[count].end_freq =
20294 WMI_REG_RULE_END_FREQ_GET(
20295 wmi_reg_rule[count].freq_info);
20296 reg_rule_ptr[count].max_bw =
20297 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020298 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020299 reg_rule_ptr[count].reg_power =
20300 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020301 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020302 reg_rule_ptr[count].ant_gain =
20303 WMI_REG_RULE_ANTENNA_GAIN_GET(
20304 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020305 reg_rule_ptr[count].flags =
20306 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020307 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020308 }
20309
20310 return reg_rule_ptr;
20311}
20312
20313static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20314 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20315 struct cur_regulatory_info *reg_info, uint32_t len)
20316{
20317 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20318 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20319 wmi_regulatory_rule_struct *wmi_reg_rule;
20320 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20321
20322 WMI_LOGD("processing regulatory channel list");
20323
20324 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20325 if (!param_buf) {
20326 WMI_LOGE("invalid channel list event buf");
20327 return QDF_STATUS_E_FAILURE;
20328 }
20329
20330 chan_list_event_hdr = param_buf->fixed_param;
20331
20332 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20333 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20334 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020335 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020336 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20337 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020338 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020339 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020340 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020341 reg_info->ctry_code = chan_list_event_hdr->country_id;
20342 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20343 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20344 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20345 else if (chan_list_event_hdr->status_code ==
20346 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20347 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20348 else if (chan_list_event_hdr->status_code ==
20349 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20350 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20351 else if (chan_list_event_hdr->status_code ==
20352 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20353 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20354 else if (chan_list_event_hdr->status_code ==
20355 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20356 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20357 else if (chan_list_event_hdr->status_code ==
20358 WMI_REG_SET_CC_STATUS_FAIL)
20359 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20360
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020361 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20362 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20363 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20364 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20365
20366 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20367 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20368
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020369 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20370 __func__, reg_info->alpha2, reg_info->dfs_region,
20371 reg_info->min_bw_2g, reg_info->max_bw_2g,
20372 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020373
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020374 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20375 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020376 wmi_reg_rule =
20377 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20378 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20379 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020380 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20381 wmi_reg_rule);
20382 wmi_reg_rule += num_2g_reg_rules;
20383
20384 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20385 wmi_reg_rule);
20386
20387 WMI_LOGD("processed regulatory channel list");
20388
20389 return QDF_STATUS_SUCCESS;
20390}
20391
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020392static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20393 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20394 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20395{
20396 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20397 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20398
20399 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20400 if (!param_buf) {
20401 WMI_LOGE("invalid 11d country event buf");
20402 return QDF_STATUS_E_FAILURE;
20403 }
20404
20405 reg_11d_country_event = param_buf->fixed_param;
20406
20407 qdf_mem_copy(reg_11d_country->alpha2,
20408 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20409
20410 WMI_LOGD("processed 11d country event, new cc %s",
20411 reg_11d_country->alpha2);
20412
20413 return QDF_STATUS_SUCCESS;
20414}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020415
20416static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20417 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20418 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20419{
20420 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20421 wmi_avoid_freq_range_desc *afr_desc;
20422 uint32_t num_freq_ranges, freq_range_idx;
20423 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20424 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20425
20426 if (!param_buf) {
20427 WMI_LOGE("Invalid channel avoid event buffer");
20428 return QDF_STATUS_E_INVAL;
20429 }
20430
20431 afr_fixed_param = param_buf->fixed_param;
20432 if (!afr_fixed_param) {
20433 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20434 return QDF_STATUS_E_INVAL;
20435 }
20436
20437 if (!ch_avoid_ind) {
20438 WMI_LOGE("Invalid channel avoid indication buffer");
20439 return QDF_STATUS_E_INVAL;
20440 }
20441 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20442 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20443 afr_fixed_param->num_freq_ranges;
20444
20445 WMI_LOGD("Channel avoid event received with %d ranges",
20446 num_freq_ranges);
20447
20448 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20449 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20450 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20451 freq_range_idx++) {
20452 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20453 afr_desc->start_freq;
20454 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20455 afr_desc->end_freq;
20456 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20457 freq_range_idx, afr_desc->tlv_header,
20458 afr_desc->start_freq, afr_desc->end_freq);
20459 afr_desc++;
20460 }
20461
20462 return QDF_STATUS_SUCCESS;
20463}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020464#ifdef DFS_COMPONENT_ENABLE
20465/**
20466 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20467 * @wmi_handle: wma handle
20468 * @evt_buf: event buffer
20469 * @vdev_id: vdev id
20470 * @len: length of buffer
20471 *
20472 * Return: 0 for success or error code
20473 */
20474static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20475 uint8_t *evt_buf,
20476 uint32_t *vdev_id,
20477 uint32_t len)
20478{
20479 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20480 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20481
20482 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20483 if (!param_tlvs) {
20484 WMI_LOGE("invalid cac complete event buf");
20485 return QDF_STATUS_E_FAILURE;
20486 }
20487
20488 cac_event = param_tlvs->fixed_param;
20489 *vdev_id = cac_event->vdev_id;
20490 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20491
20492 return QDF_STATUS_SUCCESS;
20493}
20494
20495/**
20496 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20497 * @wmi_handle: wma handle
20498 * @evt_buf: event buffer
20499 * @radar_found: radar found event info
20500 * @len: length of buffer
20501 *
20502 * Return: 0 for success or error code
20503 */
20504static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20505 wmi_unified_t wmi_handle,
20506 uint8_t *evt_buf,
20507 struct radar_found_info *radar_found,
20508 uint32_t len)
20509{
20510 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20511 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20512
20513 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20514 if (!param_tlv) {
20515 WMI_LOGE("invalid radar detection event buf");
20516 return QDF_STATUS_E_FAILURE;
20517 }
20518
20519 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020520 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20521 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020522 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020523 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020524 radar_found->chan_width = radar_event->chan_width;
20525 radar_found->detector_id = radar_event->detector_id;
20526 radar_found->segment_id = radar_event->segment_id;
20527 radar_found->timestamp = radar_event->timestamp;
20528 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020529 radar_found->freq_offset = radar_event->freq_offset;
20530 radar_found->sidx = radar_event->sidx;
20531
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020532 WMI_LOGI("processed radar found event pdev %d,"
20533 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20534 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20535 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20536 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020537 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020538 radar_event->timestamp, radar_event->chan_freq,
20539 radar_event->chan_width, radar_event->detector_id,
20540 radar_event->freq_offset, radar_event->segment_id,
20541 radar_event->sidx, radar_event->is_chirp,
20542 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020543
20544 return QDF_STATUS_SUCCESS;
20545}
bings1ea12532017-12-18 16:56:53 +080020546
20547#ifdef QCA_MCL_DFS_SUPPORT
20548/**
20549 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20550 * @wmi_handle: wma handle
20551 * @evt_buf: event buffer
20552 * @wlan_radar_event: Pointer to struct radar_event_info
20553 * @len: length of buffer
20554 *
20555 * Return: QDF_STATUS
20556 */
20557static QDF_STATUS extract_wlan_radar_event_info_tlv(
20558 wmi_unified_t wmi_handle,
20559 uint8_t *evt_buf,
20560 struct radar_event_info *wlan_radar_event,
20561 uint32_t len)
20562{
20563 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20564 wmi_dfs_radar_event_fixed_param *radar_event;
20565
20566 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20567 if (!param_tlv) {
20568 WMI_LOGE("invalid wlan radar event buf");
20569 return QDF_STATUS_E_FAILURE;
20570 }
20571
20572 radar_event = param_tlv->fixed_param;
20573 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20574 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20575 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20576 wlan_radar_event->rssi = radar_event->rssi;
20577 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20578 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20579 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20580 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020581 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20582 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020583 if (radar_event->pulse_flags &
20584 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20585 wlan_radar_event->is_psidx_diff_valid = true;
20586 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20587 } else {
20588 wlan_radar_event->is_psidx_diff_valid = false;
20589 }
20590
bings1ea12532017-12-18 16:56:53 +080020591 wlan_radar_event->pdev_id = radar_event->pdev_id;
20592
20593 return QDF_STATUS_SUCCESS;
20594}
20595#else
20596static QDF_STATUS extract_wlan_radar_event_info_tlv(
20597 wmi_unified_t wmi_handle,
20598 uint8_t *evt_buf,
20599 struct radar_event_info *wlan_radar_event,
20600 uint32_t len)
20601{
20602 return QDF_STATUS_SUCCESS;
20603}
20604#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020605#endif
20606
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020607/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020608 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20609 * @wmi_handle: wmi handle
20610 * @get_rcpi_param: rcpi params
20611 *
20612 * Return: QDF status
20613 */
20614static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20615 struct rcpi_req *get_rcpi_param)
20616{
20617 wmi_buf_t buf;
20618 wmi_request_rcpi_cmd_fixed_param *cmd;
20619 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20620
20621 buf = wmi_buf_alloc(wmi_handle, len);
20622 if (!buf) {
20623 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20624 return QDF_STATUS_E_NOMEM;
20625 }
20626
20627 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20628 WMITLV_SET_HDR(&cmd->tlv_header,
20629 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20630 WMITLV_GET_STRUCT_TLVLEN
20631 (wmi_request_rcpi_cmd_fixed_param));
20632
20633 cmd->vdev_id = get_rcpi_param->vdev_id;
20634 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20635 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020636
20637 switch (get_rcpi_param->measurement_type) {
20638
20639 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20640 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20641 break;
20642
20643 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20644 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20645 break;
20646
20647 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20648 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20649 break;
20650
20651 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20652 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20653 break;
20654
20655 default:
20656 /*
20657 * invalid rcpi measurement type, fall back to
20658 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20659 */
20660 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20661 break;
20662 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020663 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20664 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20665 WMI_REQUEST_RCPI_CMDID)) {
20666
20667 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20668 __func__);
20669 wmi_buf_free(buf);
20670 return QDF_STATUS_E_FAILURE;
20671 }
20672
20673 return QDF_STATUS_SUCCESS;
20674}
20675
20676/**
20677 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20678 * @wmi_handle: wmi handle
20679 * @evt_buf: pointer to event buffer
20680 * @res: pointer to hold rcpi response from firmware
20681 *
20682 * Return: QDF_STATUS_SUCCESS for successful event parse
20683 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20684 */
20685static QDF_STATUS
20686extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20687 void *evt_buf, struct rcpi_res *res)
20688{
20689 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20690 wmi_update_rcpi_event_fixed_param *event;
20691
20692 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20693 if (!param_buf) {
20694 WMI_LOGE(FL("Invalid rcpi event"));
20695 return QDF_STATUS_E_INVAL;
20696 }
20697
20698 event = param_buf->fixed_param;
20699 res->vdev_id = event->vdev_id;
20700 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20701
20702 switch (event->measurement_type) {
20703
20704 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20705 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20706 break;
20707
20708 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20709 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20710 break;
20711
20712 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20713 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20714 break;
20715
20716 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20717 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20718 break;
20719
20720 default:
20721 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20722 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20723 return QDF_STATUS_E_FAILURE;
20724 }
20725
20726 if (event->status)
20727 return QDF_STATUS_E_FAILURE;
20728 else
20729 return QDF_STATUS_SUCCESS;
20730}
20731
20732/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020733 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20734 * host to target defines. For legacy there is not conversion
20735 * required. Just return pdev_id as it is.
20736 * @param pdev_id: host pdev_id to be converted.
20737 * Return: target pdev_id after conversion.
20738 */
20739static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20740 uint32_t pdev_id)
20741{
20742 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20743 return WMI_PDEV_ID_SOC;
20744
20745 /*No conversion required*/
20746 return pdev_id;
20747}
20748
20749/**
20750 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20751 * target to host defines. For legacy there is not conversion
20752 * required. Just return pdev_id as it is.
20753 * @param pdev_id: target pdev_id to be converted.
20754 * Return: host pdev_id after conversion.
20755 */
20756static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20757 uint32_t pdev_id)
20758{
20759 /*No conversion required*/
20760 return pdev_id;
20761}
20762
20763/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020764 * send_set_country_cmd_tlv() - WMI scan channel list function
20765 * @param wmi_handle : handle to WMI.
20766 * @param param : pointer to hold scan channel list parameter
20767 *
20768 * Return: 0 on success and -ve on failure.
20769 */
20770static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20771 struct set_country *params)
20772{
20773 wmi_buf_t buf;
20774 QDF_STATUS qdf_status;
20775 wmi_set_current_country_cmd_fixed_param *cmd;
20776 uint16_t len = sizeof(*cmd);
20777
20778 buf = wmi_buf_alloc(wmi_handle, len);
20779 if (!buf) {
20780 WMI_LOGE("Failed to allocate memory");
20781 qdf_status = QDF_STATUS_E_NOMEM;
20782 goto end;
20783 }
20784
20785 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20786 WMITLV_SET_HDR(&cmd->tlv_header,
20787 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20788 WMITLV_GET_STRUCT_TLVLEN
20789 (wmi_set_current_country_cmd_fixed_param));
20790
20791 WMI_LOGD("setting cuurnet country to %s", params->country);
20792
20793 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20794
20795 cmd->pdev_id = params->pdev_id;
20796
20797 qdf_status = wmi_unified_cmd_send(wmi_handle,
20798 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20799
20800 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20801 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20802 wmi_buf_free(buf);
20803 }
20804
20805end:
20806 return qdf_status;
20807}
20808
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020809#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20810 WMI_SET_BITS(alpha, 0, 8, val0); \
20811 WMI_SET_BITS(alpha, 8, 8, val1); \
20812 WMI_SET_BITS(alpha, 16, 8, val2); \
20813 } while (0)
20814
20815static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20816 uint8_t pdev_id, struct cc_regdmn_s *rd)
20817{
20818 wmi_set_init_country_cmd_fixed_param *cmd;
20819 uint16_t len;
20820 wmi_buf_t buf;
20821 int ret;
20822
20823 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20824 buf = wmi_buf_alloc(wmi_handle, len);
20825 if (!buf) {
20826 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20827 return QDF_STATUS_E_NOMEM;
20828 }
20829 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20830 WMITLV_SET_HDR(&cmd->tlv_header,
20831 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20832 WMITLV_GET_STRUCT_TLVLEN
20833 (wmi_set_init_country_cmd_fixed_param));
20834
20835 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20836
20837 if (rd->flags == CC_IS_SET) {
20838 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20839 cmd->country_code.country_id = rd->cc.country_code;
20840 } else if (rd->flags == ALPHA_IS_SET) {
20841 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20842 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20843 rd->cc.alpha[0],
20844 rd->cc.alpha[1],
20845 rd->cc.alpha[2]);
20846 } else if (rd->flags == REGDMN_IS_SET) {
20847 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20848 cmd->country_code.domain_code = rd->cc.regdmn_id;
20849 }
20850
20851 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20852 WMI_SET_INIT_COUNTRY_CMDID);
20853 if (ret) {
20854 WMI_LOGE("Failed to config wow wakeup event");
20855 wmi_buf_free(buf);
20856 return QDF_STATUS_E_FAILURE;
20857 }
20858
20859 return QDF_STATUS_SUCCESS;
20860}
20861
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020862/**
20863 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20864 * configuration params
20865 * @wmi_handle: wmi handler
20866 * @limit_off_chan_param: pointer to wmi_off_chan_param
20867 *
20868 * Return: 0 for success and non zero for failure
20869 */
20870static
20871QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20872 struct wmi_limit_off_chan_param *limit_off_chan_param)
20873{
20874 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20875 wmi_buf_t buf;
20876 uint32_t len = sizeof(*cmd);
20877 int err;
20878
20879 buf = wmi_buf_alloc(wmi_handle, len);
20880 if (!buf) {
20881 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20882 __func__);
20883 return QDF_STATUS_E_NOMEM;
20884 }
20885
20886 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20887
20888 WMITLV_SET_HDR(&cmd->tlv_header,
20889 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20890 WMITLV_GET_STRUCT_TLVLEN(
20891 wmi_vdev_limit_offchan_cmd_fixed_param));
20892
20893 cmd->vdev_id = limit_off_chan_param->vdev_id;
20894
20895 cmd->flags &= 0;
20896 if (limit_off_chan_param->status)
20897 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20898 if (limit_off_chan_param->skip_dfs_chans)
20899 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20900
20901 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20902 cmd->rest_time = limit_off_chan_param->rest_time;
20903
20904 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20905 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20906 cmd->rest_time);
20907
20908 err = wmi_unified_cmd_send(wmi_handle, buf,
20909 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20910 if (QDF_IS_STATUS_ERROR(err)) {
20911 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20912 wmi_buf_free(buf);
20913 return QDF_STATUS_E_FAILURE;
20914 }
20915
20916 return QDF_STATUS_SUCCESS;
20917}
20918
Anurag Chouhan97f00422017-09-11 14:56:30 +053020919/**
20920 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20921 * @wmi_handle: wmi handler
20922 * @req_buf: set arp stats request buffer
20923 *
20924 * Return: 0 for success and non zero for failure
20925 */
20926static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20927 struct set_arp_stats *req_buf)
20928{
20929 wmi_buf_t buf = NULL;
20930 QDF_STATUS status;
20931 int len;
20932 uint8_t *buf_ptr;
20933 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20934
20935 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020936 if (req_buf->pkt_type_bitmap) {
20937 len += WMI_TLV_HDR_SIZE;
20938 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20939 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020940 buf = wmi_buf_alloc(wmi_handle, len);
20941 if (!buf) {
20942 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20943 return QDF_STATUS_E_NOMEM;
20944 }
20945
20946 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20947 wmi_set_arp =
20948 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20949 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20950 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20951 WMITLV_GET_STRUCT_TLVLEN
20952 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20953
20954 /* fill in per roam config values */
20955 wmi_set_arp->vdev_id = req_buf->vdev_id;
20956
20957 wmi_set_arp->set_clr = req_buf->flag;
20958 wmi_set_arp->pkt_type = req_buf->pkt_type;
20959 wmi_set_arp->ipv4 = req_buf->ip_addr;
20960
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020961 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
20962 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
20963 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
20964
20965 /*
20966 * pkt_type_bitmap should be non-zero to ensure
20967 * presence of additional stats.
20968 */
20969 if (req_buf->pkt_type_bitmap) {
20970 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
20971
20972 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20973 WMITLV_SET_HDR(buf_ptr,
20974 WMITLV_TAG_ARRAY_STRUC,
20975 sizeof(wmi_vdev_set_connectivity_check_stats));
20976 buf_ptr += WMI_TLV_HDR_SIZE;
20977 wmi_set_connect_stats =
20978 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
20979 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
20980 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
20981 WMITLV_GET_STRUCT_TLVLEN(
20982 wmi_vdev_set_connectivity_check_stats));
20983 wmi_set_connect_stats->pkt_type_bitmap =
20984 req_buf->pkt_type_bitmap;
20985 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
20986 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
20987 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
20988
20989 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
20990 wmi_set_connect_stats->pkt_type_bitmap,
20991 wmi_set_connect_stats->tcp_src_port,
20992 wmi_set_connect_stats->tcp_dst_port,
20993 wmi_set_connect_stats->icmp_ipv4);
20994 }
20995
Anurag Chouhan97f00422017-09-11 14:56:30 +053020996 /* Send per roam config parameters */
20997 status = wmi_unified_cmd_send(wmi_handle, buf,
20998 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20999 if (QDF_IS_STATUS_ERROR(status)) {
21000 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21001 status);
21002 goto error;
21003 }
21004
21005 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21006 req_buf->flag, req_buf->vdev_id);
21007 return QDF_STATUS_SUCCESS;
21008error:
21009 wmi_buf_free(buf);
21010
21011 return status;
21012}
21013
21014/**
21015 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21016 * @wmi_handle: wmi handler
21017 * @req_buf: get arp stats request buffer
21018 *
21019 * Return: 0 for success and non zero for failure
21020 */
21021static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21022 struct get_arp_stats *req_buf)
21023{
21024 wmi_buf_t buf = NULL;
21025 QDF_STATUS status;
21026 int len;
21027 uint8_t *buf_ptr;
21028 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21029
21030 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21031 buf = wmi_buf_alloc(wmi_handle, len);
21032 if (!buf) {
21033 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21034 return QDF_STATUS_E_NOMEM;
21035 }
21036
21037 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21038 get_arp_stats =
21039 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21040 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21041 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21042 WMITLV_GET_STRUCT_TLVLEN
21043 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21044
21045 /* fill in arp stats req cmd values */
21046 get_arp_stats->vdev_id = req_buf->vdev_id;
21047
21048 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21049 /* Send per roam config parameters */
21050 status = wmi_unified_cmd_send(wmi_handle, buf,
21051 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21052 if (QDF_IS_STATUS_ERROR(status)) {
21053 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21054 status);
21055 goto error;
21056 }
21057
21058 return QDF_STATUS_SUCCESS;
21059error:
21060 wmi_buf_free(buf);
21061
21062 return status;
21063}
21064
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021065/**
21066 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21067 * @wmi_handle: wmi handler
21068 * @pmk_info: pointer to PMK cache entry
21069 * @vdev_id: vdev id
21070 *
21071 * Return: 0 for success and non zero for failure
21072 */
21073static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21074 struct wmi_unified_pmk_cache *pmk_info)
21075{
21076 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21077 wmi_buf_t buf;
21078 QDF_STATUS status;
21079 uint8_t *buf_ptr;
21080 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021081 uint32_t len = sizeof(*cmd);
21082
21083 if (pmk_info->pmk_len)
21084 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021085
21086 buf = wmi_buf_alloc(wmi_handle, len);
21087 if (!buf) {
21088 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21089 __func__);
21090 return QDF_STATUS_E_NOMEM;
21091 }
21092
21093 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21094 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21095
21096 WMITLV_SET_HDR(&cmd->tlv_header,
21097 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21098 WMITLV_GET_STRUCT_TLVLEN(
21099 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21100
21101 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021102
21103 /* If pmk_info->pmk_len is 0, this is a flush request */
21104 if (!pmk_info->pmk_len) {
21105 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21106 cmd->num_cache = 0;
21107 goto send_cmd;
21108 }
21109
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021110 cmd->num_cache = 1;
21111 buf_ptr += sizeof(*cmd);
21112
21113 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21114 sizeof(*pmksa));
21115 buf_ptr += WMI_TLV_HDR_SIZE;
21116
21117 pmksa = (wmi_pmk_cache *)buf_ptr;
21118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21119 WMITLV_GET_STRUCT_TLVLEN
21120 (wmi_pmk_cache));
21121 pmksa->pmk_len = pmk_info->pmk_len;
21122 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21123 pmksa->pmkid_len = pmk_info->pmkid_len;
21124 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21125 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21126 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21127 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21128 pmksa->ssid.ssid_len);
21129 pmksa->cache_id = pmk_info->cache_id;
21130 pmksa->cat_flag = pmk_info->cat_flag;
21131 pmksa->action_flag = pmk_info->action_flag;
21132
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021133send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021134 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21135 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21136 if (status != QDF_STATUS_SUCCESS) {
21137 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21138 __func__, status);
21139 wmi_buf_free(buf);
21140 }
21141
21142 return status;
21143}
21144
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021145/**
21146 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21147 * @wmi_handle: wmi handle
21148 * @param: reserved param
21149 *
21150 * Return: 0 for success or error code
21151 */
21152static QDF_STATUS
21153send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21154 uint32_t param)
21155{
21156 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21157 wmi_buf_t buf;
21158 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21159
21160 buf = wmi_buf_alloc(wmi_handle, len);
21161 if (!buf) {
21162 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21163 return QDF_STATUS_E_FAILURE;
21164 }
21165 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21166 WMITLV_SET_HDR(&cmd->tlv_header,
21167 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21168 WMITLV_GET_STRUCT_TLVLEN
21169 (wmi_pdev_check_cal_version_cmd_fixed_param));
21170 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21171 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21172 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21173 wmi_buf_free(buf);
21174 return QDF_STATUS_E_FAILURE;
21175 }
21176
21177 return QDF_STATUS_SUCCESS;
21178}
21179
21180/**
21181 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21182 * @wmi_handle: wmi handle
21183 * @param evt_buf: pointer to event buffer
21184 * @param param: Pointer to hold peer caldata version data
21185 *
21186 * Return: 0 for success or error code
21187 */
21188static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21189 wmi_unified_t wmi_handle,
21190 void *evt_buf,
21191 wmi_host_pdev_check_cal_version_event *param)
21192{
21193 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21194 wmi_pdev_check_cal_version_event_fixed_param *event;
21195
21196 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21197 if (!param_tlvs) {
21198 WMI_LOGE("invalid cal version event buf");
21199 return QDF_STATUS_E_FAILURE;
21200 }
21201 event = param_tlvs->fixed_param;
21202 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21203 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21204 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21205 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21206
21207 param->software_cal_version = event->software_cal_version;
21208 param->board_cal_version = event->board_cal_version;
21209 param->cal_ok = event->cal_status;
21210
21211 return QDF_STATUS_SUCCESS;
21212}
21213
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021214/*
21215 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21216 * @wmi_handle: wmi handle
21217 * @params: pointer to wmi_btm_config
21218 *
21219 * Return: QDF_STATUS
21220 */
21221static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21222 struct wmi_btm_config *params)
21223{
21224
21225 wmi_btm_config_fixed_param *cmd;
21226 wmi_buf_t buf;
21227 uint32_t len;
21228
21229 len = sizeof(*cmd);
21230 buf = wmi_buf_alloc(wmi_handle, len);
21231 if (!buf) {
21232 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21233 return QDF_STATUS_E_NOMEM;
21234 }
21235
21236 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21237 WMITLV_SET_HDR(&cmd->tlv_header,
21238 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21239 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21240 cmd->vdev_id = params->vdev_id;
21241 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021242 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21243 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21244 cmd->stick_time_seconds = params->btm_sticky_time;
21245
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021246 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21247 WMI_ROAM_BTM_CONFIG_CMDID)) {
21248 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21249 __func__);
21250 wmi_buf_free(buf);
21251 return QDF_STATUS_E_FAILURE;
21252 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021253
21254 return QDF_STATUS_SUCCESS;
21255}
21256
21257/**
21258 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21259 * configurations to firmware.
21260 * @wmi_handle: wmi handle
21261 * @obss_cfg_param: obss detection configurations
21262 *
21263 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21264 *
21265 * Return: QDF_STATUS
21266 */
21267static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21268 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21269{
21270 wmi_buf_t buf;
21271 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21272 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21273
21274 buf = wmi_buf_alloc(wmi_handle, len);
21275 if (!buf) {
21276 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21277 return QDF_STATUS_E_NOMEM;
21278 }
21279
21280 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21281 WMITLV_SET_HDR(&cmd->tlv_header,
21282 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21283 WMITLV_GET_STRUCT_TLVLEN
21284 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21285
21286 cmd->vdev_id = obss_cfg_param->vdev_id;
21287 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21288 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21289 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21290 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21291 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21292 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21293 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21294 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021295
21296 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21297 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21298 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21299 wmi_buf_free(buf);
21300 return QDF_STATUS_E_FAILURE;
21301 }
21302
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021303 return QDF_STATUS_SUCCESS;
21304}
21305
Arif Hussain33d98502018-01-12 13:15:04 -080021306/**
21307 * extract_obss_detection_info_tlv() - Extract obss detection info
21308 * received from firmware.
21309 * @evt_buf: pointer to event buffer
21310 * @obss_detection: Pointer to hold obss detection info
21311 *
21312 * Return: QDF_STATUS
21313 */
21314static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21315 struct wmi_obss_detect_info
21316 *obss_detection)
21317{
21318 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21319 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21320
21321 if (!obss_detection) {
21322 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21323 return QDF_STATUS_E_INVAL;
21324 }
21325
21326 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21327 if (!param_buf) {
21328 WMI_LOGE("%s: Invalid evt_buf", __func__);
21329 return QDF_STATUS_E_INVAL;
21330 }
21331
21332 fix_param = param_buf->fixed_param;
21333 obss_detection->vdev_id = fix_param->vdev_id;
21334 obss_detection->matched_detection_masks =
21335 fix_param->matched_detection_masks;
21336 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21337 &obss_detection->matched_bssid_addr[0]);
21338 switch (fix_param->reason) {
21339 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21340 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21341 break;
21342 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21343 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21344 break;
21345 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21346 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21347 break;
21348 default:
21349 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21350 return QDF_STATUS_E_INVAL;
21351 }
21352
21353 return QDF_STATUS_SUCCESS;
21354}
21355
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021356/**
21357 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21358 * @wmi_handle: wmi handler
21359 * @params: pointer to 11k offload params
21360 *
21361 * Return: 0 for success and non zero for failure
21362 */
21363static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21364 struct wmi_11k_offload_params *params)
21365{
21366 wmi_11k_offload_report_fixed_param *cmd;
21367 wmi_buf_t buf;
21368 QDF_STATUS status;
21369 uint8_t *buf_ptr;
21370 wmi_neighbor_report_11k_offload_tlv_param
21371 *neighbor_report_offload_params;
21372 wmi_neighbor_report_offload *neighbor_report_offload;
21373
21374 uint32_t len = sizeof(*cmd);
21375
21376 if (params->offload_11k_bitmask &
21377 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21378 len += WMI_TLV_HDR_SIZE +
21379 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21380
21381 buf = wmi_buf_alloc(wmi_handle, len);
21382 if (!buf) {
21383 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21384 __func__);
21385 return QDF_STATUS_E_NOMEM;
21386 }
21387
21388 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21389 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21390
21391 WMITLV_SET_HDR(&cmd->tlv_header,
21392 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21393 WMITLV_GET_STRUCT_TLVLEN(
21394 wmi_11k_offload_report_fixed_param));
21395
21396 cmd->vdev_id = params->vdev_id;
21397 cmd->offload_11k = params->offload_11k_bitmask;
21398
21399 if (params->offload_11k_bitmask &
21400 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21401 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21402
21403 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21404 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21405 buf_ptr += WMI_TLV_HDR_SIZE;
21406
21407 neighbor_report_offload_params =
21408 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21409 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21410 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21411 WMITLV_GET_STRUCT_TLVLEN(
21412 wmi_neighbor_report_11k_offload_tlv_param));
21413
21414 neighbor_report_offload = &neighbor_report_offload_params->
21415 neighbor_rep_ofld_params;
21416
21417 neighbor_report_offload->time_offset =
21418 params->neighbor_report_params.time_offset;
21419 neighbor_report_offload->low_rssi_offset =
21420 params->neighbor_report_params.low_rssi_offset;
21421 neighbor_report_offload->bmiss_count_trigger =
21422 params->neighbor_report_params.bmiss_count_trigger;
21423 neighbor_report_offload->per_threshold_offset =
21424 params->neighbor_report_params.per_threshold_offset;
21425 neighbor_report_offload->neighbor_report_cache_timeout =
21426 params->neighbor_report_params.
21427 neighbor_report_cache_timeout;
21428 neighbor_report_offload->max_neighbor_report_req_cap =
21429 params->neighbor_report_params.
21430 max_neighbor_report_req_cap;
21431 neighbor_report_offload->ssid.ssid_len =
21432 params->neighbor_report_params.ssid.length;
21433 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21434 &params->neighbor_report_params.ssid.mac_ssid,
21435 neighbor_report_offload->ssid.ssid_len);
21436 }
21437
21438 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21439 WMI_11K_OFFLOAD_REPORT_CMDID);
21440 if (status != QDF_STATUS_SUCCESS) {
21441 WMI_LOGE("%s: failed to send 11k offload command %d",
21442 __func__, status);
21443 wmi_buf_free(buf);
21444 }
21445
21446 return status;
21447}
21448
21449/**
21450 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21451 * command
21452 * @wmi_handle: wmi handler
21453 * @params: pointer to neighbor report invoke params
21454 *
21455 * Return: 0 for success and non zero for failure
21456 */
21457static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21458 struct wmi_invoke_neighbor_report_params *params)
21459{
21460 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21461 wmi_buf_t buf;
21462 QDF_STATUS status;
21463 uint8_t *buf_ptr;
21464 uint32_t len = sizeof(*cmd);
21465
21466 buf = wmi_buf_alloc(wmi_handle, len);
21467 if (!buf) {
21468 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21469 __func__);
21470 return QDF_STATUS_E_NOMEM;
21471 }
21472
21473 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21474 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21475
21476 WMITLV_SET_HDR(&cmd->tlv_header,
21477 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21478 WMITLV_GET_STRUCT_TLVLEN(
21479 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21480
21481 cmd->vdev_id = params->vdev_id;
21482 cmd->flags = params->send_resp_to_host;
21483
21484 cmd->ssid.ssid_len = params->ssid.length;
21485 qdf_mem_copy(cmd->ssid.ssid,
21486 &params->ssid.mac_ssid,
21487 cmd->ssid.ssid_len);
21488
21489 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21490 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21491 if (status != QDF_STATUS_SUCCESS) {
21492 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21493 __func__, status);
21494 wmi_buf_free(buf);
21495 }
21496
21497 return status;
21498}
21499
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021500#ifdef WLAN_SUPPORT_GREEN_AP
21501static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21502 uint8_t *evt_buf,
21503 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21504{
21505 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21506 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21507 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21508
21509 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21510 if (!param_buf) {
21511 WMI_LOGE("Invalid EGAP Info status event buffer");
21512 return QDF_STATUS_E_INVAL;
21513 }
21514
21515 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21516 param_buf->fixed_param;
21517 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21518 param_buf->chainmask_list;
21519
21520 egap_status_info_params->status = egap_info_event->status;
21521 egap_status_info_params->mac_id = chainmask_event->mac_id;
21522 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21523 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21524
21525 return QDF_STATUS_SUCCESS;
21526}
21527#endif
21528
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021529/*
21530 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21531 * updating bss color change within firmware when AP announces bss color change.
21532 * @wmi_handle: wmi handle
21533 * @vdev_id: vdev ID
21534 * @enable: enable bss color change within firmware
21535 *
21536 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21537 *
21538 * Return: QDF_STATUS
21539 */
21540static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21541 uint32_t vdev_id,
21542 bool enable)
21543{
21544 wmi_buf_t buf;
21545 wmi_bss_color_change_enable_fixed_param *cmd;
21546 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21547
21548 buf = wmi_buf_alloc(wmi_handle, len);
21549 if (!buf) {
21550 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21551 return QDF_STATUS_E_NOMEM;
21552 }
21553
21554 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21555 WMITLV_SET_HDR(&cmd->tlv_header,
21556 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21557 WMITLV_GET_STRUCT_TLVLEN
21558 (wmi_bss_color_change_enable_fixed_param));
21559 cmd->vdev_id = vdev_id;
21560 cmd->enable = enable;
21561 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21562 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21563 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21564 wmi_buf_free(buf);
21565 return QDF_STATUS_E_FAILURE;
21566 }
21567
21568 return QDF_STATUS_SUCCESS;
21569}
21570
21571/**
21572 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21573 * configurations to firmware.
21574 * @wmi_handle: wmi handle
21575 * @cfg_param: obss detection configurations
21576 *
21577 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21578 *
21579 * Return: QDF_STATUS
21580 */
21581static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21582 wmi_unified_t wmi_handle,
21583 struct wmi_obss_color_collision_cfg_param *cfg_param)
21584{
21585 wmi_buf_t buf;
21586 wmi_obss_color_collision_det_config_fixed_param *cmd;
21587 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21588
21589 buf = wmi_buf_alloc(wmi_handle, len);
21590 if (!buf) {
21591 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21592 return QDF_STATUS_E_NOMEM;
21593 }
21594
21595 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21596 buf);
21597 WMITLV_SET_HDR(&cmd->tlv_header,
21598 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21599 WMITLV_GET_STRUCT_TLVLEN
21600 (wmi_obss_color_collision_det_config_fixed_param));
21601 cmd->vdev_id = cfg_param->vdev_id;
21602 cmd->flags = cfg_param->flags;
21603 cmd->current_bss_color = cfg_param->current_bss_color;
21604 cmd->detection_period_ms = cfg_param->detection_period_ms;
21605 cmd->scan_period_ms = cfg_param->scan_period_ms;
21606 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21607
21608 switch (cfg_param->evt_type) {
21609 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21610 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21611 break;
21612 case OBSS_COLOR_COLLISION_DETECTION:
21613 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21614 break;
21615 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21616 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21617 break;
21618 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21619 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21620 break;
21621 default:
21622 WMI_LOGE("%s: invalid event type: %d",
21623 __func__, cfg_param->evt_type);
21624 wmi_buf_free(buf);
21625 return QDF_STATUS_E_FAILURE;
21626 }
21627
21628 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21629 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21630 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21631 __func__, cfg_param->vdev_id);
21632 wmi_buf_free(buf);
21633 return QDF_STATUS_E_FAILURE;
21634 }
21635
21636 return QDF_STATUS_SUCCESS;
21637}
21638
21639/**
21640 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21641 * received from firmware.
21642 * @evt_buf: pointer to event buffer
21643 * @info: Pointer to hold bss collision info
21644 *
21645 * Return: QDF_STATUS
21646 */
21647static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21648 struct wmi_obss_color_collision_info *info)
21649{
21650 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21651 wmi_obss_color_collision_evt_fixed_param *fix_param;
21652
21653 if (!info) {
21654 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21655 return QDF_STATUS_E_INVAL;
21656 }
21657
21658 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21659 evt_buf;
21660 if (!param_buf) {
21661 WMI_LOGE("%s: Invalid evt_buf", __func__);
21662 return QDF_STATUS_E_INVAL;
21663 }
21664
21665 fix_param = param_buf->fixed_param;
21666 info->vdev_id = fix_param->vdev_id;
21667 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21668 info->obss_color_bitmap_bit32to63 =
21669 fix_param->bss_color_bitmap_bit32to63;
21670
21671 switch (fix_param->evt_type) {
21672 case WMI_BSS_COLOR_COLLISION_DISABLE:
21673 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21674 break;
21675 case WMI_BSS_COLOR_COLLISION_DETECTION:
21676 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21677 break;
21678 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21679 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21680 break;
21681 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21682 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21683 break;
21684 default:
21685 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21686 __func__, fix_param->evt_type, fix_param->vdev_id);
21687 return QDF_STATUS_E_FAILURE;
21688 }
21689
21690 return QDF_STATUS_SUCCESS;
21691}
21692
Arif Hussaine0eb7302018-03-01 14:40:59 -080021693/*
21694 * extract_comb_phyerr_tlv() - extract comb phy error from event
21695 * @wmi_handle: wmi handle
21696 * @evt_buf: pointer to event buffer
21697 * @datalen: data length of event buffer
21698 * @buf_offset: Pointer to hold value of current event buffer offset
21699 * post extraction
21700 * @phyerr: Pointer to hold phyerr
21701 *
21702 * Return: QDF_STATUS
21703 */
21704static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21705 void *evt_buf,
21706 uint16_t datalen,
21707 uint16_t *buf_offset,
21708 wmi_host_phyerr_t *phyerr)
21709{
21710 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21711 wmi_comb_phyerr_rx_hdr *pe_hdr;
21712
21713 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21714 if (!param_tlvs) {
21715 WMI_LOGD("%s: Received null data from FW", __func__);
21716 return QDF_STATUS_E_FAILURE;
21717 }
21718
21719 pe_hdr = param_tlvs->hdr;
21720 if (!pe_hdr) {
21721 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21722 return QDF_STATUS_E_FAILURE;
21723 }
21724
21725 /* Ensure it's at least the size of the header */
21726 if (datalen < sizeof(*pe_hdr)) {
21727 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21728 __func__, sizeof(*pe_hdr), datalen);
21729 return QDF_STATUS_E_FAILURE;
21730 }
21731
21732 phyerr->pdev_id = wmi_handle->ops->
21733 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21734 phyerr->tsf64 = pe_hdr->tsf_l32;
21735 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21736 phyerr->bufp = param_tlvs->bufp;
21737 phyerr->buf_len = pe_hdr->buf_len;
21738 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21739 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21740 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21741
21742 return QDF_STATUS_SUCCESS;
21743}
21744
21745/**
21746 * extract_single_phyerr_tlv() - extract single phy error from event
21747 * @wmi_handle: wmi handle
21748 * @evt_buf: pointer to event buffer
21749 * @datalen: data length of event buffer
21750 * @buf_offset: Pointer to hold value of current event buffer offset
21751 * post extraction
21752 * @phyerr: Pointer to hold phyerr
21753 *
21754 * Return: QDF_STATUS
21755 */
21756static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21757 void *evt_buf,
21758 uint16_t datalen,
21759 uint16_t *buf_offset,
21760 wmi_host_phyerr_t *phyerr)
21761{
21762 wmi_single_phyerr_rx_event *ev;
21763 uint16_t n = *buf_offset;
21764 uint8_t *data = (uint8_t *)evt_buf;
21765
21766 if (n < datalen) {
21767 if ((datalen - n) < sizeof(ev->hdr)) {
21768 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21769 __func__, datalen, n, sizeof(ev->hdr));
21770 return QDF_STATUS_E_FAILURE;
21771 }
21772
21773 /*
21774 * Obtain a pointer to the beginning of the current event.
21775 * data[0] is the beginning of the WMI payload.
21776 */
21777 ev = (wmi_single_phyerr_rx_event *)&data[n];
21778
21779 /*
21780 * Sanity check the buffer length of the event against
21781 * what we currently have.
21782 *
21783 * Since buf_len is 32 bits, we check if it overflows
21784 * a large 32 bit value. It's not 0x7fffffff because
21785 * we increase n by (buf_len + sizeof(hdr)), which would
21786 * in itself cause n to overflow.
21787 *
21788 * If "int" is 64 bits then this becomes a moot point.
21789 */
21790 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21791 WMI_LOGD("%s: buf_len is garbage 0x%x",
21792 __func__, ev->hdr.buf_len);
21793 return QDF_STATUS_E_FAILURE;
21794 }
21795
21796 if ((n + ev->hdr.buf_len) > datalen) {
21797 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21798 __func__, n, ev->hdr.buf_len, datalen);
21799 return QDF_STATUS_E_FAILURE;
21800 }
21801
21802 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21803 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21804 phyerr->bufp = &ev->bufp[0];
21805 phyerr->buf_len = ev->hdr.buf_len;
21806 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21807
21808 /*
21809 * Advance the buffer pointer to the next PHY error.
21810 * buflen is the length of this payload, so we need to
21811 * advance past the current header _AND_ the payload.
21812 */
21813 n += sizeof(*ev) + ev->hdr.buf_len;
21814 }
21815 *buf_offset = n;
21816
21817 return QDF_STATUS_SUCCESS;
21818}
21819
Govind Singh5eb51532016-03-09 11:34:12 +053021820struct wmi_ops tlv_ops = {
21821 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21822 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21823 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021824 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21825 .send_hidden_ssid_vdev_restart_cmd =
21826 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021827 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21828 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21829 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021830 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021831 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021832 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021833 .send_peer_rx_reorder_queue_setup_cmd =
21834 send_peer_rx_reorder_queue_setup_cmd_tlv,
21835 .send_peer_rx_reorder_queue_remove_cmd =
21836 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021837 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21838 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21839 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021840 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21841 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021842 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021843 .send_suspend_cmd = send_suspend_cmd_tlv,
21844 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021845#ifdef FEATURE_WLAN_D0WOW
21846 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21847 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21848#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021849 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21850 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21851 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21852 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021853#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021854 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021855#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021856 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21857 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21858 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021859 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021860 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021861 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021862 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021863 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21864 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21865 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21866 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021867 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021868 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021869 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21870 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021871 .send_set_sta_uapsd_auto_trig_cmd =
21872 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021873 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21874 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21875 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021876#ifdef CONVERGED_P2P_ENABLE
21877 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21878 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21879#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021880 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21881 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021882#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021883 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21884 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21885 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21886 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21887 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21888 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21889 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021890 .send_ocb_start_timing_advert_cmd =
21891 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021892 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21893 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21894 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21895 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21896#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021897 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21898 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21899 .send_set_mcc_channel_time_latency_cmd =
21900 send_set_mcc_channel_time_latency_cmd_tlv,
21901 .send_set_mcc_channel_time_quota_cmd =
21902 send_set_mcc_channel_time_quota_cmd_tlv,
21903 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21904 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021905 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021906 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21907 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21908 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021909 .send_probe_rsp_tmpl_send_cmd =
21910 send_probe_rsp_tmpl_send_cmd_tlv,
21911 .send_p2p_go_set_beacon_ie_cmd =
21912 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021913 .send_setup_install_key_cmd =
21914 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021915 .send_set_gateway_params_cmd =
21916 send_set_gateway_params_cmd_tlv,
21917 .send_set_rssi_monitoring_cmd =
21918 send_set_rssi_monitoring_cmd_tlv,
21919 .send_scan_probe_setoui_cmd =
21920 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021921 .send_roam_scan_offload_rssi_thresh_cmd =
21922 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021923 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021924 .send_roam_scan_filter_cmd =
21925 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021926#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053021927 .send_ipa_offload_control_cmd =
21928 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021929#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053021930 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21931 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21932 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21933 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021934 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021935 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021936#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053021937 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21938 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21939 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021940#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021941 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021942 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21943 .send_snr_cmd = send_snr_cmd_tlv,
21944 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021945#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021946 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21947 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21948 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21949 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021950 .send_multiple_add_clear_mcbc_filter_cmd =
21951 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021952 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021953 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21954 .send_process_gtk_offload_getinfo_cmd =
21955 send_process_gtk_offload_getinfo_cmd_tlv,
21956 .send_enable_enhance_multicast_offload_cmd =
21957 send_enable_enhance_multicast_offload_tlv,
21958 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21959#ifdef FEATURE_WLAN_RA_FILTERING
21960 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21961#endif
21962 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021963 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21964 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021965 .send_lphb_config_tcp_pkt_filter_cmd =
21966 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021967 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
21968 .send_lphb_config_udp_pkt_filter_cmd =
21969 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053021970 .send_enable_disable_packet_filter_cmd =
21971 send_enable_disable_packet_filter_cmd_tlv,
21972 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021973#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021974#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053021975 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
21976 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021977 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021978 .send_roam_scan_offload_mode_cmd =
21979 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021980#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053021981 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021982#endif
Govind Singh87542482016-06-08 19:40:11 +053021983 .send_roam_scan_offload_ap_profile_cmd =
21984 send_roam_scan_offload_ap_profile_cmd_tlv,
21985#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021986#ifdef WLAN_SUPPORT_GREEN_AP
21987 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
21988 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021989 .extract_green_ap_egap_status_info =
21990 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021991#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053021992 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
21993 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021994 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080021995 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021996 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070021997#ifdef WLAN_FEATURE_CIF_CFR
21998 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
21999#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022000 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022001 .send_dfs_phyerr_filter_offload_en_cmd =
22002 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022003 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22004 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22005 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22006 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22007 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022008 .send_process_add_periodic_tx_ptrn_cmd =
22009 send_process_add_periodic_tx_ptrn_cmd_tlv,
22010 .send_process_del_periodic_tx_ptrn_cmd =
22011 send_process_del_periodic_tx_ptrn_cmd_tlv,
22012 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22013 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22014 .send_set_app_type2_params_in_fw_cmd =
22015 send_set_app_type2_params_in_fw_cmd_tlv,
22016 .send_set_auto_shutdown_timer_cmd =
22017 send_set_auto_shutdown_timer_cmd_tlv,
22018 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22019 .send_process_dhcpserver_offload_cmd =
22020 send_process_dhcpserver_offload_cmd_tlv,
22021 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22022 .send_process_ch_avoid_update_cmd =
22023 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022024 .send_pdev_set_regdomain_cmd =
22025 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022026 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22027 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22028 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22029 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022030 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022031 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022032 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022033 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022034 .send_set_base_macaddr_indicate_cmd =
22035 send_set_base_macaddr_indicate_cmd_tlv,
22036 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22037 .send_enable_specific_fw_logs_cmd =
22038 send_enable_specific_fw_logs_cmd_tlv,
22039 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022040 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022041 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022042#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022043 .send_pdev_set_dual_mac_config_cmd =
22044 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022045#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022046 .send_app_type1_params_in_fw_cmd =
22047 send_app_type1_params_in_fw_cmd_tlv,
22048 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22049 .send_process_roam_synch_complete_cmd =
22050 send_process_roam_synch_complete_cmd_tlv,
22051 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22052 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22053 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022054 .send_roam_scan_offload_scan_period_cmd =
22055 send_roam_scan_offload_scan_period_cmd_tlv,
22056 .send_roam_scan_offload_chan_list_cmd =
22057 send_roam_scan_offload_chan_list_cmd_tlv,
22058 .send_roam_scan_offload_rssi_change_cmd =
22059 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022060#ifdef FEATURE_WLAN_APF
22061 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22062 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22063 .send_apf_write_work_memory_cmd =
22064 wmi_send_apf_write_work_memory_cmd_tlv,
22065 .send_apf_read_work_memory_cmd =
22066 wmi_send_apf_read_work_memory_cmd_tlv,
22067 .extract_apf_read_memory_resp_event =
22068 wmi_extract_apf_read_memory_resp_event_tlv,
22069#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022070 .send_adapt_dwelltime_params_cmd =
22071 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022072 .send_dbs_scan_sel_params_cmd =
22073 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022074 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022075 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22076 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22077 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22078 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22079 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22080 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022081 .send_vdev_set_custom_aggr_size_cmd =
22082 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022083 .send_vdev_set_qdepth_thresh_cmd =
22084 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022085 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22086 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22087 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022088 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22089 .send_smart_ant_set_training_info_cmd =
22090 send_smart_ant_set_training_info_cmd_tlv,
22091 .send_smart_ant_set_node_config_cmd =
22092 send_smart_ant_set_node_config_cmd_tlv,
22093 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22094 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22095 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022096 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22097 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22098 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22099 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022100 .send_periodic_chan_stats_config_cmd =
22101 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022102 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22103 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22104 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022105 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22106 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22107 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22108 .send_vdev_spectral_configure_cmd =
22109 send_vdev_spectral_configure_cmd_tlv,
22110 .send_vdev_spectral_enable_cmd =
22111 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022112 .send_thermal_mitigation_param_cmd =
22113 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022114 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22115 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022116 .send_process_update_edca_param_cmd =
22117 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022118 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022119 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022120 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022121 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22122 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022123 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022124 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22125 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22126 .extract_host_mem_req = extract_host_mem_req_tlv,
22127 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022128 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022129 .is_service_enabled = is_service_enabled_tlv,
22130 .save_fw_version = save_fw_version_in_service_ready_tlv,
22131 .ready_extract_init_status = ready_extract_init_status_tlv,
22132 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022133 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022134 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022135 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22136 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022137 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022138 .extract_tbttoffset_update_params =
22139 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022140 .extract_ext_tbttoffset_update_params =
22141 extract_ext_tbttoffset_update_params_tlv,
22142 .extract_tbttoffset_num_vdevs =
22143 extract_tbttoffset_num_vdevs_tlv,
22144 .extract_ext_tbttoffset_num_vdevs =
22145 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022146 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22147 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22148 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22149 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022150#ifdef CONVERGED_TDLS_ENABLE
22151 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22152#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022153 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022154 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022155 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22156 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022157#ifdef CONVERGED_P2P_ENABLE
22158 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22159 .extract_p2p_lo_stop_ev_param =
22160 extract_p2p_lo_stop_ev_param_tlv,
22161#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022162 .extract_offchan_data_tx_compl_param =
22163 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022164 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22165 .extract_all_stats_count = extract_all_stats_counts_tlv,
22166 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022167 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022168 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22169 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022170 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022171 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022172 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022173 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22174 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22175 .extract_chan_stats = extract_chan_stats_tlv,
22176 .extract_profile_ctx = extract_profile_ctx_tlv,
22177 .extract_profile_data = extract_profile_data_tlv,
22178 .extract_chan_info_event = extract_chan_info_event_tlv,
22179 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022180 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022181#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022182 .send_encrypt_decrypt_send_cmd =
22183 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022184 .extract_encrypt_decrypt_resp_event =
22185 extract_encrypt_decrypt_resp_event_tlv,
22186#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022187 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022188 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22189 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022190 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022191 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022192 .send_multiple_vdev_restart_req_cmd =
22193 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022194 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22195 .extract_hw_mode_cap_service_ready_ext =
22196 extract_hw_mode_cap_service_ready_ext_tlv,
22197 .extract_mac_phy_cap_service_ready_ext =
22198 extract_mac_phy_cap_service_ready_ext_tlv,
22199 .extract_reg_cap_service_ready_ext =
22200 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022201 .extract_dbr_ring_cap_service_ready_ext =
22202 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022203 .extract_sar_cap_service_ready_ext =
22204 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022205 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22206 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022207 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022208 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022209 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022210 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22211 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22212 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022213 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022214 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022215 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022216 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022217 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022218 .extract_pdev_csa_switch_count_status =
22219 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022220 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022221 .extract_pdev_tpc_config_ev_param =
22222 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022223 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022224 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22225 .extract_peer_sta_ps_statechange_ev =
22226 extract_peer_sta_ps_statechange_ev_tlv,
22227 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022228 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022229#ifdef WLAN_FEATURE_ACTION_OUI
22230 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22231#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022232 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22233 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022234 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022235 extract_reg_chan_list_update_event_tlv,
22236 .extract_chainmask_tables =
22237 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022238 .extract_thermal_stats = extract_thermal_stats_tlv,
22239 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022240 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22241 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022242#ifdef DFS_COMPONENT_ENABLE
22243 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22244 .extract_dfs_radar_detection_event =
22245 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022246 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022247#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022248 .convert_pdev_id_host_to_target =
22249 convert_host_pdev_id_to_target_pdev_id_legacy,
22250 .convert_pdev_id_target_to_host =
22251 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022252
22253 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22254 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22255 .extract_reg_11d_new_country_event =
22256 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022257 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022258 .send_limit_off_chan_cmd =
22259 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022260 .extract_reg_ch_avoid_event =
22261 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022262 .send_pdev_caldata_version_check_cmd =
22263 send_pdev_caldata_version_check_cmd_tlv,
22264 .extract_pdev_caldata_version_check_ev_param =
22265 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022266 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22267 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022268 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22269#if defined(WLAN_FEATURE_FILS_SK)
22270 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22271#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022272 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022273#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22274 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22275 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22276 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22277 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22278 .extract_ndp_ind = extract_ndp_ind_tlv,
22279 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22280 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22281 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22282 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022283 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022284#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022285 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022286 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022287 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022288#ifdef WLAN_SUPPORT_FILS
22289 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22290 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22291 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22292#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022293 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22294 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022295 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22296 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22297 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22298 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022299 .send_bss_color_change_enable_cmd =
22300 send_bss_color_change_enable_cmd_tlv,
22301 .send_obss_color_collision_cfg_cmd =
22302 send_obss_color_collision_cfg_cmd_tlv,
22303 .extract_obss_color_collision_info =
22304 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022305 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22306 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022307#ifdef QCA_SUPPORT_CP_STATS
22308 .extract_cca_stats = extract_cca_stats_tlv,
22309#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022310};
22311
Govind Singhe7f2f342016-05-23 12:12:52 +053022312/**
22313 * populate_tlv_event_id() - populates wmi event ids
22314 *
22315 * @param event_ids: Pointer to hold event ids
22316 * Return: None
22317 */
22318static void populate_tlv_events_id(uint32_t *event_ids)
22319{
22320 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22321 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22322 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22323 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22324 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22325 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22326 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22327 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22328 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22329 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22330 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22331 event_ids[wmi_service_ready_ext_event_id] =
22332 WMI_SERVICE_READY_EXT_EVENTID;
22333 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22334 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22335 event_ids[wmi_vdev_install_key_complete_event_id] =
22336 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22337 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22338 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22339
22340 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22341 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22342 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22343 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22344 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22345 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22346 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22347 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022348 event_ids[wmi_peer_delete_response_event_id] =
22349 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022350 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22351 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22352 event_ids[wmi_tbttoffset_update_event_id] =
22353 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022354 event_ids[wmi_ext_tbttoffset_update_event_id] =
22355 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022356 event_ids[wmi_offload_bcn_tx_status_event_id] =
22357 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22358 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22359 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22360 event_ids[wmi_mgmt_tx_completion_event_id] =
22361 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022362 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22363 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022364 event_ids[wmi_tx_delba_complete_event_id] =
22365 WMI_TX_DELBA_COMPLETE_EVENTID;
22366 event_ids[wmi_tx_addba_complete_event_id] =
22367 WMI_TX_ADDBA_COMPLETE_EVENTID;
22368 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22369
22370 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22371
22372 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22373 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22374
22375 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022376 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022377
22378 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22379
22380 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022381 event_ids[wmi_p2p_lo_stop_event_id] =
22382 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022383 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22384 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022385 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022386 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22387 event_ids[wmi_wow_initial_wakeup_event_id] =
22388 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22389
22390 event_ids[wmi_rtt_meas_report_event_id] =
22391 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22392 event_ids[wmi_tsf_meas_report_event_id] =
22393 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22394 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22395 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22396 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22397 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22398 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022399 event_ids[wmi_diag_event_id_log_supported_event_id] =
22400 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22401 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22402 event_ids[wmi_nlo_scan_complete_event_id] =
22403 WMI_NLO_SCAN_COMPLETE_EVENTID;
22404 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22405 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22406
22407 event_ids[wmi_gtk_offload_status_event_id] =
22408 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22409 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22410 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22411 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22412
22413 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22414
22415 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22416
22417 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22418 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22419 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22420 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22421 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22422 event_ids[wmi_wlan_profile_data_event_id] =
22423 WMI_WLAN_PROFILE_DATA_EVENTID;
22424 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22425 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22426 event_ids[wmi_vdev_get_keepalive_event_id] =
22427 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22428 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22429
22430 event_ids[wmi_diag_container_event_id] =
22431 WMI_DIAG_DATA_CONTAINER_EVENTID;
22432
22433 event_ids[wmi_host_auto_shutdown_event_id] =
22434 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22435
22436 event_ids[wmi_update_whal_mib_stats_event_id] =
22437 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22438
22439 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22440 event_ids[wmi_update_vdev_rate_stats_event_id] =
22441 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22442
22443 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022444 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022445
22446 /** Set OCB Sched Response, deprecated */
22447 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22448
22449 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22450 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22451 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22452
22453 /* GPIO Event */
22454 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22455 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22456
22457 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22458 event_ids[wmi_rfkill_state_change_event_id] =
22459 WMI_RFKILL_STATE_CHANGE_EVENTID;
22460
22461 /* TDLS Event */
22462 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22463
22464 event_ids[wmi_batch_scan_enabled_event_id] =
22465 WMI_BATCH_SCAN_ENABLED_EVENTID;
22466 event_ids[wmi_batch_scan_result_event_id] =
22467 WMI_BATCH_SCAN_RESULT_EVENTID;
22468 /* OEM Event */
22469 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22470 event_ids[wmi_oem_meas_report_event_id] =
22471 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22472 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22473
22474 /* NAN Event */
22475 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22476
22477 /* LPI Event */
22478 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22479 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22480 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22481
22482 /* ExtScan events */
22483 event_ids[wmi_extscan_start_stop_event_id] =
22484 WMI_EXTSCAN_START_STOP_EVENTID;
22485 event_ids[wmi_extscan_operation_event_id] =
22486 WMI_EXTSCAN_OPERATION_EVENTID;
22487 event_ids[wmi_extscan_table_usage_event_id] =
22488 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22489 event_ids[wmi_extscan_cached_results_event_id] =
22490 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22491 event_ids[wmi_extscan_wlan_change_results_event_id] =
22492 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22493 event_ids[wmi_extscan_hotlist_match_event_id] =
22494 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22495 event_ids[wmi_extscan_capabilities_event_id] =
22496 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22497 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22498 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22499
22500 /* mDNS offload events */
22501 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22502
22503 /* SAP Authentication offload events */
22504 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22505 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22506
22507 /** Out-of-context-of-bss (OCB) events */
22508 event_ids[wmi_ocb_set_config_resp_event_id] =
22509 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22510 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22511 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22512 event_ids[wmi_dcc_get_stats_resp_event_id] =
22513 WMI_DCC_GET_STATS_RESP_EVENTID;
22514 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22515 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22516 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22517 /* System-On-Chip events */
22518 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22519 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22520 event_ids[wmi_soc_hw_mode_transition_event_id] =
22521 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22522 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22523 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022524 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022525 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22526 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022527 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022528 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22529 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22530 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22531 WMI_PEER_STA_PS_STATECHG_EVENTID;
22532 event_ids[wmi_pdev_channel_hopping_event_id] =
22533 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022534 event_ids[wmi_offchan_data_tx_completion_event] =
22535 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022536 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22537 event_ids[wmi_dfs_radar_detection_event_id] =
22538 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022539 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022540 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022541 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022542 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022543 event_ids[wmi_service_available_event_id] =
22544 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022545 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022546 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022547 /* NDP events */
22548 event_ids[wmi_ndp_initiator_rsp_event_id] =
22549 WMI_NDP_INITIATOR_RSP_EVENTID;
22550 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22551 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22552 event_ids[wmi_ndp_responder_rsp_event_id] =
22553 WMI_NDP_RESPONDER_RSP_EVENTID;
22554 event_ids[wmi_ndp_end_indication_event_id] =
22555 WMI_NDP_END_INDICATION_EVENTID;
22556 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022557 event_ids[wmi_ndl_schedule_update_event_id] =
22558 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022559
22560 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22561 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22562 event_ids[wmi_pdev_chip_power_stats_event_id] =
22563 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22564 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22565 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22566 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022567 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022568 WMI_BPF_CAPABILIY_INFO_EVENTID;
22569 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22570 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22571 event_ids[wmi_report_rx_aggr_failure_event_id] =
22572 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22573 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22574 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22575 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22576 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22577 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22578 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22579 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22580 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22581 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22582 event_ids[wmi_coex_bt_activity_event_id] =
22583 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22584 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22585 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22586 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22587 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22588 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022589 event_ids[wmi_dma_buf_release_event_id] =
22590 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022591 event_ids[wmi_sap_obss_detection_report_event_id] =
22592 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022593 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022594 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022595 event_ids[wmi_obss_color_collision_report_event_id] =
22596 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022597 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22598 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022599 event_ids[wmi_twt_enable_complete_event_id] =
22600 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022601 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22602 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022603 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022604}
22605
Soumya Bhat488092d2017-03-22 14:41:01 +053022606/**
22607 * populate_tlv_service() - populates wmi services
22608 *
22609 * @param wmi_service: Pointer to hold wmi_service
22610 * Return: None
22611 */
22612static void populate_tlv_service(uint32_t *wmi_service)
22613{
22614 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022615 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022616 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22617 wmi_service[wmi_service_roam_scan_offload] =
22618 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22619 wmi_service[wmi_service_bcn_miss_offload] =
22620 WMI_SERVICE_BCN_MISS_OFFLOAD;
22621 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22622 wmi_service[wmi_service_sta_advanced_pwrsave] =
22623 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22624 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22625 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22626 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22627 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22628 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22629 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22630 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22631 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22632 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22633 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22634 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22635 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22636 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22637 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22638 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22639 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22640 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22641 wmi_service[wmi_service_packet_power_save] =
22642 WMI_SERVICE_PACKET_POWER_SAVE;
22643 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22644 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22645 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22646 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22647 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22648 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22649 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22650 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22651 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22652 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22653 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22654 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22655 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22656 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22657 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22658 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22659 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22660 wmi_service[wmi_service_mcc_bcn_interval_change] =
22661 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22662 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22663 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22664 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22665 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22666 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22667 wmi_service[wmi_service_lte_ant_share_support] =
22668 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22669 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22670 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22671 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22672 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22673 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22674 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22675 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22676 wmi_service[wmi_service_bcn_txrate_override] =
22677 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22678 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22679 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22680 wmi_service[wmi_service_estimate_linkspeed] =
22681 WMI_SERVICE_ESTIMATE_LINKSPEED;
22682 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22683 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22684 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22685 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22686 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22687 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22688 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22689 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22690 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22691 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22692 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22693 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22694 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22695 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22696 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22697 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22698 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22699 wmi_service[wmi_service_sap_auth_offload] =
22700 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22701 wmi_service[wmi_service_dual_band_simultaneous_support] =
22702 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22703 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22704 wmi_service[wmi_service_ap_arpns_offload] =
22705 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22706 wmi_service[wmi_service_per_band_chainmask_support] =
22707 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22708 wmi_service[wmi_service_packet_filter_offload] =
22709 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22710 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22711 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22712 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22713 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22714 wmi_service[wmi_service_multiple_vdev_restart] =
22715 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22716
22717 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22718 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22719 wmi_service[wmi_service_smart_antenna_sw_support] =
22720 WMI_SERVICE_UNAVAILABLE;
22721 wmi_service[wmi_service_smart_antenna_hw_support] =
22722 WMI_SERVICE_UNAVAILABLE;
22723 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022724 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022725 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022726 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22727 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22728 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22729 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22730 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22731 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22732 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22733 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022734 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22735 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22736 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022737 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022738 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22739 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22740 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22741 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22742 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22743 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022744 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22745 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22746 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22747 wmi_service[wmi_service_unified_wow_capability] =
22748 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22749 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022750 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022751 wmi_service[wmi_service_sync_delete_cmds] =
22752 WMI_SERVICE_SYNC_DELETE_CMDS;
22753 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22754 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22755 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22756 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22757 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22758 wmi_service[wmi_service_deprecated_replace] =
22759 WMI_SERVICE_DEPRECATED_REPLACE;
22760 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22761 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22762 wmi_service[wmi_service_enhanced_mcast_filter] =
22763 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22764 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22765 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22766 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22767 wmi_service[wmi_service_p2p_listen_offload_support] =
22768 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22769 wmi_service[wmi_service_mark_first_wakeup_packet] =
22770 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22771 wmi_service[wmi_service_multiple_mcast_filter_set] =
22772 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22773 wmi_service[wmi_service_host_managed_rx_reorder] =
22774 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22775 wmi_service[wmi_service_flash_rdwr_support] =
22776 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22777 wmi_service[wmi_service_wlan_stats_report] =
22778 WMI_SERVICE_WLAN_STATS_REPORT;
22779 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22780 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22781 wmi_service[wmi_service_dfs_phyerr_offload] =
22782 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22783 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22784 wmi_service[wmi_service_fw_mem_dump_support] =
22785 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22786 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22787 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22788 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22789 wmi_service[wmi_service_hw_data_filtering] =
22790 WMI_SERVICE_HW_DATA_FILTERING;
22791 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22792 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022793 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022794 wmi_service[wmi_service_extended_nss_support] =
22795 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022796 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022797 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22798 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022799 wmi_service[wmi_service_offchan_data_tid_support] =
22800 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022801 wmi_service[wmi_service_support_dma] =
22802 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022803 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22804 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22805 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022806 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22807 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022808 wmi_service[wmi_service_11k_neighbour_report_support] =
22809 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022810 wmi_service[wmi_service_ap_obss_detection_offload] =
22811 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22812 wmi_service[wmi_service_bss_color_offload] =
22813 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022814 wmi_service[wmi_service_gmac_offload_support] =
22815 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022816 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22817 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22818 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22819 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022820 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22821 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022822 wmi_service[wmi_service_listen_interval_offload_support] =
22823 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022824
Soumya Bhat488092d2017-03-22 14:41:01 +053022825}
22826
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022827#ifndef CONFIG_MCL
22828
Govind Singhe7f2f342016-05-23 12:12:52 +053022829/**
22830 * populate_pdev_param_tlv() - populates pdev params
22831 *
22832 * @param pdev_param: Pointer to hold pdev params
22833 * Return: None
22834 */
22835static void populate_pdev_param_tlv(uint32_t *pdev_param)
22836{
22837 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22838 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22839 pdev_param[wmi_pdev_param_txpower_limit2g] =
22840 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22841 pdev_param[wmi_pdev_param_txpower_limit5g] =
22842 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22843 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22844 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22845 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22846 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22847 WMI_PDEV_PARAM_BEACON_TX_MODE;
22848 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22849 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22850 pdev_param[wmi_pdev_param_protection_mode] =
22851 WMI_PDEV_PARAM_PROTECTION_MODE;
22852 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22853 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22854 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22855 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22856 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22857 pdev_param[wmi_pdev_param_sta_kickout_th] =
22858 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22859 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22860 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22861 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22862 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22863 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22864 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22865 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22866 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22867 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22868 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22869 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22870 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22871 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22872 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22873 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22874 pdev_param[wmi_pdev_param_ltr_rx_override] =
22875 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22876 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22877 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22878 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22879 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22880 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22881 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22882 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22883 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22884 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22885 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22886 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22887 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22888 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22889 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22890 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22891 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22892 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22893 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22894 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22895 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22896 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22897 pdev_param[wmi_pdev_param_arp_ac_override] =
22898 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22899 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22900 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22901 pdev_param[wmi_pdev_param_ani_poll_period] =
22902 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22903 pdev_param[wmi_pdev_param_ani_listen_period] =
22904 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22905 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22906 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22907 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22908 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22909 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22910 pdev_param[wmi_pdev_param_idle_ps_config] =
22911 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22912 pdev_param[wmi_pdev_param_power_gating_sleep] =
22913 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22914 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22915 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22916 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22917 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22918 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22919 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22920 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22921 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22922 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22923 pdev_param[wmi_pdev_param_power_collapse_enable] =
22924 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22925 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22926 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22927 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22928 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22929 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22930 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22931 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22932 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22933 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22934 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22935 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22936 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22937 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22938 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22939 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22940 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22941 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22942 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22943 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22944 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22945 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22946 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22947 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22948 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22949 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22950 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22951 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22952 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22953 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22954 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22955 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22956 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22957 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22958 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22959 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22960 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22961 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22962 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22963 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
22964 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
22965 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
22966 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
22967 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
22968 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022969 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
22970 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
22971 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053022972 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
22973 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022974 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053022975 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022976 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
22977 pdev_param[wmi_pdev_param_proxy_sta_mode] =
22978 WMI_PDEV_PARAM_PROXY_STA_MODE;
22979 pdev_param[wmi_pdev_param_mu_group_policy] =
22980 WMI_PDEV_PARAM_MU_GROUP_POLICY;
22981 pdev_param[wmi_pdev_param_noise_detection] =
22982 WMI_PDEV_PARAM_NOISE_DETECTION;
22983 pdev_param[wmi_pdev_param_noise_threshold] =
22984 WMI_PDEV_PARAM_NOISE_THRESHOLD;
22985 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
22986 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
22987 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022988 pdev_param[wmi_pdev_param_atf_strict_sch] =
22989 WMI_PDEV_PARAM_ATF_STRICT_SCH;
22990 pdev_param[wmi_pdev_param_atf_sched_duration] =
22991 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022992 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
22993 pdev_param[wmi_pdev_param_sensitivity_level] =
22994 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
22995 pdev_param[wmi_pdev_param_signed_txpower_2g] =
22996 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
22997 pdev_param[wmi_pdev_param_signed_txpower_5g] =
22998 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070022999 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23000 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23001 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23002 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023003 pdev_param[wmi_pdev_param_cca_threshold] =
23004 WMI_PDEV_PARAM_CCA_THRESHOLD;
23005 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23006 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023007 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023008 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23009 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23010 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23011 pdev_param[wmi_pdev_param_arp_srcaddr] =
23012 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23013 pdev_param[wmi_pdev_param_arp_dstaddr] =
23014 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23015 pdev_param[wmi_pdev_param_txpower_decr_db] =
23016 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023017 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23018 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023019 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23020 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023021 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023022 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023023 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23024 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023025 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23026 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023027 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23028 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023029 pdev_param[wmi_pdev_param_igmpmld_override] =
23030 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23031 pdev_param[wmi_pdev_param_igmpmld_tid] =
23032 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023033 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23034 pdev_param[wmi_pdev_param_block_interbss] =
23035 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023036 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023037 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23038 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23039 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023040 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023041 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023042 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23043 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023044 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023045 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23046 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023047 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23048 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23049 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23050 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023051 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23052 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23053 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23054 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23055 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23056 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23057 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23058 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23059 pdev_param[wmi_pdev_param_fast_channel_reset] =
23060 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23061 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023062 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023063 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023064 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23065 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023066}
23067
23068/**
23069 * populate_vdev_param_tlv() - populates vdev params
23070 *
23071 * @param vdev_param: Pointer to hold vdev params
23072 * Return: None
23073 */
23074static void populate_vdev_param_tlv(uint32_t *vdev_param)
23075{
23076 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23077 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23078 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23079 vdev_param[wmi_vdev_param_beacon_interval] =
23080 WMI_VDEV_PARAM_BEACON_INTERVAL;
23081 vdev_param[wmi_vdev_param_listen_interval] =
23082 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23083 vdev_param[wmi_vdev_param_multicast_rate] =
23084 WMI_VDEV_PARAM_MULTICAST_RATE;
23085 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23086 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23087 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23088 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23089 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23090 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23091 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23092 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23093 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23094 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23095 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23096 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23097 vdev_param[wmi_vdev_param_bmiss_count_max] =
23098 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23099 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23100 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23101 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23102 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23103 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23104 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23105 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23106 vdev_param[wmi_vdev_param_disable_htprotection] =
23107 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23108 vdev_param[wmi_vdev_param_sta_quickkickout] =
23109 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23110 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23111 vdev_param[wmi_vdev_param_protection_mode] =
23112 WMI_VDEV_PARAM_PROTECTION_MODE;
23113 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23114 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23115 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23116 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23117 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23118 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23119 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23120 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23121 vdev_param[wmi_vdev_param_bcast_data_rate] =
23122 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23123 vdev_param[wmi_vdev_param_mcast_data_rate] =
23124 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23125 vdev_param[wmi_vdev_param_mcast_indicate] =
23126 WMI_VDEV_PARAM_MCAST_INDICATE;
23127 vdev_param[wmi_vdev_param_dhcp_indicate] =
23128 WMI_VDEV_PARAM_DHCP_INDICATE;
23129 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23130 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23131 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23132 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23133 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23134 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23135 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23136 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23137 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23138 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23139 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23140 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23141 vdev_param[wmi_vdev_param_packet_powersave] =
23142 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23143 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23144 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23145 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23146 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23147 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23148 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23149 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23150 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23151 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23152 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23153 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23154 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23155 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23156 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23157 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23158 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23159 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23160 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23161 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23162 vdev_param[wmi_vdev_param_roam_fw_offload] =
23163 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23164 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23165 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23166 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23167 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23168 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23169 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23170 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23171 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23172 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23173 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23174 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23175 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23176 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23177 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23178 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23179 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23180 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23181 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23182 vdev_param[wmi_vdev_param_inactivity_cnt] =
23183 WMI_VDEV_PARAM_INACTIVITY_CNT;
23184 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23185 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23186 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23187 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23188 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23189 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23190 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23191 vdev_param[wmi_vdev_param_rx_leak_window] =
23192 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23193 vdev_param[wmi_vdev_param_stats_avg_factor] =
23194 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23195 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23196 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23197 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23198 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23199 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23200 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023201 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23202 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023203 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023204 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23205 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23206 WMI_VDEV_PARAM_HE_RANGE_EXT;
23207 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23208 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023209 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23210 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023211 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023212 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23213 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23214 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23215 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23216 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23217 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23218 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023219 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23220 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23221 vdev_param[wmi_vdev_param_rc_num_retries] =
23222 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23223 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23224 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23225 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23226 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23227 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23228 vdev_param[wmi_vdev_param_vht80_ratemask] =
23229 WMI_VDEV_PARAM_VHT80_RATEMASK;
23230 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23231 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23232 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023233 vdev_param[wmi_vdev_param_set_he_ltf] =
23234 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023235 vdev_param[wmi_vdev_param_disable_cabq] =
23236 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023237 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23238 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023239 vdev_param[wmi_vdev_param_set_ba_mode] =
23240 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023241 vdev_param[wmi_vdev_param_capabilities] =
23242 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023243 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23244 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023245}
23246#endif
23247
Govind Singh5eb51532016-03-09 11:34:12 +053023248/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023249 * populate_target_defines_tlv() - Populate target defines and params
23250 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023251 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023252 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023253 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023254#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023255static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023256{
Govind Singhe7f2f342016-05-23 12:12:52 +053023257 populate_pdev_param_tlv(wmi_handle->pdev_param);
23258 populate_vdev_param_tlv(wmi_handle->vdev_param);
23259}
23260#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023261static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23262{ }
23263#endif
23264
23265/**
Zhang Qian537fca62018-01-03 16:33:24 +080023266 * wmi_ocb_ut_attach() - Attach OCB test framework
23267 * @wmi_handle: wmi handle
23268 *
23269 * Return: None
23270 */
23271#ifdef WLAN_OCB_UT
23272void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23273#else
23274static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23275{
23276 return;
23277}
23278#endif
23279
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023280/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023281 * wmi_tlv_attach() - Attach TLV APIs
23282 *
23283 * Return: None
23284 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023285void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023286{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023287 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023288 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023289 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023290#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023291 /* Skip saving WMI_CMD_HDR and TLV HDR */
23292 wmi_handle->log_info.buf_offset_command = 8;
23293 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023294 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023295#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023296 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023297 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023298 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023299 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023300 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023301}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023302qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023303
23304/**
23305 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23306 *
23307 * Return: None
23308 */
23309void wmi_tlv_init(void)
23310{
23311 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23312}