blob: b315b4bd1185ca5c54ec5064c617b4d11fc1c4fb [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053033#include <wlan_defs.h>
34
Wu Gaocd3a8512017-03-13 20:17:34 +080035#ifdef CONVERGED_P2P_ENABLE
36#include "wlan_p2p_public_struct.h"
37#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070038#ifdef WLAN_PMO_ENABLE
39#include "wlan_pmo_hw_filter_public_struct.h"
40#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053041#include <wlan_utility.h>
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053042
43/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
44 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053045 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053046 * @cmd: pointer target vdev create command buffer
47 * @param: pointer host params for vdev create
48 *
49 * Return: None
50 */
51#ifdef CONFIG_MCL
52static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053053 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053054 wmi_vdev_create_cmd_fixed_param * cmd,
55 struct vdev_create_params *param)
56{
57 cmd->pdev_id = WMI_PDEV_ID_SOC;
58}
59#else
60static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053061 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053062 wmi_vdev_create_cmd_fixed_param * cmd,
63 struct vdev_create_params *param)
64{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053065 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
66 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053067}
68#endif
69
Govind Singh5eb51532016-03-09 11:34:12 +053070/**
71 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
72 * @wmi_handle: wmi handle
73 * @param: pointer to hold vdev create parameter
74 * @macaddr: vdev mac address
75 *
Govind Singhe7f2f342016-05-23 12:12:52 +053076 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053077 */
Sathish Kumarfd347372017-02-13 12:29:09 +053078static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053079 uint8_t macaddr[IEEE80211_ADDR_LEN],
80 struct vdev_create_params *param)
81{
82 wmi_vdev_create_cmd_fixed_param *cmd;
83 wmi_buf_t buf;
84 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053085 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070086 int num_bands = 2;
87 uint8_t *buf_ptr;
88 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053089
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070090 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053091 buf = wmi_buf_alloc(wmi_handle, len);
92 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053093 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053094 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053095 }
96 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
97 WMITLV_SET_HDR(&cmd->tlv_header,
98 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
99 WMITLV_GET_STRUCT_TLVLEN
100 (wmi_vdev_create_cmd_fixed_param));
101 cmd->vdev_id = param->if_id;
102 cmd->vdev_type = param->type;
103 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700104 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530105 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530106 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +0530107 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +0530108 __func__, param->if_id,
109 macaddr[0], macaddr[1], macaddr[2],
110 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700111 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
112 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
113 (num_bands * sizeof(wmi_vdev_txrx_streams)));
114 buf_ptr += WMI_TLV_HDR_SIZE;
115
Govind Singh224a7312016-06-21 14:33:26 +0530116 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700117 param->type, param->subtype,
118 param->nss_2g, param->nss_5g);
119 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
120 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
121 txrx_streams->supported_tx_streams = param->nss_2g;
122 txrx_streams->supported_rx_streams = param->nss_2g;
123 WMITLV_SET_HDR(&txrx_streams->tlv_header,
124 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
125 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
126
127 txrx_streams++;
128 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
129 txrx_streams->supported_tx_streams = param->nss_5g;
130 txrx_streams->supported_rx_streams = param->nss_5g;
131 WMITLV_SET_HDR(&txrx_streams->tlv_header,
132 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
133 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530134 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530135 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530136 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530137 wmi_buf_free(buf);
138 }
139
140 return ret;
141}
142
143/**
144 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
145 * @wmi_handle: wmi handle
146 * @if_id: vdev id
147 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530148 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530149 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530150static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530151 uint8_t if_id)
152{
153 wmi_vdev_delete_cmd_fixed_param *cmd;
154 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530155 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530156
157 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
158 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530159 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530160 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530161 }
162
163 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
164 WMITLV_SET_HDR(&cmd->tlv_header,
165 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
166 WMITLV_GET_STRUCT_TLVLEN
167 (wmi_vdev_delete_cmd_fixed_param));
168 cmd->vdev_id = if_id;
169 ret = wmi_unified_cmd_send(wmi_handle, buf,
170 sizeof(wmi_vdev_delete_cmd_fixed_param),
171 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530172 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530173 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530174 wmi_buf_free(buf);
175 }
Govind Singhb53420c2016-03-09 14:32:57 +0530176 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530177
178 return ret;
179}
180
181/**
182 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
183 * @wmi: wmi handle
184 * @vdev_id: vdev id
185 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530186 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530187 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530188static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530189 uint8_t vdev_id)
190{
191 wmi_vdev_stop_cmd_fixed_param *cmd;
192 wmi_buf_t buf;
193 int32_t len = sizeof(*cmd);
194
195 buf = wmi_buf_alloc(wmi, len);
196 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530197 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530198 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530199 }
200 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
201 WMITLV_SET_HDR(&cmd->tlv_header,
202 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
203 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
204 cmd->vdev_id = vdev_id;
205 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530206 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530207 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530208 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530209 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530210 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530211
212 return 0;
213}
214
215/**
216 * send_vdev_down_cmd_tlv() - send vdev down command to fw
217 * @wmi: wmi handle
218 * @vdev_id: vdev id
219 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530220 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530221 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530222static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530223{
224 wmi_vdev_down_cmd_fixed_param *cmd;
225 wmi_buf_t buf;
226 int32_t len = sizeof(*cmd);
227
228 buf = wmi_buf_alloc(wmi, len);
229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530230 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530231 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530232 }
233 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
234 WMITLV_SET_HDR(&cmd->tlv_header,
235 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
236 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
237 cmd->vdev_id = vdev_id;
238 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530239 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530240 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530241 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530242 }
Govind Singhb53420c2016-03-09 14:32:57 +0530243 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530244
245 return 0;
246}
247
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530248#ifdef CONFIG_MCL
249static inline void copy_channel_info(
250 wmi_vdev_start_request_cmd_fixed_param * cmd,
251 wmi_channel *chan,
252 struct vdev_start_params *req)
253{
254 chan->mhz = req->chan_freq;
255
256 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
257
258 chan->band_center_freq1 = req->band_center_freq1;
259 chan->band_center_freq2 = req->band_center_freq2;
260
261 if (req->is_half_rate)
262 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
263 else if (req->is_quarter_rate)
264 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
265
Naveen Rawat44f2f432016-12-01 12:58:57 -0800266 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530267 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
268 cmd->disable_hw_ack = req->dis_hw_ack;
269 }
270
271 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
272 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
273
274}
275#else
276static inline void copy_channel_info(
277 wmi_vdev_start_request_cmd_fixed_param * cmd,
278 wmi_channel *chan,
279 struct vdev_start_params *req)
280{
281 chan->mhz = req->channel.mhz;
282
283 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
284
285 chan->band_center_freq1 = req->channel.cfreq1;
286 chan->band_center_freq2 = req->channel.cfreq2;
287
288 if (req->channel.half_rate)
289 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
290 else if (req->channel.quarter_rate)
291 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
292
293 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530294 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530295 cmd->disable_hw_ack = req->disable_hw_ack;
296 }
297
Krishna Rao0b952ea2017-03-20 13:30:10 +0530298 if (req->channel.dfs_set_cfreq2)
299 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
300
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530301 /* FIXME: Find out min, max and regulatory power levels */
302 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
303 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
304
305}
306#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530307/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530308 * send_vdev_start_cmd_tlv() - send vdev start request to fw
309 * @wmi_handle: wmi handle
310 * @req: vdev start params
311 *
312 * Return: QDF status
313 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530314static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530315 struct vdev_start_params *req)
316{
317 wmi_vdev_start_request_cmd_fixed_param *cmd;
318 wmi_buf_t buf;
319 wmi_channel *chan;
320 int32_t len, ret;
321 uint8_t *buf_ptr;
322
323 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
324 buf = wmi_buf_alloc(wmi_handle, len);
325 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530326 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530327 return QDF_STATUS_E_NOMEM;
328 }
329 buf_ptr = (uint8_t *) wmi_buf_data(buf);
330 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
331 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
332 WMITLV_SET_HDR(&cmd->tlv_header,
333 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
334 WMITLV_GET_STRUCT_TLVLEN
335 (wmi_vdev_start_request_cmd_fixed_param));
336 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
337 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
338 cmd->vdev_id = req->vdev_id;
339
340 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530341 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530342
343 cmd->beacon_interval = req->beacon_intval;
344 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530345
346 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530347 cmd->beacon_interval = req->beacon_intval;
348 cmd->dtim_period = req->dtim_period;
349
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 /* Copy the SSID */
351 if (req->ssid.length) {
352 if (req->ssid.length < sizeof(cmd->ssid.ssid))
353 cmd->ssid.ssid_len = req->ssid.length;
354 else
355 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
356 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
357 cmd->ssid.ssid_len);
358 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530359
360 if (req->hidden_ssid)
361 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
362
363 if (req->pmf_enabled)
364 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530365 }
366
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700367 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530368 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530369 cmd->preferred_rx_streams = req->preferred_rx_streams;
370 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700371 cmd->cac_duration_ms = req->cac_duration_ms;
372 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700373 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530374
375 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
376 sizeof(wmi_channel));
377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
378 cmd->num_noa_descriptors *
379 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800380 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530381 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
382 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700383 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800384 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385 req->is_dfs, req->beacon_intval, cmd->dtim_period,
386 chan->band_center_freq1, chan->band_center_freq2,
387 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700388 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700389 req->ldpc_rx_enabled, req->cac_duration_ms,
390 req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530391
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 if (req->is_restart)
393 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
394 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530395 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
397 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530398 if (ret) {
399 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530400 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530402 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530403
404 return QDF_STATUS_SUCCESS;
405}
406
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407/**
408 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
409 * @wmi_handle: wmi handle
410 * @restart_params: vdev restart params
411 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530412 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530414static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530415 struct hidden_ssid_vdev_restart_params *restart_params)
416{
417 wmi_vdev_start_request_cmd_fixed_param *cmd;
418 wmi_buf_t buf;
419 wmi_channel *chan;
420 int32_t len;
421 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530422 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530423
424 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
425 buf = wmi_buf_alloc(wmi_handle, len);
426 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530427 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530428 return QDF_STATUS_E_NOMEM;
429 }
430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
431 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
432 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
433
434 WMITLV_SET_HDR(&cmd->tlv_header,
435 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
436 WMITLV_GET_STRUCT_TLVLEN
437 (wmi_vdev_start_request_cmd_fixed_param));
438
439 WMITLV_SET_HDR(&chan->tlv_header,
440 WMITLV_TAG_STRUC_wmi_channel,
441 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
442
443 cmd->vdev_id = restart_params->session_id;
444 cmd->ssid.ssid_len = restart_params->ssid_len;
445 qdf_mem_copy(cmd->ssid.ssid,
446 restart_params->ssid,
447 cmd->ssid.ssid_len);
448 cmd->flags = restart_params->flags;
449 cmd->requestor_id = restart_params->requestor_id;
450 cmd->disable_hw_ack = restart_params->disable_hw_ack;
451
452 chan->mhz = restart_params->mhz;
453 chan->band_center_freq1 =
454 restart_params->band_center_freq1;
455 chan->band_center_freq2 =
456 restart_params->band_center_freq2;
457 chan->info = restart_params->info;
458 chan->reg_info_1 = restart_params->reg_info_1;
459 chan->reg_info_2 = restart_params->reg_info_2;
460
461 cmd->num_noa_descriptors = 0;
462 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
463 sizeof(wmi_channel));
464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
465 cmd->num_noa_descriptors *
466 sizeof(wmi_p2p_noa_descriptor));
467
468 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
469 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530470 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530471 wmi_buf_free(buf);
472 return QDF_STATUS_E_FAILURE;
473 }
474 return QDF_STATUS_SUCCESS;
475}
476
477
478/**
Govind Singh5eb51532016-03-09 11:34:12 +0530479 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
480 * @wmi: wmi handle
481 * @peer_addr: peer mac address
482 * @param: pointer to hold peer flush tid parameter
483 *
484 * Return: 0 for sucess or error code
485 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530486static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530487 uint8_t peer_addr[IEEE80211_ADDR_LEN],
488 struct peer_flush_params *param)
489{
490 wmi_peer_flush_tids_cmd_fixed_param *cmd;
491 wmi_buf_t buf;
492 int32_t len = sizeof(*cmd);
493
494 buf = wmi_buf_alloc(wmi, len);
495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530496 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530497 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530498 }
499 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
500 WMITLV_SET_HDR(&cmd->tlv_header,
501 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
502 WMITLV_GET_STRUCT_TLVLEN
503 (wmi_peer_flush_tids_cmd_fixed_param));
504 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
505 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
506 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530507 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530508 peer_addr, param->vdev_id,
509 param->peer_tid_bitmap);
510 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530511 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530512 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530513 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530514 }
515
516 return 0;
517}
518
519/**
520 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
521 * @wmi: wmi handle
522 * @peer_addr: peer mac addr
523 * @vdev_id: vdev id
524 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530525 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530526 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530527static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530528 uint8_t peer_addr[IEEE80211_ADDR_LEN],
529 uint8_t vdev_id)
530{
531 wmi_peer_delete_cmd_fixed_param *cmd;
532 wmi_buf_t buf;
533 int32_t len = sizeof(*cmd);
534 buf = wmi_buf_alloc(wmi, len);
535 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530536 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530537 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530538 }
539 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
540 WMITLV_SET_HDR(&cmd->tlv_header,
541 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
542 WMITLV_GET_STRUCT_TLVLEN
543 (wmi_peer_delete_cmd_fixed_param));
544 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
545 cmd->vdev_id = vdev_id;
546
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800547 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530548 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530549 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530550 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530551 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530552 }
Govind Singh5eb51532016-03-09 11:34:12 +0530553
554 return 0;
555}
556
557/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530558 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
559 * to target id.
560 * @targ_paramid: Target parameter id to hold the result.
561 * @peer_param_id: host param id.
562 *
563 * Return: QDF_STATUS_SUCCESS for success
564 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
565 */
566#ifdef CONFIG_MCL
567static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
568 uint32_t *targ_paramid,
569 uint32_t peer_param_id)
570{
571 *targ_paramid = peer_param_id;
572 return QDF_STATUS_SUCCESS;
573}
574#else
575static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
576 uint32_t *targ_paramid,
577 uint32_t peer_param_id)
578{
579 switch (peer_param_id) {
580 case WMI_HOST_PEER_MIMO_PS_STATE:
581 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
582 break;
583 case WMI_HOST_PEER_AMPDU:
584 *targ_paramid = WMI_PEER_AMPDU;
585 break;
586 case WMI_HOST_PEER_AUTHORIZE:
587 *targ_paramid = WMI_PEER_AUTHORIZE;
588 break;
589 case WMI_HOST_PEER_CHWIDTH:
590 *targ_paramid = WMI_PEER_CHWIDTH;
591 break;
592 case WMI_HOST_PEER_NSS:
593 *targ_paramid = WMI_PEER_NSS;
594 break;
595 case WMI_HOST_PEER_USE_4ADDR:
596 *targ_paramid = WMI_PEER_USE_4ADDR;
597 break;
598 case WMI_HOST_PEER_MEMBERSHIP:
599 *targ_paramid = WMI_PEER_MEMBERSHIP;
600 break;
601 case WMI_HOST_PEER_USERPOS:
602 *targ_paramid = WMI_PEER_USERPOS;
603 break;
604 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
605 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
606 break;
607 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
608 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
609 break;
610 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
611 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
612 break;
613 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
614 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
615 break;
616 case WMI_HOST_PEER_PHYMODE:
617 *targ_paramid = WMI_PEER_PHYMODE;
618 break;
619 case WMI_HOST_PEER_USE_FIXED_PWR:
620 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
621 break;
622 case WMI_HOST_PEER_PARAM_FIXED_RATE:
623 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
624 break;
625 case WMI_HOST_PEER_SET_MU_WHITELIST:
626 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
627 break;
628 case WMI_HOST_PEER_SET_MAC_TX_RATE:
629 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
630 break;
631 case WMI_HOST_PEER_SET_MIN_TX_RATE:
632 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
633 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530634 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
635 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
636 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530637 case WMI_HOST_PEER_NSS_VHT160:
638 *targ_paramid = WMI_PEER_NSS_VHT160;
639 break;
640 case WMI_HOST_PEER_NSS_VHT80_80:
641 *targ_paramid = WMI_PEER_NSS_VHT80_80;
642 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530643 default:
644 return QDF_STATUS_E_NOSUPPORT;
645 }
646
647 return QDF_STATUS_SUCCESS;
648}
649#endif
650/**
Govind Singh5eb51532016-03-09 11:34:12 +0530651 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530652 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530653 * @peer_addr: peer mac address
654 * @param : pointer to hold peer set parameter
655 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530656 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530657 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530658static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530659 uint8_t peer_addr[IEEE80211_ADDR_LEN],
660 struct peer_set_params *param)
661{
662 wmi_peer_set_param_cmd_fixed_param *cmd;
663 wmi_buf_t buf;
664 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530665 uint32_t param_id;
666
667 if (convert_host_peer_id_to_target_id_tlv(&param_id,
668 param->param_id) != QDF_STATUS_SUCCESS)
669 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530670
671 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
672 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530673 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530674 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530675 }
676 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
677 WMITLV_SET_HDR(&cmd->tlv_header,
678 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
679 WMITLV_GET_STRUCT_TLVLEN
680 (wmi_peer_set_param_cmd_fixed_param));
681 cmd->vdev_id = param->vdev_id;
682 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530683 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530684 cmd->param_value = param->param_value;
685 err = wmi_unified_cmd_send(wmi, buf,
686 sizeof(wmi_peer_set_param_cmd_fixed_param),
687 WMI_PEER_SET_PARAM_CMDID);
688 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530689 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530690 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530691 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530692 }
693
694 return 0;
695}
696
697/**
698 * send_vdev_up_cmd_tlv() - send vdev up command in fw
699 * @wmi: wmi handle
700 * @bssid: bssid
701 * @vdev_up_params: pointer to hold vdev up parameter
702 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530703 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530704 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530705static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530706 uint8_t bssid[IEEE80211_ADDR_LEN],
707 struct vdev_up_params *params)
708{
709 wmi_vdev_up_cmd_fixed_param *cmd;
710 wmi_buf_t buf;
711 int32_t len = sizeof(*cmd);
712
Govind Singhb53420c2016-03-09 14:32:57 +0530713 WMI_LOGD("%s: VDEV_UP", __func__);
714 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530715 params->vdev_id, params->assoc_id, bssid);
716 buf = wmi_buf_alloc(wmi, len);
717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530718 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530719 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530720 }
721 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
722 WMITLV_SET_HDR(&cmd->tlv_header,
723 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
724 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
725 cmd->vdev_id = params->vdev_id;
726 cmd->vdev_assoc_id = params->assoc_id;
727 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
728 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530729 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530730 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530731 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530732 }
733
734 return 0;
735}
736
737/**
738 * send_peer_create_cmd_tlv() - send peer create command to fw
739 * @wmi: wmi handle
740 * @peer_addr: peer mac address
741 * @peer_type: peer type
742 * @vdev_id: vdev id
743 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530744 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530745 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530746static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530747 struct peer_create_params *param)
748{
749 wmi_peer_create_cmd_fixed_param *cmd;
750 wmi_buf_t buf;
751 int32_t len = sizeof(*cmd);
752
753 buf = wmi_buf_alloc(wmi, len);
754 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530755 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530756 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530757 }
758 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
759 WMITLV_SET_HDR(&cmd->tlv_header,
760 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
761 WMITLV_GET_STRUCT_TLVLEN
762 (wmi_peer_create_cmd_fixed_param));
763 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
764 cmd->peer_type = param->peer_type;
765 cmd->vdev_id = param->vdev_id;
766
767 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530768 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530769 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530770 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530771 }
Govind Singhb53420c2016-03-09 14:32:57 +0530772 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530773 param->vdev_id);
774
775 return 0;
776}
777
778/**
Leo Changeee40872016-09-28 13:43:36 -0700779 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
780 * command to fw
781 * @wmi: wmi handle
782 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
783 *
784 * Return: 0 for success or error code
785 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700786static
Leo Changeee40872016-09-28 13:43:36 -0700787QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
788 struct rx_reorder_queue_setup_params *param)
789{
790 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
791 wmi_buf_t buf;
792 int32_t len = sizeof(*cmd);
793
794 buf = wmi_buf_alloc(wmi, len);
795 if (!buf) {
796 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
797 return QDF_STATUS_E_NOMEM;
798 }
799 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
800 WMITLV_SET_HDR(&cmd->tlv_header,
801 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
802 WMITLV_GET_STRUCT_TLVLEN
803 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
804 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
805 cmd->vdev_id = param->vdev_id;
806 cmd->tid = param->tid;
807 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
808 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
809 cmd->queue_no = param->queue_no;
810
811 if (wmi_unified_cmd_send(wmi, buf, len,
812 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
813 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
814 __func__);
815 qdf_nbuf_free(buf);
816 return QDF_STATUS_E_FAILURE;
817 }
818 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
819 param->peer_macaddr, param->vdev_id, param->tid);
820
821 return QDF_STATUS_SUCCESS;
822}
823
824/**
825 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
826 * command to fw
827 * @wmi: wmi handle
828 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
829 *
830 * Return: 0 for success or error code
831 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700832static
Leo Changeee40872016-09-28 13:43:36 -0700833QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
834 struct rx_reorder_queue_remove_params *param)
835{
836 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
837 wmi_buf_t buf;
838 int32_t len = sizeof(*cmd);
839
840 buf = wmi_buf_alloc(wmi, len);
841 if (!buf) {
842 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
843 return QDF_STATUS_E_NOMEM;
844 }
845 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
846 wmi_buf_data(buf);
847 WMITLV_SET_HDR(&cmd->tlv_header,
848 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
849 WMITLV_GET_STRUCT_TLVLEN
850 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
851 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
852 cmd->vdev_id = param->vdev_id;
853 cmd->tid_mask = param->peer_tid_bitmap;
854
855 if (wmi_unified_cmd_send(wmi, buf, len,
856 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
857 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
858 __func__);
859 qdf_nbuf_free(buf);
860 return QDF_STATUS_E_FAILURE;
861 }
862 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
863 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
864
865 return QDF_STATUS_SUCCESS;
866}
867
868/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530869 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
870 * @wmi_handle: wmi handle
871 * @param: pointer holding peer details
872 *
873 * Return: 0 for success or error code
874 */
875static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
876 struct peer_add_wds_entry_params *param)
877{
878 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
879 wmi_buf_t buf;
880 int len = sizeof(*cmd);
881
882 buf = wmi_buf_alloc(wmi_handle, len);
883 if (!buf) {
884 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
885 return QDF_STATUS_E_FAILURE;
886 }
887 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
888 WMITLV_SET_HDR(&cmd->tlv_header,
889 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
890 WMITLV_GET_STRUCT_TLVLEN
891 (wmi_peer_add_wds_entry_cmd_fixed_param));
892 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
893 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
894 cmd->flags = param->flags;
895
896 return wmi_unified_cmd_send(wmi_handle, buf, len,
897 WMI_PEER_ADD_WDS_ENTRY_CMDID);
898}
899
900/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530901 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530902 * @wmi_handle: wmi handle
903 * @param: pointer holding peer details
904 *
905 * Return: 0 for success or error code
906 */
907static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
908 struct peer_del_wds_entry_params *param)
909{
910 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
911 wmi_buf_t buf;
912 int len = sizeof(*cmd);
913
914 buf = wmi_buf_alloc(wmi_handle, len);
915 if (!buf) {
916 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
917 return QDF_STATUS_E_NOMEM;
918 }
919 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
920 WMITLV_SET_HDR(&cmd->tlv_header,
921 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
922 WMITLV_GET_STRUCT_TLVLEN
923 (wmi_peer_remove_wds_entry_cmd_fixed_param));
924 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
925 return wmi_unified_cmd_send(wmi_handle, buf, len,
926 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
927}
928
929/**
930 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
931 * @wmi_handle: wmi handle
932 * @param: pointer holding peer details
933 *
934 * Return: 0 for success or error code
935 */
936static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
937 struct peer_update_wds_entry_params *param)
938{
939 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
940 wmi_buf_t buf;
941 int len = sizeof(*cmd);
942
943 buf = wmi_buf_alloc(wmi_handle, len);
944 if (!buf) {
945 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
946 return QDF_STATUS_E_NOMEM;
947 }
948
949 /* wmi_buf_alloc returns zeroed command buffer */
950 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
951 WMITLV_SET_HDR(&cmd->tlv_header,
952 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
953 WMITLV_GET_STRUCT_TLVLEN
954 (wmi_peer_update_wds_entry_cmd_fixed_param));
955 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
956 if (param->wds_macaddr)
957 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
958 &cmd->wds_macaddr);
959 if (param->peer_macaddr)
960 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
961 &cmd->peer_macaddr);
962 return wmi_unified_cmd_send(wmi_handle, buf, len,
963 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
964}
965
966
967
968/**
Govind Singh5eb51532016-03-09 11:34:12 +0530969 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
970 * @wmi_handle: wmi handle
971 * @value: value
972 * @mac_id: mac id to have radio context
973 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530974 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530975 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530976static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530977 uint32_t value, uint8_t mac_id)
978{
979 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
980 wmi_buf_t buf;
981 int32_t len = sizeof(*cmd);
982
Govind Singhb53420c2016-03-09 14:32:57 +0530983 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530984
985 buf = wmi_buf_alloc(wmi_handle, len);
986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530987 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530988 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530989 }
990
991 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
992 WMITLV_SET_HDR(&cmd->tlv_header,
993 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
994 WMITLV_GET_STRUCT_TLVLEN
995 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530996 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530997 cmd->enable = value;
998
999 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1000 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301001 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301002 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301003 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301004 }
1005
1006 return 0;
1007}
1008
1009/**
1010 * send_pdev_utf_cmd_tlv() - send utf command to fw
1011 * @wmi_handle: wmi handle
1012 * @param: pointer to pdev_utf_params
1013 * @mac_id: mac id to have radio context
1014 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301015 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301016 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301017static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301018send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1019 struct pdev_utf_params *param,
1020 uint8_t mac_id)
1021{
1022 wmi_buf_t buf;
1023 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001024 /* if param->len is 0 no data is sent, return error */
1025 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301026 static uint8_t msgref = 1;
1027 uint8_t segNumber = 0, segInfo, numSegments;
1028 uint16_t chunk_len, total_bytes;
1029 uint8_t *bufpos;
1030 struct seg_hdr_info segHdrInfo;
1031
1032 bufpos = param->utf_payload;
1033 total_bytes = param->len;
1034 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1035 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1036 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1037
1038 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1039 numSegments++;
1040
1041 while (param->len) {
1042 if (param->len > MAX_WMI_UTF_LEN)
1043 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1044 else
1045 chunk_len = param->len;
1046
1047 buf = wmi_buf_alloc(wmi_handle,
1048 (chunk_len + sizeof(segHdrInfo) +
1049 WMI_TLV_HDR_SIZE));
1050 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301051 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301052 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301053 }
1054
1055 cmd = (uint8_t *) wmi_buf_data(buf);
1056
1057 segHdrInfo.len = total_bytes;
1058 segHdrInfo.msgref = msgref;
1059 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1060 segHdrInfo.segmentInfo = segInfo;
1061 segHdrInfo.pad = 0;
1062
Govind Singhb53420c2016-03-09 14:32:57 +05301063 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301064 " segHdrInfo.segmentInfo = %d",
1065 __func__, segHdrInfo.len, segHdrInfo.msgref,
1066 segHdrInfo.segmentInfo);
1067
Govind Singhb53420c2016-03-09 14:32:57 +05301068 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301069 "chunk len %d", __func__, total_bytes, segNumber,
1070 numSegments, chunk_len);
1071
1072 segNumber++;
1073
1074 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1075 (chunk_len + sizeof(segHdrInfo)));
1076 cmd += WMI_TLV_HDR_SIZE;
1077 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1078 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1079
1080 ret = wmi_unified_cmd_send(wmi_handle, buf,
1081 (chunk_len + sizeof(segHdrInfo) +
1082 WMI_TLV_HDR_SIZE),
1083 WMI_PDEV_UTF_CMDID);
1084
Govind Singh67922e82016-04-01 16:48:57 +05301085 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301086 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301087 wmi_buf_free(buf);
1088 break;
1089 }
1090
1091 param->len -= chunk_len;
1092 bufpos += chunk_len;
1093 }
1094
1095 msgref++;
1096
1097 return ret;
1098}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301099#ifdef CONFIG_MCL
1100static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1101 uint32_t host_param)
1102{
1103 return host_param;
1104}
1105#else
1106static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1107 uint32_t host_param)
1108{
1109 if (host_param < wmi_pdev_param_max)
1110 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301111
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301112 return WMI_UNAVAILABLE_PARAM;
1113}
1114#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301115/**
1116 * send_pdev_param_cmd_tlv() - set pdev parameters
1117 * @wmi_handle: wmi handle
1118 * @param: pointer to pdev parameter
1119 * @mac_id: radio context
1120 *
1121 * Return: 0 on success, errno on failure
1122 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301123static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301124send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1125 struct pdev_params *param,
1126 uint8_t mac_id)
1127{
Govind Singh67922e82016-04-01 16:48:57 +05301128 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301129 wmi_pdev_set_param_cmd_fixed_param *cmd;
1130 wmi_buf_t buf;
1131 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301132 uint32_t pdev_param;
1133
1134 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1135 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1136 WMI_LOGW("%s: Unavailable param %d\n",
1137 __func__, param->param_id);
1138 return QDF_STATUS_E_INVAL;
1139 }
Govind Singh5eb51532016-03-09 11:34:12 +05301140
1141 buf = wmi_buf_alloc(wmi_handle, len);
1142 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301143 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301144 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301145 }
1146 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1147 WMITLV_SET_HDR(&cmd->tlv_header,
1148 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1149 WMITLV_GET_STRUCT_TLVLEN
1150 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301151 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301152 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301153 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301154 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301155 param->param_value);
1156 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1157 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301158 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301159 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301160 wmi_buf_free(buf);
1161 }
1162 return ret;
1163}
1164
1165/**
1166 * send_suspend_cmd_tlv() - WMI suspend function
1167 * @param wmi_handle : handle to WMI.
1168 * @param param : pointer to hold suspend parameter
1169 * @mac_id: radio context
1170 *
1171 * Return 0 on success and -ve on failure.
1172 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301173static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301174 struct suspend_params *param,
1175 uint8_t mac_id)
1176{
1177 wmi_pdev_suspend_cmd_fixed_param *cmd;
1178 wmi_buf_t wmibuf;
1179 uint32_t len = sizeof(*cmd);
1180 int32_t ret;
1181
1182 /*
1183 * send the comand to Target to ignore the
1184 * PCIE reset so as to ensure that Host and target
1185 * states are in sync
1186 */
1187 wmibuf = wmi_buf_alloc(wmi_handle, len);
1188 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301189 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301190
1191 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1192 WMITLV_SET_HDR(&cmd->tlv_header,
1193 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1194 WMITLV_GET_STRUCT_TLVLEN
1195 (wmi_pdev_suspend_cmd_fixed_param));
1196 if (param->disable_target_intr)
1197 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1198 else
1199 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301200
1201 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1202
Govind Singh5eb51532016-03-09 11:34:12 +05301203 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1204 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301205 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301206 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301207 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301208 }
1209
1210 return ret;
1211}
1212
1213/**
1214 * send_resume_cmd_tlv() - WMI resume function
1215 * @param wmi_handle : handle to WMI.
1216 * @mac_id: radio context
1217 *
1218 * Return: 0 on success and -ve on failure.
1219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301220static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301221 uint8_t mac_id)
1222{
1223 wmi_buf_t wmibuf;
1224 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301225 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301226
1227 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1228 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301229 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301230 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1231 WMITLV_SET_HDR(&cmd->tlv_header,
1232 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1233 WMITLV_GET_STRUCT_TLVLEN
1234 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301235 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301236 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1237 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301238 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301239 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301240 wmi_buf_free(wmibuf);
1241 }
1242
1243 return ret;
1244}
1245
1246/**
1247 * send_wow_enable_cmd_tlv() - WMI wow enable function
1248 * @param wmi_handle : handle to WMI.
1249 * @param param : pointer to hold wow enable parameter
1250 * @mac_id: radio context
1251 *
1252 * Return: 0 on success and -ve on failure.
1253 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301254static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301255 struct wow_cmd_params *param,
1256 uint8_t mac_id)
1257{
1258 wmi_wow_enable_cmd_fixed_param *cmd;
1259 wmi_buf_t buf;
1260 int32_t len;
1261 int32_t ret;
1262
1263 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1264
1265 buf = wmi_buf_alloc(wmi_handle, len);
1266 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301267 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1268 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301269 }
1270 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1271 WMITLV_SET_HDR(&cmd->tlv_header,
1272 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1273 WMITLV_GET_STRUCT_TLVLEN
1274 (wmi_wow_enable_cmd_fixed_param));
1275 cmd->enable = param->enable;
1276 if (param->can_suspend_link)
1277 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1278 else
1279 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001280 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301281
Govind Singhb53420c2016-03-09 14:32:57 +05301282 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301283 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1284 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1285
1286 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1287 WMI_WOW_ENABLE_CMDID);
1288 if (ret)
1289 wmi_buf_free(buf);
1290
1291 return ret;
1292}
1293
1294/**
1295 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301296 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301297 * @peer_addr: peer mac address
1298 * @param: pointer to ap_ps parameter structure
1299 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301300 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301301 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301302static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301303 uint8_t *peer_addr,
1304 struct ap_ps_params *param)
1305{
1306 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1307 wmi_buf_t buf;
1308 int32_t err;
1309
1310 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301312 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301313 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301314 }
1315 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1316 WMITLV_SET_HDR(&cmd->tlv_header,
1317 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1318 WMITLV_GET_STRUCT_TLVLEN
1319 (wmi_ap_ps_peer_cmd_fixed_param));
1320 cmd->vdev_id = param->vdev_id;
1321 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1322 cmd->param = param->param;
1323 cmd->value = param->value;
1324 err = wmi_unified_cmd_send(wmi_handle, buf,
1325 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1326 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301327 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301328 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301329 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301330 }
1331
1332 return 0;
1333}
1334
1335/**
1336 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301337 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301338 * @peer_addr: peer mac address
1339 * @param: pointer to sta_ps parameter structure
1340 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301341 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301342 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301343static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301344 struct sta_ps_params *param)
1345{
1346 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1347 wmi_buf_t buf;
1348 int32_t len = sizeof(*cmd);
1349
1350 buf = wmi_buf_alloc(wmi_handle, len);
1351 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301352 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301353 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301354 }
1355
1356 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1357 WMITLV_SET_HDR(&cmd->tlv_header,
1358 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1359 WMITLV_GET_STRUCT_TLVLEN
1360 (wmi_sta_powersave_param_cmd_fixed_param));
1361 cmd->vdev_id = param->vdev_id;
1362 cmd->param = param->param;
1363 cmd->value = param->value;
1364
1365 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1366 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301367 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301368 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301369 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301370 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301371 }
1372
1373 return 0;
1374}
1375
1376/**
1377 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301378 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301379 * @param: ponirt to crash inject paramter structure
1380 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301381 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301382 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301383static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301384 struct crash_inject *param)
1385{
1386 int32_t ret = 0;
1387 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1388 uint16_t len = sizeof(*cmd);
1389 wmi_buf_t buf;
1390
1391 buf = wmi_buf_alloc(wmi_handle, len);
1392 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301393 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301394 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301395 }
1396
1397 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1398 WMITLV_SET_HDR(&cmd->tlv_header,
1399 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1400 WMITLV_GET_STRUCT_TLVLEN
1401 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1402 cmd->type = param->type;
1403 cmd->delay_time_ms = param->delay_time_ms;
1404
1405 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1406 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301407 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301408 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301409 __func__, ret);
1410 wmi_buf_free(buf);
1411 }
1412
1413 return ret;
1414}
1415
1416/**
1417 * send_dbglog_cmd_tlv() - set debug log level
1418 * @param wmi_handle : handle to WMI.
1419 * @param param : pointer to hold dbglog level parameter
1420 *
1421 * Return: 0 on success and -ve on failure.
1422 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301423 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301424send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1425 struct dbglog_params *dbglog_param)
1426{
1427 wmi_buf_t buf;
1428 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001429 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301430 int32_t i;
1431 int32_t len;
1432 int8_t *buf_ptr;
1433 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1434
1435 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1436
1437 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1438 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1439 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1440 buf = wmi_buf_alloc(wmi_handle, len);
1441 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001442 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301443
1444 configmsg =
1445 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1446 buf_ptr = (int8_t *) configmsg;
1447 WMITLV_SET_HDR(&configmsg->tlv_header,
1448 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1449 WMITLV_GET_STRUCT_TLVLEN
1450 (wmi_debug_log_config_cmd_fixed_param));
1451 configmsg->dbg_log_param = dbglog_param->param;
1452 configmsg->value = dbglog_param->val;
1453 /* Filling in the data part of second tlv -- should
1454 * follow first tlv _ WMI_TLV_HDR_SIZE */
1455 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1456 sizeof
1457 (wmi_debug_log_config_cmd_fixed_param)
1458 + WMI_TLV_HDR_SIZE);
1459 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1460 WMITLV_TAG_ARRAY_UINT32,
1461 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1462 if (dbglog_param->module_id_bitmap) {
1463 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1464 module_id_bitmap_array[i] =
1465 dbglog_param->module_id_bitmap[i];
1466 }
1467 }
1468
1469 status = wmi_unified_cmd_send(wmi_handle, buf,
1470 len, WMI_DBGLOG_CFG_CMDID);
1471
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001472 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301473 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301474
1475 return status;
1476}
1477
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301478#ifdef CONFIG_MCL
1479static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1480 uint32_t host_param)
1481{
1482 return host_param;
1483}
1484#else
1485static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1486 uint32_t host_param)
1487{
1488 if (host_param < wmi_vdev_param_max)
1489 return wmi_handle->vdev_param[host_param];
1490
1491 return WMI_UNAVAILABLE_PARAM;
1492}
1493#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301494/**
1495 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1496 * @param wmi_handle : handle to WMI.
1497 * @param macaddr : MAC address
1498 * @param param : pointer to hold vdev set parameter
1499 *
1500 * Return: 0 on success and -ve on failure.
1501 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301502static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301503 struct vdev_set_params *param)
1504{
Govind Singh67922e82016-04-01 16:48:57 +05301505 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301506 wmi_vdev_set_param_cmd_fixed_param *cmd;
1507 wmi_buf_t buf;
1508 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301509 uint32_t vdev_param;
1510
1511 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1512 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1513 WMI_LOGW("%s:Vdev param %d not available", __func__,
1514 param->param_id);
1515 return QDF_STATUS_E_INVAL;
1516
1517 }
Govind Singh5eb51532016-03-09 11:34:12 +05301518
1519 buf = wmi_buf_alloc(wmi_handle, len);
1520 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301521 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301522 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301523 }
1524 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1525 WMITLV_SET_HDR(&cmd->tlv_header,
1526 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1527 WMITLV_GET_STRUCT_TLVLEN
1528 (wmi_vdev_set_param_cmd_fixed_param));
1529 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301530 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301531 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301532 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301533 param->if_id, param->param_id, param->param_value);
1534 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1535 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301536 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301537 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301538 wmi_buf_free(buf);
1539 }
1540
1541 return ret;
1542}
1543
1544/**
1545 * send_stats_request_cmd_tlv() - WMI request stats function
1546 * @param wmi_handle : handle to WMI.
1547 * @param macaddr : MAC address
1548 * @param param : pointer to hold stats request parameter
1549 *
1550 * Return: 0 on success and -ve on failure.
1551 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301552static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301553 uint8_t macaddr[IEEE80211_ADDR_LEN],
1554 struct stats_request_params *param)
1555{
Govind Singhd3156eb2016-02-26 17:50:39 +05301556 int32_t ret;
1557 wmi_request_stats_cmd_fixed_param *cmd;
1558 wmi_buf_t buf;
1559 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1560
1561 buf = wmi_buf_alloc(wmi_handle, len);
1562 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301563 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1564 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301565 }
1566
1567 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1568 WMITLV_SET_HDR(&cmd->tlv_header,
1569 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1570 WMITLV_GET_STRUCT_TLVLEN
1571 (wmi_request_stats_cmd_fixed_param));
1572 cmd->stats_id = param->stats_id;
1573 cmd->vdev_id = param->vdev_id;
1574 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1575 WMI_REQUEST_STATS_CMDID);
1576 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301577 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301578 wmi_buf_free(buf);
1579 }
1580
1581 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301582}
1583
Govind Singh87542482016-06-08 19:40:11 +05301584#ifdef CONFIG_WIN
1585/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001586 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301587 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001588 * @param PKTLOG_EVENT : packet log event
1589 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301590 *
1591 * Return: 0 on success and -ve on failure.
1592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301593static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001594 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301595{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001596 int32_t ret;
1597 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1598 wmi_buf_t buf;
1599 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1600
1601 buf = wmi_buf_alloc(wmi_handle, len);
1602 if (!buf) {
1603 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1604 return -QDF_STATUS_E_NOMEM;
1605 }
1606
1607 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1608 WMITLV_SET_HDR(&cmd->tlv_header,
1609 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1610 WMITLV_GET_STRUCT_TLVLEN
1611 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1612 cmd->evlist = PKTLOG_EVENT;
1613 cmd->pdev_id = mac_id;
1614 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1615 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1616 if (ret) {
1617 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1618 wmi_buf_free(buf);
1619 }
1620
1621 return ret;
1622}
1623
1624/**
1625 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1626 * @param wmi_handle : handle to WMI.
1627 * @mac_id: mac id to have radio context
1628 *
1629 * Return: 0 on success and -ve on failure.
1630 */
1631static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001632 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001633{
1634 int32_t ret;
1635 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1636 wmi_buf_t buf;
1637 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1638
1639 buf = wmi_buf_alloc(wmi_handle, len);
1640 if (!buf) {
1641 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1642 return -QDF_STATUS_E_NOMEM;
1643 }
1644
1645 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1646 WMITLV_SET_HDR(&cmd->tlv_header,
1647 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1648 WMITLV_GET_STRUCT_TLVLEN
1649 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1650 cmd->pdev_id = mac_id;
1651 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1652 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1653 if (ret) {
1654 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1655 wmi_buf_free(buf);
1656 }
1657
1658 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301659}
1660#else
Govind Singh5eb51532016-03-09 11:34:12 +05301661/**
Keyur Parekhde522342017-08-18 14:01:05 -07001662 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1663 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301664 * @param wmi_handle : handle to WMI.
1665 * @param macaddr : MAC address
1666 * @param param : pointer to hold stats request parameter
1667 *
1668 * Return: 0 on success and -ve on failure.
1669 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301670static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301671 uint8_t macaddr[IEEE80211_ADDR_LEN],
1672 struct packet_enable_params *param)
1673{
1674 return 0;
1675}
Keyur Parekhde522342017-08-18 14:01:05 -07001676/**
1677 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1678 * packet-log
1679 * @param wmi_handle : handle to WMI.
1680 * @mac_id: mac id to have radio context
1681 *
1682 * Return: 0 on success and -ve on failure.
1683 */
1684static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1685 uint8_t mac_id)
1686{
1687 return 0;
1688}
Govind Singh87542482016-06-08 19:40:11 +05301689#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301690
Sathish Kumarfd347372017-02-13 12:29:09 +05301691static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301692 struct beacon_params *param)
1693{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301694 QDF_STATUS ret;
1695 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1696 wmi_buf_t wmi_buf;
1697 qdf_dma_addr_t dma_addr;
1698 uint32_t dtim_flag = 0;
1699
1700 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1701 if (!wmi_buf) {
1702 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1703 return QDF_STATUS_E_NOMEM;
1704 }
1705 if (param->is_dtim_count_zero) {
1706 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1707 if (param->is_bitctl_reqd) {
1708 /* deliver CAB traffic in next DTIM beacon */
1709 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1710 }
1711 }
1712 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1713 WMITLV_SET_HDR(&cmd->tlv_header,
1714 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1715 WMITLV_GET_STRUCT_TLVLEN
1716 (wmi_bcn_send_from_host_cmd_fixed_param));
1717 cmd->vdev_id = param->vdev_id;
1718 cmd->data_len = qdf_nbuf_len(param->wbuf);
1719 cmd->frame_ctrl = param->frame_ctrl;
1720 cmd->dtim_flag = dtim_flag;
1721 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1722 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1723#if defined(HTT_PADDR64)
1724 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1725#endif
1726 cmd->bcn_antenna = param->bcn_txant;
1727
1728 ret = wmi_unified_cmd_send(wmi_handle,
1729 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1730 if (ret != QDF_STATUS_SUCCESS) {
1731 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1732 wmi_buf_free(wmi_buf);
1733 }
1734
1735 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301736}
1737
1738/**
1739 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1740 * @param wmi_handle : handle to WMI.
1741 * @param param : pointer to hold beacon send cmd parameter
1742 *
1743 * Return: 0 on success and -ve on failure.
1744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301745static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301746 struct beacon_tmpl_params *param)
1747{
1748 int32_t ret;
1749 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1750 wmi_bcn_prb_info *bcn_prb_info;
1751 wmi_buf_t wmi_buf;
1752 uint8_t *buf_ptr;
1753 uint32_t wmi_buf_len;
1754
Sathish Kumar45e991b2017-02-27 10:35:40 +05301755 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301756 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1757 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1758 param->tmpl_len_aligned;
1759 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1760 if (!wmi_buf) {
1761 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1762 return QDF_STATUS_E_NOMEM;
1763 }
1764 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1765 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1766 WMITLV_SET_HDR(&cmd->tlv_header,
1767 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1768 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1769 cmd->vdev_id = param->vdev_id;
1770 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301771 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1772 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301773 cmd->buf_len = param->tmpl_len;
1774 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1775
1776 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1777 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1778 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1779 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1780 bcn_prb_info->caps = 0;
1781 bcn_prb_info->erp = 0;
1782 buf_ptr += sizeof(wmi_bcn_prb_info);
1783
1784 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1785 buf_ptr += WMI_TLV_HDR_SIZE;
1786 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1787
1788 ret = wmi_unified_cmd_send(wmi_handle,
1789 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1790 if (ret) {
1791 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1792 wmi_buf_free(wmi_buf);
1793 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301794
Govind Singh87542482016-06-08 19:40:11 +05301795 return 0;
1796}
Govind Singh5eb51532016-03-09 11:34:12 +05301797
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301798#ifdef CONFIG_MCL
1799static inline void copy_peer_flags_tlv(
1800 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1801 struct peer_assoc_params *param)
1802{
1803 cmd->peer_flags = param->peer_flags;
1804}
1805#else
1806static inline void copy_peer_flags_tlv(
1807 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1808 struct peer_assoc_params *param)
1809{
1810 /*
1811 * The target only needs a subset of the flags maintained in the host.
1812 * Just populate those flags and send it down
1813 */
1814 cmd->peer_flags = 0;
1815
1816 /*
1817 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1818 */
1819 if (param->is_wme_set) {
1820
1821 if (param->qos_flag)
1822 cmd->peer_flags |= WMI_PEER_QOS;
1823 if (param->apsd_flag)
1824 cmd->peer_flags |= WMI_PEER_APSD;
1825 if (param->ht_flag)
1826 cmd->peer_flags |= WMI_PEER_HT;
1827 if (param->bw_40)
1828 cmd->peer_flags |= WMI_PEER_40MHZ;
1829 if (param->bw_80)
1830 cmd->peer_flags |= WMI_PEER_80MHZ;
1831 if (param->bw_160)
1832 cmd->peer_flags |= WMI_PEER_160MHZ;
1833
1834 /* Typically if STBC is enabled for VHT it should be enabled
1835 * for HT as well
1836 **/
1837 if (param->stbc_flag)
1838 cmd->peer_flags |= WMI_PEER_STBC;
1839
1840 /* Typically if LDPC is enabled for VHT it should be enabled
1841 * for HT as well
1842 **/
1843 if (param->ldpc_flag)
1844 cmd->peer_flags |= WMI_PEER_LDPC;
1845
1846 if (param->static_mimops_flag)
1847 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1848 if (param->dynamic_mimops_flag)
1849 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1850 if (param->spatial_mux_flag)
1851 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1852 if (param->vht_flag)
1853 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001854 if (param->he_flag)
1855 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301856 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001857
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301858 if (param->is_pmf_enabled)
1859 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301860 /*
1861 * Suppress authorization for all AUTH modes that need 4-way handshake
1862 * (during re-association).
1863 * Authorization will be done for these modes on key installation.
1864 */
1865 if (param->auth_flag)
1866 cmd->peer_flags |= WMI_PEER_AUTH;
1867 if (param->need_ptk_4_way)
1868 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1869 else
1870 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1871 if (param->need_gtk_2_way)
1872 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1873 /* safe mode bypass the 4-way handshake */
1874 if (param->safe_mode_enabled)
1875 cmd->peer_flags &=
1876 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1877 /* Disable AMSDU for station transmit, if user configures it */
1878 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1879 * it
1880 * if (param->amsdu_disable) Add after FW support
1881 **/
1882
1883 /* Target asserts if node is marked HT and all MCS is set to 0.
1884 * Mark the node as non-HT if all the mcs rates are disabled through
1885 * iwpriv
1886 **/
1887 if (param->peer_ht_rates.num_rates == 0)
1888 cmd->peer_flags &= ~WMI_PEER_HT;
1889}
1890#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301891
1892#ifdef CONFIG_MCL
1893static inline void copy_peer_mac_addr_tlv(
1894 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1895 struct peer_assoc_params *param)
1896{
1897 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1898 sizeof(param->peer_macaddr));
1899}
1900#else
1901static inline void copy_peer_mac_addr_tlv(
1902 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1903 struct peer_assoc_params *param)
1904{
1905 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1906}
1907#endif
1908
Govind Singh5eb51532016-03-09 11:34:12 +05301909/**
1910 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1911 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301912 * @param param : pointer to peer assoc parameter
1913 *
1914 * Return: 0 on success and -ve on failure.
1915 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301916static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301917 struct peer_assoc_params *param)
1918{
Govind Singhd3156eb2016-02-26 17:50:39 +05301919 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1920 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001921 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301922 wmi_buf_t buf;
1923 int32_t len;
1924 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301925 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301926 uint32_t peer_legacy_rates_align;
1927 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001928 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301929
1930
1931 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1932 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301933
1934 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001935 (peer_legacy_rates_align * sizeof(uint8_t)) +
1936 WMI_TLV_HDR_SIZE +
1937 (peer_ht_rates_align * sizeof(uint8_t)) +
1938 sizeof(wmi_vht_rate_set) +
1939 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1940 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301941
1942 buf = wmi_buf_alloc(wmi_handle, len);
1943 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301944 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301945 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301946 }
1947
1948 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1949 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1950 WMITLV_SET_HDR(&cmd->tlv_header,
1951 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1952 WMITLV_GET_STRUCT_TLVLEN
1953 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301954
Govind Singhd3156eb2016-02-26 17:50:39 +05301955 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301956
Govind Singhd3156eb2016-02-26 17:50:39 +05301957 cmd->peer_new_assoc = param->peer_new_assoc;
1958 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301959
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301960 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301961 copy_peer_mac_addr_tlv(cmd, param);
1962
Govind Singhd3156eb2016-02-26 17:50:39 +05301963 cmd->peer_rate_caps = param->peer_rate_caps;
1964 cmd->peer_caps = param->peer_caps;
1965 cmd->peer_listen_intval = param->peer_listen_intval;
1966 cmd->peer_ht_caps = param->peer_ht_caps;
1967 cmd->peer_max_mpdu = param->peer_max_mpdu;
1968 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 cmd->peer_vht_caps = param->peer_vht_caps;
1970 cmd->peer_phymode = param->peer_phymode;
1971
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001972 /* Update 11ax capabilities */
1973 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1974 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001975 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1976 sizeof(param->peer_he_cap_phyinfo));
1977 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1978 sizeof(param->peer_ppet));
1979
Govind Singhd3156eb2016-02-26 17:50:39 +05301980 /* Update peer legacy rate information */
1981 buf_ptr += sizeof(*cmd);
1982 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301983 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301984 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301985 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301986 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 param->peer_legacy_rates.num_rates);
1988
1989 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001990 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301991 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301992 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301993 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301994 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301995 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301996 param->peer_ht_rates.num_rates);
1997
1998 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001999 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302000 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2001 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2002
2003 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302004
2005 /* Update bandwidth-NSS mapping */
2006 cmd->peer_bw_rxnss_override = 0;
2007 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2008
Govind Singhd3156eb2016-02-26 17:50:39 +05302009 mcs = (wmi_vht_rate_set *) buf_ptr;
2010 if (param->vht_capable) {
2011 mcs->rx_max_rate = param->rx_max_rate;
2012 mcs->rx_mcs_set = param->rx_mcs_set;
2013 mcs->tx_max_rate = param->tx_max_rate;
2014 mcs->tx_mcs_set = param->tx_mcs_set;
2015 }
2016
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002017 /* HE Rates */
2018 cmd->peer_he_mcs = param->peer_he_mcs_count;
2019 buf_ptr += sizeof(wmi_vht_rate_set);
2020 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2021 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2022 buf_ptr += WMI_TLV_HDR_SIZE;
2023
2024 /* Loop through the HE rate set */
2025 for (i = 0; i < param->peer_he_mcs_count; i++) {
2026 he_mcs = (wmi_he_rate_set *) buf_ptr;
2027 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2028 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2029
2030 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2031 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2032 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2033 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2034 buf_ptr += sizeof(wmi_he_rate_set);
2035 }
2036
2037
Govind Singhb53420c2016-03-09 14:32:57 +05302038 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302039 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2040 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002041 "cmd->peer_vht_caps %x "
2042 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302043 "HE phy %x %x %x "
2044 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302045 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2046 cmd->peer_rate_caps, cmd->peer_caps,
2047 cmd->peer_listen_intval, cmd->peer_ht_caps,
2048 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2049 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002050 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2051 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302052 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2053 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302054
2055 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2056 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302057 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302058 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302059 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302060 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302061 }
2062
2063 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302064}
2065
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302066/* copy_scan_notify_events() - Helper routine to copy scan notify events
2067 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302068static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302069 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302070 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302071{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302072
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302073 /* Scan events subscription */
2074 if (param->scan_ev_started)
2075 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2076 if (param->scan_ev_completed)
2077 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2078 if (param->scan_ev_bss_chan)
2079 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2080 if (param->scan_ev_foreign_chan)
2081 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2082 if (param->scan_ev_dequeued)
2083 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2084 if (param->scan_ev_preempted)
2085 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2086 if (param->scan_ev_start_failed)
2087 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2088 if (param->scan_ev_restarted)
2089 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2090 if (param->scan_ev_foreign_chn_exit)
2091 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2092 if (param->scan_ev_suspended)
2093 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2094 if (param->scan_ev_resumed)
2095 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302096
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302097 /** Set scan control flags */
2098 cmd->scan_ctrl_flags = 0;
2099 if (param->scan_f_passive)
2100 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2101 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302102 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302103 if (param->scan_f_promisc_mode)
2104 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2105 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302106 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302107 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302108 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302109 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302110 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302111 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302112 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302113 if (param->scan_f_ofdm_rates)
2114 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2115 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302116 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302117 if (param->scan_f_filter_prb_req)
2118 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2119 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302120 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302121 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302122 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302123 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302124 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302125 if (param->scan_f_force_active_dfs_chn)
2126 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2127 if (param->scan_f_add_tpc_ie_in_probe)
2128 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2129 if (param->scan_f_add_ds_ie_in_probe)
2130 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2131 if (param->scan_f_add_spoofed_mac_in_probe)
2132 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2133 if (param->scan_f_add_rand_seq_in_probe)
2134 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2135 if (param->scan_f_en_ie_whitelist_in_probe)
2136 cmd->scan_ctrl_flags |=
2137 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302138
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302139 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2140 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2141 param->adaptive_dwell_time_mode);
2142}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302143
2144/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302145static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302146 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302147{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302148 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302149}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302150
Anish Natarajdd855152017-03-20 12:49:08 +05302151/*
2152 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2153 * @param wmi_handle : Handle to WMI
2154 * @param vdev_id : vdev identifier
2155 *
2156 * Return : void *
2157 */
2158static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2159{
2160 struct wlan_objmgr_vdev *vdev = NULL;
2161 struct wlan_objmgr_pdev *pdev = NULL;
2162 uint8_t pdev_id = 0;
2163
2164 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2165 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2166 vdev_id, WLAN_SCAN_ID);
2167 if (vdev) {
2168 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2169 pdev = wlan_vdev_get_pdev(vdev);
2170 if (pdev)
2171 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2172 else {
2173 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2174 }
2175 } else {
2176 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2177 }
2178
2179 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2180}
2181
Govind Singh5eb51532016-03-09 11:34:12 +05302182/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302183 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2184 * @mac: random mac addr
2185 * @mask: random mac mask
2186 * @mac_addr: wmi random mac
2187 * @mac_mask: wmi random mac mask
2188 *
2189 * Return None.
2190 */
2191static inline
2192void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2193 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2194{
2195 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2196 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2197}
2198
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302199/*
2200 * wmi_fill_vendor_oui() - fill vendor OUIs
2201 * @buf_ptr: pointer to wmi tlv buffer
2202 * @num_vendor_oui: number of vendor OUIs to be filled
2203 * @param_voui: pointer to OUI buffer
2204 *
2205 * This function populates the wmi tlv buffer when vendor specific OUIs are
2206 * present.
2207 *
2208 * Return: None
2209 */
2210static inline
2211void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2212 uint32_t *pvoui)
2213{
2214 wmi_vendor_oui *voui = NULL;
2215 uint32_t i;
2216
2217 voui = (wmi_vendor_oui *)buf_ptr;
2218
2219 for (i = 0; i < num_vendor_oui; i++) {
2220 WMITLV_SET_HDR(&voui[i].tlv_header,
2221 WMITLV_TAG_STRUC_wmi_vendor_oui,
2222 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2223 voui[i].oui_type_subtype = pvoui[i];
2224 }
2225}
2226
2227/*
2228 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2229 * @ie_bitmap: output pointer to ie bit map in cmd
2230 * @num_vendor_oui: output pointer to num vendor OUIs
2231 * @ie_whitelist: input parameter
2232 *
2233 * This function populates the IE whitelist attrs of scan, pno and
2234 * scan oui commands for ie_whitelist parameter.
2235 *
2236 * Return: None
2237 */
2238static inline
2239void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2240 uint32_t *num_vendor_oui,
2241 struct probe_req_whitelist_attr *ie_whitelist)
2242{
2243 uint32_t i = 0;
2244
2245 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2246 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2247
2248 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2249}
2250
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302251/**
Govind Singh5eb51532016-03-09 11:34:12 +05302252 * send_scan_start_cmd_tlv() - WMI scan start function
2253 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302254 * @param param : pointer to hold scan start cmd parameter
2255 *
2256 * Return: 0 on success and -ve on failure.
2257 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302258static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302259 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302260{
Govind Singhd3156eb2016-02-26 17:50:39 +05302261 int32_t ret = 0;
2262 int32_t i;
2263 wmi_buf_t wmi_buf;
2264 wmi_start_scan_cmd_fixed_param *cmd;
2265 uint8_t *buf_ptr;
2266 uint32_t *tmp_ptr;
2267 wmi_ssid *ssid = NULL;
2268 wmi_mac_addr *bssid;
2269 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302270 uint8_t extraie_len_with_pad = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302271 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302272
2273 /* Length TLV placeholder for array of uint32_t */
2274 len += WMI_TLV_HDR_SIZE;
2275 /* calculate the length of buffer required */
2276 if (params->num_chan)
2277 len += params->num_chan * sizeof(uint32_t);
2278
2279 /* Length TLV placeholder for array of wmi_ssid structures */
2280 len += WMI_TLV_HDR_SIZE;
2281 if (params->num_ssids)
2282 len += params->num_ssids * sizeof(wmi_ssid);
2283
2284 /* Length TLV placeholder for array of wmi_mac_addr structures */
2285 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302286 if (params->num_bssid)
2287 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302288
2289 /* Length TLV placeholder for array of bytes */
2290 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302291 if (params->extraie.len)
2292 extraie_len_with_pad =
2293 roundup(params->extraie.len, sizeof(uint32_t));
2294 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302295
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302296 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2297 if (ie_whitelist->num_vendor_oui)
2298 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2299
Govind Singhd3156eb2016-02-26 17:50:39 +05302300 /* Allocate the memory */
2301 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2302 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302303 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302304 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302305 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302306 }
2307 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2308 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2309 WMITLV_SET_HDR(&cmd->tlv_header,
2310 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2311 WMITLV_GET_STRUCT_TLVLEN
2312 (wmi_start_scan_cmd_fixed_param));
2313
2314 cmd->scan_id = params->scan_id;
2315 cmd->scan_req_id = params->scan_req_id;
2316 cmd->vdev_id = params->vdev_id;
2317 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302318
2319 copy_scan_event_cntrl_flags(cmd, params);
2320
Govind Singhd3156eb2016-02-26 17:50:39 +05302321 cmd->dwell_time_active = params->dwell_time_active;
2322 cmd->dwell_time_passive = params->dwell_time_passive;
2323 cmd->min_rest_time = params->min_rest_time;
2324 cmd->max_rest_time = params->max_rest_time;
2325 cmd->repeat_probe_time = params->repeat_probe_time;
2326 cmd->probe_spacing_time = params->probe_spacing_time;
2327 cmd->idle_time = params->idle_time;
2328 cmd->max_scan_time = params->max_scan_time;
2329 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302330 cmd->burst_duration = params->burst_duration;
2331 cmd->num_chan = params->num_chan;
2332 cmd->num_bssid = params->num_bssid;
2333 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302334 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302335 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302336 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2337
2338 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2339
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302340 if (params->scan_random.randomize)
2341 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2342 params->scan_random.mac_mask,
2343 &cmd->mac_addr,
2344 &cmd->mac_mask);
2345
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302346 if (ie_whitelist->white_list)
2347 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2348 &cmd->num_vendor_oui,
2349 ie_whitelist);
2350
Govind Singhd3156eb2016-02-26 17:50:39 +05302351 buf_ptr += sizeof(*cmd);
2352 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2353 for (i = 0; i < params->num_chan; ++i)
2354 tmp_ptr[i] = params->chan_list[i];
2355
2356 WMITLV_SET_HDR(buf_ptr,
2357 WMITLV_TAG_ARRAY_UINT32,
2358 (params->num_chan * sizeof(uint32_t)));
2359 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302360 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302361 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302362 goto error;
2363 }
2364
2365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2366 (params->num_ssids * sizeof(wmi_ssid)));
2367
2368 if (params->num_ssids) {
2369 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2370 for (i = 0; i < params->num_ssids; ++i) {
2371 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302372 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302373 params->ssid[i].length);
2374 ssid++;
2375 }
2376 }
2377 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2378
2379 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2380 (params->num_bssid * sizeof(wmi_mac_addr)));
2381 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302382
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302383 if (params->num_bssid) {
2384 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302385 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2386 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302387 bssid++;
2388 }
2389 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302390
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302391 buf_ptr += WMI_TLV_HDR_SIZE +
2392 (params->num_bssid * sizeof(wmi_mac_addr));
2393
2394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2395 if (params->extraie.len)
2396 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2397 params);
2398
2399 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302400
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302401 /* probe req ie whitelisting */
2402 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2403 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2404
2405 buf_ptr += WMI_TLV_HDR_SIZE;
2406
2407 if (cmd->num_vendor_oui) {
2408 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2409 ie_whitelist->voui);
2410 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2411 }
2412
Anish Natarajdd855152017-03-20 12:49:08 +05302413 ret = wmi_unified_cmd_send(
2414 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302415 len, WMI_START_SCAN_CMDID);
2416 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302417 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302418 wmi_buf_free(wmi_buf);
2419 }
2420 return ret;
2421error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302422 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302423 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302424}
2425
2426/**
2427 * send_scan_stop_cmd_tlv() - WMI scan start function
2428 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302429 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302430 *
2431 * Return: 0 on success and -ve on failure.
2432 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302433static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302434 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302435{
Govind Singhd3156eb2016-02-26 17:50:39 +05302436 wmi_stop_scan_cmd_fixed_param *cmd;
2437 int ret;
2438 int len = sizeof(*cmd);
2439 wmi_buf_t wmi_buf;
2440
2441 /* Allocate the memory */
2442 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2443 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302444 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302445 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302446 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302447 goto error;
2448 }
2449
2450 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2451 WMITLV_SET_HDR(&cmd->tlv_header,
2452 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2453 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2454 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302455 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302456 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302457 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2458 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302459 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302460 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2461 /* Cancelling all scans */
2462 cmd->req_type = WMI_SCAN_STOP_ALL;
2463 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2464 /* Cancelling VAP scans */
2465 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2466 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2467 /* Cancelling specific scan */
2468 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302469 } else {
2470 WMI_LOGE("%s: Invalid Command : ", __func__);
2471 wmi_buf_free(wmi_buf);
2472 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302473 }
2474
Anish Natarajdd855152017-03-20 12:49:08 +05302475 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302476 len, WMI_STOP_SCAN_CMDID);
2477 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302478 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302479 wmi_buf_free(wmi_buf);
2480 }
2481
2482error:
2483 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302484}
2485
Govind Singh87542482016-06-08 19:40:11 +05302486#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302487/**
2488 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2489 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302490 * @param param : pointer to hold scan channel list parameter
2491 *
2492 * Return: 0 on success and -ve on failure.
2493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302494static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302495 struct scan_chan_list_params *chan_list)
2496{
2497 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302498 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302499 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302500 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302501 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302502 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302503 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2504
2505 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2506 buf = wmi_buf_alloc(wmi_handle, len);
2507 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302508 WMI_LOGE("Failed to allocate memory");
2509 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302510 goto end;
2511 }
2512
2513 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2514 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2515 WMITLV_SET_HDR(&cmd->tlv_header,
2516 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2517 WMITLV_GET_STRUCT_TLVLEN
2518 (wmi_scan_chan_list_cmd_fixed_param));
2519
Govind Singhb53420c2016-03-09 14:32:57 +05302520 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302521
2522 cmd->num_scan_chans = chan_list->num_scan_chans;
2523 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2524 WMITLV_TAG_ARRAY_STRUC,
2525 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302526 chan_info = (wmi_channel_param *)
2527 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302528 tchan_info = chan_list->chan_info;
2529
2530 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2531 WMITLV_SET_HDR(&chan_info->tlv_header,
2532 WMITLV_TAG_STRUC_wmi_channel,
2533 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2534 chan_info->mhz = tchan_info->mhz;
2535 chan_info->band_center_freq1 =
2536 tchan_info->band_center_freq1;
2537 chan_info->band_center_freq2 =
2538 tchan_info->band_center_freq2;
2539 chan_info->info = tchan_info->info;
2540 chan_info->reg_info_1 = tchan_info->reg_info_1;
2541 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302542 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302543
2544 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2545 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2546 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2547 tchan_info++;
2548 chan_info++;
2549 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302550 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2551 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302552
Anish Natarajdd855152017-03-20 12:49:08 +05302553 qdf_status = wmi_unified_cmd_send(wmi_handle,
2554 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302555
Govind Singh67922e82016-04-01 16:48:57 +05302556 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302557 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302558 wmi_buf_free(buf);
2559 }
Govind Singh67922e82016-04-01 16:48:57 +05302560
Govind Singhd3156eb2016-02-26 17:50:39 +05302561end:
Govind Singhb53420c2016-03-09 14:32:57 +05302562 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302563}
Govind Singh87542482016-06-08 19:40:11 +05302564#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302565static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302566 struct scan_chan_list_params *chan_list)
2567{
2568 wmi_buf_t buf;
2569 QDF_STATUS qdf_status;
2570 wmi_scan_chan_list_cmd_fixed_param *cmd;
2571 int i;
2572 uint8_t *buf_ptr;
2573 wmi_channel *chan_info;
2574 struct channel_param *tchan_info;
2575 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302576
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302577 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302578 buf = wmi_buf_alloc(wmi_handle, len);
2579 if (!buf) {
2580 WMI_LOGE("Failed to allocate memory");
2581 qdf_status = QDF_STATUS_E_NOMEM;
2582 goto end;
2583 }
2584
2585 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2586 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2587 WMITLV_SET_HDR(&cmd->tlv_header,
2588 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2589 WMITLV_GET_STRUCT_TLVLEN
2590 (wmi_scan_chan_list_cmd_fixed_param));
2591
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302592 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302593
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302594 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2595 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302596 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302597 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2598 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302599 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302600 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2601 tchan_info = &(chan_list->ch_param[0]);
2602
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302603 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302604 WMITLV_SET_HDR(&chan_info->tlv_header,
2605 WMITLV_TAG_STRUC_wmi_channel,
2606 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2607 chan_info->mhz = tchan_info->mhz;
2608 chan_info->band_center_freq1 =
2609 tchan_info->cfreq1;
2610 chan_info->band_center_freq2 =
2611 tchan_info->cfreq2;
2612
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302613 if (tchan_info->is_chan_passive)
2614 WMI_SET_CHANNEL_FLAG(chan_info,
2615 WMI_CHAN_FLAG_PASSIVE);
2616
2617 if (tchan_info->allow_vht)
2618 WMI_SET_CHANNEL_FLAG(chan_info,
2619 WMI_CHAN_FLAG_ALLOW_VHT);
2620 else if (tchan_info->allow_ht)
2621 WMI_SET_CHANNEL_FLAG(chan_info,
2622 WMI_CHAN_FLAG_ALLOW_HT);
2623 WMI_SET_CHANNEL_MODE(chan_info,
2624 tchan_info->phy_mode);
2625
2626 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2627 * after FW support
2628 */
2629
2630 /* also fill in power information */
2631 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2632 tchan_info->minpower);
2633 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2634 tchan_info->maxpower);
2635 WMI_SET_CHANNEL_REG_POWER(chan_info,
2636 tchan_info->maxregpower);
2637 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2638 tchan_info->antennamax);
2639 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2640 tchan_info->reg_class_id);
2641
Govind Singh87542482016-06-08 19:40:11 +05302642 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2643
Govind Singh87542482016-06-08 19:40:11 +05302644 tchan_info++;
2645 chan_info++;
2646 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302647 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2648 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302649
Anish Natarajdd855152017-03-20 12:49:08 +05302650 qdf_status = wmi_unified_cmd_send(
2651 wmi_handle,
2652 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302653
2654 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2655 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2656 wmi_buf_free(buf);
2657 }
2658
2659end:
2660 return qdf_status;
2661}
2662#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302663
2664/**
2665 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2666 *
2667 * @bufp: Pointer to buffer
2668 * @param: Pointer to tx param
2669 *
2670 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2671 */
2672static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2673 struct tx_send_params param)
2674{
2675 wmi_tx_send_params *tx_param;
2676 QDF_STATUS status = QDF_STATUS_SUCCESS;
2677
2678 if (!bufp) {
2679 status = QDF_STATUS_E_FAILURE;
2680 return status;
2681 }
2682 tx_param = (wmi_tx_send_params *)bufp;
2683 WMITLV_SET_HDR(&tx_param->tlv_header,
2684 WMITLV_TAG_STRUC_wmi_tx_send_params,
2685 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2686 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2687 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2688 param.mcs_mask);
2689 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2690 param.nss_mask);
2691 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2692 param.retry_limit);
2693 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2694 param.chain_mask);
2695 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2696 param.bw_mask);
2697 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2698 param.preamble_type);
2699 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2700 param.frame_type);
2701
2702 return status;
2703}
2704
Govind Singhd3156eb2016-02-26 17:50:39 +05302705/**
2706 * send_mgmt_cmd_tlv() - WMI scan start function
2707 * @wmi_handle : handle to WMI.
2708 * @param : pointer to hold mgmt cmd parameter
2709 *
2710 * Return: 0 on success and -ve on failure.
2711 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302712static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302713 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302714{
Govind Singh427ee5a2016-02-26 18:09:36 +05302715 wmi_buf_t buf;
2716 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2717 int32_t cmd_len;
2718 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302719 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302720 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302721 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302722 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2723 mgmt_tx_dl_frm_len;
2724
2725 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302726 WMI_TLV_HDR_SIZE +
2727 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302728
Sathish Kumar5b636932017-06-28 14:40:32 +05302729 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302730 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302731 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2732 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302733 }
2734
2735 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2736 bufp = (uint8_t *) cmd;
2737 WMITLV_SET_HDR(&cmd->tlv_header,
2738 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2739 WMITLV_GET_STRUCT_TLVLEN
2740 (wmi_mgmt_tx_send_cmd_fixed_param));
2741
2742 cmd->vdev_id = param->vdev_id;
2743
Govind Singh224a7312016-06-21 14:33:26 +05302744 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302745 cmd->chanfreq = param->chanfreq;
2746 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2747 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2748 sizeof(uint32_t)));
2749 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302750 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302751
2752 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2753 QDF_DMA_TO_DEVICE);
2754 if (status != QDF_STATUS_SUCCESS) {
2755 WMI_LOGE("%s: wmi buf map failed", __func__);
2756 goto err1;
2757 }
2758
Govind Singhb53420c2016-03-09 14:32:57 +05302759 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302760 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002761#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302762 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2763#endif
2764 cmd->frame_len = param->frm_len;
2765 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302766 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302767
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002768 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002769 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002770
Sathish Kumar5b636932017-06-28 14:40:32 +05302771 bufp += roundup(bufp_len, sizeof(uint32_t));
2772 if (param->tx_params_valid) {
2773 status = populate_tx_send_params(bufp, param->tx_param);
2774 if (status != QDF_STATUS_SUCCESS) {
2775 WMI_LOGE("%s: Populate TX send params failed",
2776 __func__);
2777 goto err1;
2778 }
2779 cmd_len += sizeof(wmi_tx_send_params);
2780 }
2781
Govind Singh427ee5a2016-02-26 18:09:36 +05302782 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2783 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302784 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302785 goto err1;
2786 }
Govind Singhb53420c2016-03-09 14:32:57 +05302787 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302788
2789err1:
2790 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302791 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302792}
2793
2794/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302795 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2796 * @wmi_handle : handle to WMI.
2797 * @param : pointer to offchan data tx cmd parameter
2798 *
2799 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2800 */
2801static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2802 struct wmi_offchan_data_tx_params *param)
2803{
2804 wmi_buf_t buf;
2805 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2806 int32_t cmd_len;
2807 uint64_t dma_addr;
2808 void *qdf_ctx = param->qdf_ctx;
2809 uint8_t *bufp;
2810 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2811 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302812 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302813
2814 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302815 WMI_TLV_HDR_SIZE +
2816 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302817
Sathish Kumar5b636932017-06-28 14:40:32 +05302818 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302819 if (!buf) {
2820 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2821 return QDF_STATUS_E_NOMEM;
2822 }
2823
2824 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2825 bufp = (uint8_t *) cmd;
2826 WMITLV_SET_HDR(&cmd->tlv_header,
2827 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2828 WMITLV_GET_STRUCT_TLVLEN
2829 (wmi_offchan_data_tx_send_cmd_fixed_param));
2830
2831 cmd->vdev_id = param->vdev_id;
2832
2833 cmd->desc_id = param->desc_id;
2834 cmd->chanfreq = param->chanfreq;
2835 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2836 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2837 sizeof(uint32_t)));
2838 bufp += WMI_TLV_HDR_SIZE;
2839 qdf_mem_copy(bufp, param->pdata, bufp_len);
2840 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2841 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2842 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2843#if defined(HTT_PADDR64)
2844 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2845#endif
2846 cmd->frame_len = param->frm_len;
2847 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302848 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302849
2850 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2851 bufp, cmd->vdev_id, cmd->chanfreq);
2852
Sathish Kumar5b636932017-06-28 14:40:32 +05302853 bufp += roundup(bufp_len, sizeof(uint32_t));
2854 if (param->tx_params_valid) {
2855 status = populate_tx_send_params(bufp, param->tx_param);
2856 if (status != QDF_STATUS_SUCCESS) {
2857 WMI_LOGE("%s: Populate TX send params failed",
2858 __func__);
2859 goto err1;
2860 }
2861 cmd_len += sizeof(wmi_tx_send_params);
2862 }
2863
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302864 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2865 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2866 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05302867 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302868 }
2869
2870 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05302871
2872err1:
2873 wmi_buf_free(buf);
2874 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302875}
2876
2877/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302878 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2879 * @wmi_handle: wmi handle
2880 * @param_value: parameter value
2881 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302882 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302884static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302885 uint32_t param_value)
2886{
Govind Singh67922e82016-04-01 16:48:57 +05302887 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302888 wmi_modem_power_state_cmd_param *cmd;
2889 wmi_buf_t buf;
2890 uint16_t len = sizeof(*cmd);
2891
2892 buf = wmi_buf_alloc(wmi_handle, len);
2893 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302894 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302895 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302896 }
2897 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2898 WMITLV_SET_HDR(&cmd->tlv_header,
2899 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2900 WMITLV_GET_STRUCT_TLVLEN
2901 (wmi_modem_power_state_cmd_param));
2902 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302903 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302904 param_value);
2905 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2906 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302907 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302908 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302909 wmi_buf_free(buf);
2910 }
Govind Singh67922e82016-04-01 16:48:57 +05302911
Govind Singh427ee5a2016-02-26 18:09:36 +05302912 return ret;
2913}
2914
2915/**
2916 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2917 * @wmi_handle: wmi handle
2918 * @vdev_id: vdev id
2919 * @val: value
2920 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302921 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302922 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302923static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302924 uint32_t vdev_id, uint8_t val)
2925{
2926 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2927 wmi_buf_t buf;
2928 int32_t len = sizeof(*cmd);
2929
Govind Singhb53420c2016-03-09 14:32:57 +05302930 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302931
2932 buf = wmi_buf_alloc(wmi_handle, len);
2933 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302934 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302935 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302936 }
2937 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2938 WMITLV_SET_HDR(&cmd->tlv_header,
2939 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2940 WMITLV_GET_STRUCT_TLVLEN
2941 (wmi_sta_powersave_mode_cmd_fixed_param));
2942 cmd->vdev_id = vdev_id;
2943 if (val)
2944 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2945 else
2946 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2947
2948 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2949 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302950 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302951 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302952 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302953 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302954 }
Govind Singh5eb51532016-03-09 11:34:12 +05302955 return 0;
2956}
2957
Govind Singh427ee5a2016-02-26 18:09:36 +05302958/**
2959 * send_set_mimops_cmd_tlv() - set MIMO powersave
2960 * @wmi_handle: wmi handle
2961 * @vdev_id: vdev id
2962 * @value: value
2963 *
Govind Singhb53420c2016-03-09 14:32:57 +05302964 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302965 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302966static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302967 uint8_t vdev_id, int value)
2968{
Govind Singh67922e82016-04-01 16:48:57 +05302969 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302970 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2971 wmi_buf_t buf;
2972 uint16_t len = sizeof(*cmd);
2973
2974 buf = wmi_buf_alloc(wmi_handle, len);
2975 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302976 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302977 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302978 }
2979 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2980 WMITLV_SET_HDR(&cmd->tlv_header,
2981 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2982 WMITLV_GET_STRUCT_TLVLEN
2983 (wmi_sta_smps_force_mode_cmd_fixed_param));
2984
2985 cmd->vdev_id = vdev_id;
2986
Houston Hoffmanb5168052016-04-14 02:18:01 -07002987 /* WMI_SMPS_FORCED_MODE values do not directly map
2988 * to SM power save values defined in the specification.
2989 * Make sure to send the right mapping.
2990 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302991 switch (value) {
2992 case 0:
2993 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2994 break;
2995 case 1:
2996 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2997 break;
2998 case 2:
2999 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3000 break;
3001 case 3:
3002 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3003 break;
3004 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303005 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3006 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303007 }
3008
Govind Singhb53420c2016-03-09 14:32:57 +05303009 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303010
3011 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3012 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303013 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303014 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303015 wmi_buf_free(buf);
3016 }
3017
3018 return ret;
3019}
3020
3021/**
3022 * send_set_smps_params_cmd_tlv() - set smps params
3023 * @wmi_handle: wmi handle
3024 * @vdev_id: vdev id
3025 * @value: value
3026 *
Govind Singhb53420c2016-03-09 14:32:57 +05303027 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303028 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303029static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303030 int value)
3031{
Govind Singh67922e82016-04-01 16:48:57 +05303032 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303033 wmi_sta_smps_param_cmd_fixed_param *cmd;
3034 wmi_buf_t buf;
3035 uint16_t len = sizeof(*cmd);
3036
3037 buf = wmi_buf_alloc(wmi_handle, len);
3038 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303039 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303040 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303041 }
3042 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3043 WMITLV_SET_HDR(&cmd->tlv_header,
3044 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3045 WMITLV_GET_STRUCT_TLVLEN
3046 (wmi_sta_smps_param_cmd_fixed_param));
3047
3048 cmd->vdev_id = vdev_id;
3049 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3050 cmd->param =
3051 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3052
Govind Singhb53420c2016-03-09 14:32:57 +05303053 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303054 cmd->param);
3055
3056 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3057 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303058 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303059 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303060 wmi_buf_free(buf);
3061 }
3062
3063 return ret;
3064}
3065
3066/**
3067 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3068 * @wmi_handle: wmi handle
3069 * @noa: p2p power save parameters
3070 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303071 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303072 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303073static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303074 struct p2p_ps_params *noa)
3075{
3076 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3077 wmi_p2p_noa_descriptor *noa_discriptor;
3078 wmi_buf_t buf;
3079 uint8_t *buf_ptr;
3080 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303081 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303082 uint32_t duration;
3083
Govind Singhb53420c2016-03-09 14:32:57 +05303084 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303085 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3086 buf = wmi_buf_alloc(wmi_handle, len);
3087 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303088 WMI_LOGE("Failed to allocate memory");
3089 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303090 goto end;
3091 }
3092
3093 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3094 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3095 WMITLV_SET_HDR(&cmd->tlv_header,
3096 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3097 WMITLV_GET_STRUCT_TLVLEN
3098 (wmi_p2p_set_noa_cmd_fixed_param));
3099 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3100 cmd->vdev_id = noa->session_id;
3101 cmd->enable = (duration) ? true : false;
3102 cmd->num_noa = 1;
3103
3104 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3105 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3106 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3107 sizeof
3108 (wmi_p2p_set_noa_cmd_fixed_param)
3109 + WMI_TLV_HDR_SIZE);
3110 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3111 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3112 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3113 noa_discriptor->type_count = noa->count;
3114 noa_discriptor->duration = duration;
3115 noa_discriptor->interval = noa->interval;
3116 noa_discriptor->start_time = 0;
3117
Govind Singhb53420c2016-03-09 14:32:57 +05303118 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303119 cmd->vdev_id, noa->count, noa_discriptor->duration,
3120 noa->interval);
3121 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3122 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303123 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303124 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303125 wmi_buf_free(buf);
3126 }
3127
3128end:
Govind Singhb53420c2016-03-09 14:32:57 +05303129 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303130 return status;
3131}
3132
3133
3134/**
3135 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3136 * @wmi_handle: wmi handle
3137 * @noa: p2p opp power save parameters
3138 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303139 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303140 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303141static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303142 struct p2p_ps_params *oppps)
3143{
3144 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3145 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303146 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303147
Govind Singhb53420c2016-03-09 14:32:57 +05303148 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303149 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3150 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303151 WMI_LOGE("Failed to allocate memory");
3152 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303153 goto end;
3154 }
3155
3156 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3157 WMITLV_SET_HDR(&cmd->tlv_header,
3158 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3159 WMITLV_GET_STRUCT_TLVLEN
3160 (wmi_p2p_set_oppps_cmd_fixed_param));
3161 cmd->vdev_id = oppps->session_id;
3162 if (oppps->ctwindow)
3163 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3164
3165 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303166 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 cmd->vdev_id, oppps->ctwindow);
3168 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3169 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303170 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303171 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303172 wmi_buf_free(buf);
3173 }
3174
3175end:
Govind Singhb53420c2016-03-09 14:32:57 +05303176 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303177 return status;
3178}
3179
Wu Gaocd3a8512017-03-13 20:17:34 +08003180#ifdef CONVERGED_P2P_ENABLE
3181/**
3182 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3183 * @wmi_handle: wmi handle
3184 * @param: p2p listen offload start parameters
3185 *
3186 * Return: QDF status
3187 */
3188static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3189 struct p2p_lo_start *param)
3190{
3191 wmi_buf_t buf;
3192 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3193 int32_t len = sizeof(*cmd);
3194 uint8_t *buf_ptr;
3195 QDF_STATUS status;
3196 int device_types_len_aligned;
3197 int probe_resp_len_aligned;
3198
3199 if (!param) {
3200 WMI_LOGE("lo start param is null");
3201 return QDF_STATUS_E_INVAL;
3202 }
3203
3204 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3205
3206 device_types_len_aligned =
3207 qdf_roundup(param->dev_types_len,
3208 sizeof(A_UINT32));
3209 probe_resp_len_aligned =
3210 qdf_roundup(param->probe_resp_len,
3211 sizeof(A_UINT32));
3212
3213 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3214 probe_resp_len_aligned;
3215
3216 buf = wmi_buf_alloc(wmi_handle, len);
3217 if (!buf) {
3218 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3219 __func__);
3220 return QDF_STATUS_E_NOMEM;
3221 }
3222
3223 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3224 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3225
3226 WMITLV_SET_HDR(&cmd->tlv_header,
3227 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3228 WMITLV_GET_STRUCT_TLVLEN(
3229 wmi_p2p_lo_start_cmd_fixed_param));
3230
3231 cmd->vdev_id = param->vdev_id;
3232 cmd->ctl_flags = param->ctl_flags;
3233 cmd->channel = param->freq;
3234 cmd->period = param->period;
3235 cmd->interval = param->interval;
3236 cmd->count = param->count;
3237 cmd->device_types_len = param->dev_types_len;
3238 cmd->prob_resp_len = param->probe_resp_len;
3239
3240 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3242 device_types_len_aligned);
3243 buf_ptr += WMI_TLV_HDR_SIZE;
3244 qdf_mem_copy(buf_ptr, param->device_types,
3245 param->dev_types_len);
3246
3247 buf_ptr += device_types_len_aligned;
3248 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3249 probe_resp_len_aligned);
3250 buf_ptr += WMI_TLV_HDR_SIZE;
3251 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3252 param->probe_resp_len);
3253
3254 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3255 cmd->channel, cmd->period, cmd->interval, cmd->count);
3256
3257 status = wmi_unified_cmd_send(wmi_handle,
3258 buf, len,
3259 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3260 if (status != QDF_STATUS_SUCCESS) {
3261 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3262 __func__, status);
3263 wmi_buf_free(buf);
3264 return status;
3265 }
3266
3267 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3268
3269 return QDF_STATUS_SUCCESS;
3270}
3271
3272/**
3273 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3274 * @wmi_handle: wmi handle
3275 * @param: p2p listen offload stop parameters
3276 *
3277 * Return: QDF status
3278 */
3279static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3280 uint8_t vdev_id)
3281{
3282 wmi_buf_t buf;
3283 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3284 int32_t len;
3285 QDF_STATUS status;
3286
3287 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3288
3289 len = sizeof(*cmd);
3290 buf = wmi_buf_alloc(wmi_handle, len);
3291 if (!buf) {
3292 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3293 __func__);
3294 return QDF_STATUS_E_NOMEM;
3295 }
3296 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3297
3298 WMITLV_SET_HDR(&cmd->tlv_header,
3299 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3300 WMITLV_GET_STRUCT_TLVLEN(
3301 wmi_p2p_lo_stop_cmd_fixed_param));
3302
3303 cmd->vdev_id = vdev_id;
3304
3305 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3306
3307 status = wmi_unified_cmd_send(wmi_handle,
3308 buf, len,
3309 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3310 if (status != QDF_STATUS_SUCCESS) {
3311 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3312 __func__, status);
3313 wmi_buf_free(buf);
3314 return status;
3315 }
3316
3317 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3318
3319 return QDF_STATUS_SUCCESS;
3320}
3321#endif /* End of CONVERGED_P2P_ENABLE */
3322
Govind Singh427ee5a2016-02-26 18:09:36 +05303323/**
3324 * send_get_temperature_cmd_tlv() - get pdev temperature req
3325 * @wmi_handle: wmi handle
3326 *
Govind Singhb53420c2016-03-09 14:32:57 +05303327 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303328 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303329static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303330{
3331 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3332 wmi_buf_t wmi_buf;
3333 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3334 uint8_t *buf_ptr;
3335
3336 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303337 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3338 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303339 }
3340
3341 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3342 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303343 WMI_LOGE(FL("wmi_buf_alloc failed"));
3344 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303345 }
3346
3347 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3348
3349 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3350 WMITLV_SET_HDR(&cmd->tlv_header,
3351 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3352 WMITLV_GET_STRUCT_TLVLEN
3353 (wmi_pdev_get_temperature_cmd_fixed_param));
3354
3355 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3356 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303357 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303358 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303359 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303360 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303361
Govind Singhb53420c2016-03-09 14:32:57 +05303362 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303363}
3364
3365/**
3366 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3367 * @wmi_handle: wmi handle
3368 * @vdevid: vdev id
3369 * @peer_addr: peer mac address
3370 * @auto_triggerparam: auto trigger parameters
3371 * @num_ac: number of access category
3372 *
3373 * This function sets the trigger
3374 * uapsd params such as service interval, delay interval
3375 * and suspend interval which will be used by the firmware
3376 * to send trigger frames periodically when there is no
3377 * traffic on the transmit side.
3378 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303379 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303380 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303381static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303382 struct sta_uapsd_trig_params *param)
3383{
3384 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303385 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303386 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3387 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3388 uint32_t i;
3389 wmi_buf_t buf;
3390 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003391 struct sta_uapsd_params *uapsd_param;
3392 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303393
3394 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3395 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303396 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303397 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303398 }
3399
3400 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3401 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3402 WMITLV_SET_HDR(&cmd->tlv_header,
3403 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3404 WMITLV_GET_STRUCT_TLVLEN
3405 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3406 cmd->vdev_id = param->vdevid;
3407 cmd->num_ac = param->num_ac;
3408 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3409
3410 /* TLV indicating array of structures to follow */
3411 buf_ptr += sizeof(*cmd);
3412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3413
3414 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303415
3416 /*
3417 * Update tag and length for uapsd auto trigger params (this will take
3418 * care of updating tag and length if it is not pre-filled by caller).
3419 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003420 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3421 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303422 for (i = 0; i < param->num_ac; i++) {
3423 WMITLV_SET_HDR((buf_ptr +
3424 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3425 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3426 WMITLV_GET_STRUCT_TLVLEN
3427 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003428 trig_param->wmm_ac = uapsd_param->wmm_ac;
3429 trig_param->user_priority = uapsd_param->user_priority;
3430 trig_param->service_interval = uapsd_param->service_interval;
3431 trig_param->suspend_interval = uapsd_param->suspend_interval;
3432 trig_param->delay_interval = uapsd_param->delay_interval;
3433 trig_param++;
3434 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303435 }
3436
3437 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3438 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303439 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303440 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303441 wmi_buf_free(buf);
3442 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303443
Govind Singh427ee5a2016-02-26 18:09:36 +05303444 return ret;
3445}
3446
Govind Singh2edc80f2016-03-01 15:30:53 +05303447/**
3448 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3449 * @wmi_handle: pointer to the wmi handle
3450 * @utc: pointer to the UTC time struct
3451 *
3452 * Return: 0 on succes
3453 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303454static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303455 struct ocb_utc_param *utc)
3456{
Govind Singh67922e82016-04-01 16:48:57 +05303457 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303458 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3459 uint8_t *buf_ptr;
3460 uint32_t len, i;
3461 wmi_buf_t buf;
3462
3463 len = sizeof(*cmd);
3464 buf = wmi_buf_alloc(wmi_handle, len);
3465 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303466 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303467 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303468 }
3469
3470 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3471 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3472 WMITLV_SET_HDR(&cmd->tlv_header,
3473 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3474 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3475 cmd->vdev_id = utc->vdev_id;
3476
3477 for (i = 0; i < SIZE_UTC_TIME; i++)
3478 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3479
3480 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3481 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3482
3483 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3484 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303485 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303486 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303487 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303488 }
3489
Govind Singh67922e82016-04-01 16:48:57 +05303490 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303491}
3492
3493/**
3494 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3495 * frames on a channel
3496 * @wmi_handle: pointer to the wmi handle
3497 * @timing_advert: pointer to the timing advertisement struct
3498 *
3499 * Return: 0 on succes
3500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303501static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303502 struct ocb_timing_advert_param *timing_advert)
3503{
Govind Singh67922e82016-04-01 16:48:57 +05303504 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303505 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3506 uint8_t *buf_ptr;
3507 uint32_t len, len_template;
3508 wmi_buf_t buf;
3509
3510 len = sizeof(*cmd) +
3511 WMI_TLV_HDR_SIZE;
3512
3513 len_template = timing_advert->template_length;
3514 /* Add padding to the template if needed */
3515 if (len_template % 4 != 0)
3516 len_template += 4 - (len_template % 4);
3517 len += len_template;
3518
3519 buf = wmi_buf_alloc(wmi_handle, len);
3520 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303521 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303522 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303523 }
3524
3525 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3526 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3527 WMITLV_SET_HDR(&cmd->tlv_header,
3528 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3529 WMITLV_GET_STRUCT_TLVLEN(
3530 wmi_ocb_start_timing_advert_cmd_fixed_param));
3531 cmd->vdev_id = timing_advert->vdev_id;
3532 cmd->repeat_rate = timing_advert->repeat_rate;
3533 cmd->channel_freq = timing_advert->chan_freq;
3534 cmd->timestamp_offset = timing_advert->timestamp_offset;
3535 cmd->time_value_offset = timing_advert->time_value_offset;
3536 cmd->timing_advert_template_length = timing_advert->template_length;
3537 buf_ptr += sizeof(*cmd);
3538
3539 /* Add the timing advert template */
3540 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3541 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303542 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303543 (uint8_t *)timing_advert->template_value,
3544 timing_advert->template_length);
3545
3546 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3547 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303548 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303549 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303550 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303551 }
3552
Govind Singh67922e82016-04-01 16:48:57 +05303553 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303554}
3555
3556/**
3557 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3558 * on a channel
3559 * @wmi_handle: pointer to the wmi handle
3560 * @timing_advert: pointer to the timing advertisement struct
3561 *
3562 * Return: 0 on succes
3563 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303564static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303565 struct ocb_timing_advert_param *timing_advert)
3566{
Govind Singh67922e82016-04-01 16:48:57 +05303567 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303568 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3569 uint8_t *buf_ptr;
3570 uint32_t len;
3571 wmi_buf_t buf;
3572
3573 len = sizeof(*cmd);
3574 buf = wmi_buf_alloc(wmi_handle, len);
3575 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303576 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303577 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303578 }
3579
3580 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3581 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3582 WMITLV_SET_HDR(&cmd->tlv_header,
3583 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3584 WMITLV_GET_STRUCT_TLVLEN(
3585 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3586 cmd->vdev_id = timing_advert->vdev_id;
3587 cmd->channel_freq = timing_advert->chan_freq;
3588
3589 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3590 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303591 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303592 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303593 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303594 }
3595
Govind Singh67922e82016-04-01 16:48:57 +05303596 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303597}
3598
3599/**
3600 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3601 * @wmi_handle: pointer to the wmi handle
3602 * @request: pointer to the request
3603 *
3604 * Return: 0 on succes
3605 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303606static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303607 uint8_t vdev_id)
3608{
Govind Singhb53420c2016-03-09 14:32:57 +05303609 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303610 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3611 uint8_t *buf_ptr;
3612 wmi_buf_t buf;
3613 int32_t len;
3614
3615 len = sizeof(*cmd);
3616 buf = wmi_buf_alloc(wmi_handle, len);
3617 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303618 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303619 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303620 }
3621 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3622
3623 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303624 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303625 WMITLV_SET_HDR(&cmd->tlv_header,
3626 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3627 WMITLV_GET_STRUCT_TLVLEN(
3628 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3629 cmd->vdev_id = vdev_id;
3630
3631 /* Send the WMI command */
3632 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3633 WMI_OCB_GET_TSF_TIMER_CMDID);
3634 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303635 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303636 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303637 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303638 }
3639
Govind Singh67922e82016-04-01 16:48:57 +05303640 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303641}
3642
3643/**
3644 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3645 * @wmi_handle: pointer to the wmi handle
3646 * @get_stats_param: pointer to the dcc stats
3647 *
3648 * Return: 0 on succes
3649 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303650static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303651 struct dcc_get_stats_param *get_stats_param)
3652{
Govind Singh67922e82016-04-01 16:48:57 +05303653 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303654 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3655 wmi_dcc_channel_stats_request *channel_stats_array;
3656 wmi_buf_t buf;
3657 uint8_t *buf_ptr;
3658 uint32_t len;
3659 uint32_t i;
3660
3661 /* Validate the input */
3662 if (get_stats_param->request_array_len !=
3663 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303664 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303665 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303666 }
3667
3668 /* Allocate memory for the WMI command */
3669 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3670 get_stats_param->request_array_len;
3671
3672 buf = wmi_buf_alloc(wmi_handle, len);
3673 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303674 WMI_LOGE(FL("wmi_buf_alloc failed"));
3675 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303676 }
3677
3678 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303679 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303680
3681 /* Populate the WMI command */
3682 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3683 buf_ptr += sizeof(*cmd);
3684
3685 WMITLV_SET_HDR(&cmd->tlv_header,
3686 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3687 WMITLV_GET_STRUCT_TLVLEN(
3688 wmi_dcc_get_stats_cmd_fixed_param));
3689 cmd->vdev_id = get_stats_param->vdev_id;
3690 cmd->num_channels = get_stats_param->channel_count;
3691
3692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3693 get_stats_param->request_array_len);
3694 buf_ptr += WMI_TLV_HDR_SIZE;
3695
3696 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303697 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303698 get_stats_param->request_array_len);
3699 for (i = 0; i < cmd->num_channels; i++)
3700 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3701 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3702 WMITLV_GET_STRUCT_TLVLEN(
3703 wmi_dcc_channel_stats_request));
3704
3705 /* Send the WMI command */
3706 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3707 WMI_DCC_GET_STATS_CMDID);
3708
Govind Singh67922e82016-04-01 16:48:57 +05303709 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303710 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303711 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303712 }
3713
Govind Singh67922e82016-04-01 16:48:57 +05303714 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303715}
3716
3717/**
3718 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3719 * @wmi_handle: pointer to the wmi handle
3720 * @vdev_id: vdev id
3721 * @dcc_stats_bitmap: dcc status bitmap
3722 *
3723 * Return: 0 on succes
3724 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303725static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303726 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3727{
Govind Singh67922e82016-04-01 16:48:57 +05303728 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303729 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3730 wmi_buf_t buf;
3731 uint8_t *buf_ptr;
3732 uint32_t len;
3733
3734 /* Allocate memory for the WMI command */
3735 len = sizeof(*cmd);
3736
3737 buf = wmi_buf_alloc(wmi_handle, len);
3738 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303739 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303740 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303741 }
3742
3743 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303744 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303745
3746 /* Populate the WMI command */
3747 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3748
3749 WMITLV_SET_HDR(&cmd->tlv_header,
3750 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3751 WMITLV_GET_STRUCT_TLVLEN(
3752 wmi_dcc_clear_stats_cmd_fixed_param));
3753 cmd->vdev_id = vdev_id;
3754 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3755
3756 /* Send the WMI command */
3757 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3758 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303759 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303760 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303761 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303762 }
3763
Govind Singh67922e82016-04-01 16:48:57 +05303764 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303765}
3766
3767/**
3768 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3769 * @wmi_handle: pointer to the wmi handle
3770 * @update_ndl_param: pointer to the request parameters
3771 *
3772 * Return: 0 on success
3773 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303774static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303775 struct dcc_update_ndl_param *update_ndl_param)
3776{
Govind Singhb53420c2016-03-09 14:32:57 +05303777 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303778 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3779 wmi_dcc_ndl_chan *ndl_chan_array;
3780 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3781 uint32_t active_state_count;
3782 wmi_buf_t buf;
3783 uint8_t *buf_ptr;
3784 uint32_t len;
3785 uint32_t i;
3786
3787 /* validate the input */
3788 if (update_ndl_param->dcc_ndl_chan_list_len !=
3789 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303790 WMI_LOGE(FL("Invalid parameter"));
3791 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303792 }
3793 active_state_count = 0;
3794 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3795 for (i = 0; i < update_ndl_param->channel_count; i++)
3796 active_state_count +=
3797 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3798 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3799 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303800 WMI_LOGE(FL("Invalid parameter"));
3801 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303802 }
3803
3804 /* Allocate memory for the WMI command */
3805 len = sizeof(*cmd) +
3806 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3807 WMI_TLV_HDR_SIZE +
3808 update_ndl_param->dcc_ndl_active_state_list_len;
3809
3810 buf = wmi_buf_alloc(wmi_handle, len);
3811 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303812 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303813 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303814 }
3815
3816 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303817 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303818
3819 /* Populate the WMI command */
3820 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3821 buf_ptr += sizeof(*cmd);
3822
3823 WMITLV_SET_HDR(&cmd->tlv_header,
3824 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3825 WMITLV_GET_STRUCT_TLVLEN(
3826 wmi_dcc_update_ndl_cmd_fixed_param));
3827 cmd->vdev_id = update_ndl_param->vdev_id;
3828 cmd->num_channel = update_ndl_param->channel_count;
3829
3830 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3831 update_ndl_param->dcc_ndl_chan_list_len);
3832 buf_ptr += WMI_TLV_HDR_SIZE;
3833
3834 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303835 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303836 update_ndl_param->dcc_ndl_chan_list_len);
3837 for (i = 0; i < cmd->num_channel; i++)
3838 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3839 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3840 WMITLV_GET_STRUCT_TLVLEN(
3841 wmi_dcc_ndl_chan));
3842 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3843
3844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3845 update_ndl_param->dcc_ndl_active_state_list_len);
3846 buf_ptr += WMI_TLV_HDR_SIZE;
3847
3848 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303849 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303850 update_ndl_param->dcc_ndl_active_state_list,
3851 update_ndl_param->dcc_ndl_active_state_list_len);
3852 for (i = 0; i < active_state_count; i++) {
3853 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3854 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3855 WMITLV_GET_STRUCT_TLVLEN(
3856 wmi_dcc_ndl_active_state_config));
3857 }
3858 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3859
3860 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303861 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303862 WMI_DCC_UPDATE_NDL_CMDID);
3863 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303864 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303865 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303866 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303867 }
3868
Govind Singh67922e82016-04-01 16:48:57 +05303869 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303870}
3871
3872/**
3873 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3874 * @wmi_handle: pointer to the wmi handle
3875 * @config: the OCB configuration
3876 *
3877 * Return: 0 on success
3878 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303879static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303880 struct ocb_config_param *config, uint32_t *ch_mhz)
3881{
Govind Singh67922e82016-04-01 16:48:57 +05303882 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303883 wmi_ocb_set_config_cmd_fixed_param *cmd;
3884 wmi_channel *chan;
3885 wmi_ocb_channel *ocb_chan;
3886 wmi_qos_parameter *qos_param;
3887 wmi_dcc_ndl_chan *ndl_chan;
3888 wmi_dcc_ndl_active_state_config *ndl_active_config;
3889 wmi_ocb_schedule_element *sched_elem;
3890 uint8_t *buf_ptr;
3891 wmi_buf_t buf;
3892 int32_t len;
3893 int32_t i, j, active_state_count;
3894
3895 /*
3896 * Validate the dcc_ndl_chan_list_len and count the number of active
3897 * states. Validate dcc_ndl_active_state_list_len.
3898 */
3899 active_state_count = 0;
3900 if (config->dcc_ndl_chan_list_len) {
3901 if (!config->dcc_ndl_chan_list ||
3902 config->dcc_ndl_chan_list_len !=
3903 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303904 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303905 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303906 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303907 }
3908
3909 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3910 i < config->channel_count; ++i, ++ndl_chan)
3911 active_state_count +=
3912 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3913
3914 if (active_state_count) {
3915 if (!config->dcc_ndl_active_state_list ||
3916 config->dcc_ndl_active_state_list_len !=
3917 active_state_count *
3918 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303919 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303920 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303921 }
3922 }
3923 }
3924
3925 len = sizeof(*cmd) +
3926 WMI_TLV_HDR_SIZE + config->channel_count *
3927 sizeof(wmi_channel) +
3928 WMI_TLV_HDR_SIZE + config->channel_count *
3929 sizeof(wmi_ocb_channel) +
3930 WMI_TLV_HDR_SIZE + config->channel_count *
3931 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3932 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3933 WMI_TLV_HDR_SIZE + active_state_count *
3934 sizeof(wmi_dcc_ndl_active_state_config) +
3935 WMI_TLV_HDR_SIZE + config->schedule_size *
3936 sizeof(wmi_ocb_schedule_element);
3937 buf = wmi_buf_alloc(wmi_handle, len);
3938 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303939 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303940 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303941 }
3942
3943 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3944 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3945 WMITLV_SET_HDR(&cmd->tlv_header,
3946 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3947 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3948 cmd->vdev_id = config->session_id;
3949 cmd->channel_count = config->channel_count;
3950 cmd->schedule_size = config->schedule_size;
3951 cmd->flags = config->flags;
3952 buf_ptr += sizeof(*cmd);
3953
3954 /* Add the wmi_channel info */
3955 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3956 config->channel_count*sizeof(wmi_channel));
3957 buf_ptr += WMI_TLV_HDR_SIZE;
3958 for (i = 0; i < config->channel_count; i++) {
3959 chan = (wmi_channel *)buf_ptr;
3960 WMITLV_SET_HDR(&chan->tlv_header,
3961 WMITLV_TAG_STRUC_wmi_channel,
3962 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3963 chan->mhz = config->channels[i].chan_freq;
3964 chan->band_center_freq1 = config->channels[i].chan_freq;
3965 chan->band_center_freq2 = 0;
3966 chan->info = 0;
3967
3968 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3969 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3970 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3971 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3972 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3973 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3974 config->channels[i].antenna_max);
3975
3976 if (config->channels[i].bandwidth < 10)
3977 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3978 else if (config->channels[i].bandwidth < 20)
3979 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3980 buf_ptr += sizeof(*chan);
3981 }
3982
3983 /* Add the wmi_ocb_channel info */
3984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3985 config->channel_count*sizeof(wmi_ocb_channel));
3986 buf_ptr += WMI_TLV_HDR_SIZE;
3987 for (i = 0; i < config->channel_count; i++) {
3988 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3989 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3990 WMITLV_TAG_STRUC_wmi_ocb_channel,
3991 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3992 ocb_chan->bandwidth = config->channels[i].bandwidth;
3993 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3994 config->channels[i].mac_address.bytes,
3995 &ocb_chan->mac_address);
3996 buf_ptr += sizeof(*ocb_chan);
3997 }
3998
3999 /* Add the wmi_qos_parameter info */
4000 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4001 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4002 buf_ptr += WMI_TLV_HDR_SIZE;
4003 /* WMI_MAX_NUM_AC parameters for each channel */
4004 for (i = 0; i < config->channel_count; i++) {
4005 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4006 qos_param = (wmi_qos_parameter *)buf_ptr;
4007 WMITLV_SET_HDR(&qos_param->tlv_header,
4008 WMITLV_TAG_STRUC_wmi_qos_parameter,
4009 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4010 qos_param->aifsn =
4011 config->channels[i].qos_params[j].aifsn;
4012 qos_param->cwmin =
4013 config->channels[i].qos_params[j].cwmin;
4014 qos_param->cwmax =
4015 config->channels[i].qos_params[j].cwmax;
4016 buf_ptr += sizeof(*qos_param);
4017 }
4018 }
4019
4020 /* Add the wmi_dcc_ndl_chan (per channel) */
4021 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4022 config->dcc_ndl_chan_list_len);
4023 buf_ptr += WMI_TLV_HDR_SIZE;
4024 if (config->dcc_ndl_chan_list_len) {
4025 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304026 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304027 config->dcc_ndl_chan_list_len);
4028 for (i = 0; i < config->channel_count; i++)
4029 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4030 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4031 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4032 buf_ptr += config->dcc_ndl_chan_list_len;
4033 }
4034
4035 /* Add the wmi_dcc_ndl_active_state_config */
4036 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4037 sizeof(wmi_dcc_ndl_active_state_config));
4038 buf_ptr += WMI_TLV_HDR_SIZE;
4039 if (active_state_count) {
4040 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304041 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304042 config->dcc_ndl_active_state_list,
4043 active_state_count * sizeof(*ndl_active_config));
4044 for (i = 0; i < active_state_count; ++i)
4045 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4046 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4047 WMITLV_GET_STRUCT_TLVLEN(
4048 wmi_dcc_ndl_active_state_config));
4049 buf_ptr += active_state_count *
4050 sizeof(*ndl_active_config);
4051 }
4052
4053 /* Add the wmi_ocb_schedule_element info */
4054 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4055 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4056 buf_ptr += WMI_TLV_HDR_SIZE;
4057 for (i = 0; i < config->schedule_size; i++) {
4058 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4059 WMITLV_SET_HDR(&sched_elem->tlv_header,
4060 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4061 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4062 sched_elem->channel_freq = config->schedule[i].chan_freq;
4063 sched_elem->total_duration = config->schedule[i].total_duration;
4064 sched_elem->guard_interval = config->schedule[i].guard_interval;
4065 buf_ptr += sizeof(*sched_elem);
4066 }
4067
4068
4069 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4070 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304071 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304072 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304073 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304074 }
4075
Govind Singh67922e82016-04-01 16:48:57 +05304076 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304077}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304078
4079/**
4080 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4081 * @wmi_handle: wmi handle
4082 * @mcc_adaptive_scheduler: enable/disable
4083 *
4084 * This function enable/disable mcc adaptive scheduler in fw.
4085 *
Govind Singhb53420c2016-03-09 14:32:57 +05304086 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304087 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304088static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004089 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4090 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304091{
Govind Singh67922e82016-04-01 16:48:57 +05304092 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304093 wmi_buf_t buf = 0;
4094 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4095 uint16_t len =
4096 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4097
4098 buf = wmi_buf_alloc(wmi_handle, len);
4099 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304100 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4101 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304102 }
4103 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4104 wmi_buf_data(buf);
4105
4106 WMITLV_SET_HDR(&cmd->tlv_header,
4107 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4108 WMITLV_GET_STRUCT_TLVLEN
4109 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4110 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304111 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304112
4113 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4114 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304115 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304116 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304117 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304118 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304119 }
Govind Singh67922e82016-04-01 16:48:57 +05304120
4121 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304122}
4123
4124/**
4125 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4126 * @wmi: wmi handle
4127 * @mcc_channel: mcc channel
4128 * @mcc_channel_time_latency: MCC channel time latency.
4129 *
4130 * Currently used to set time latency for an MCC vdev/adapter using operating
4131 * channel of it and channel number. The info is provided run time using
4132 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4133 *
4134 * Return: CDF status
4135 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304136static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304137 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4138{
Govind Singh67922e82016-04-01 16:48:57 +05304139 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304140 wmi_buf_t buf = 0;
4141 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4142 uint16_t len = 0;
4143 uint8_t *buf_ptr = NULL;
4144 wmi_resmgr_chan_latency chan_latency;
4145 /* Note: we only support MCC time latency for a single channel */
4146 uint32_t num_channels = 1;
4147 uint32_t chan1_freq = mcc_channel_freq;
4148 uint32_t latency_chan1 = mcc_channel_time_latency;
4149
4150
4151 /* If 0ms latency is provided, then FW will set to a default.
4152 * Otherwise, latency must be at least 30ms.
4153 */
4154 if ((latency_chan1 > 0) &&
4155 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304156 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304157 "Minimum is 30ms (or 0 to use default value by "
4158 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304159 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304160 }
4161
4162 /* Set WMI CMD for channel time latency here */
4163 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4164 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4165 num_channels * sizeof(wmi_resmgr_chan_latency);
4166 buf = wmi_buf_alloc(wmi_handle, len);
4167 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304168 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4169 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304170 }
4171 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4172 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4173 wmi_buf_data(buf);
4174 WMITLV_SET_HDR(&cmdTL->tlv_header,
4175 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4176 WMITLV_GET_STRUCT_TLVLEN
4177 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4178 cmdTL->num_chans = num_channels;
4179 /* Update channel time latency information for home channel(s) */
4180 buf_ptr += sizeof(*cmdTL);
4181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4182 num_channels * sizeof(wmi_resmgr_chan_latency));
4183 buf_ptr += WMI_TLV_HDR_SIZE;
4184 chan_latency.chan_mhz = chan1_freq;
4185 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304186 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304187 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4188 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304189 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304190 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304191 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304192 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304193 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304194 }
Govind Singh67922e82016-04-01 16:48:57 +05304195
4196 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304197}
4198
4199/**
4200 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4201 * @wmi: wmi handle
4202 * @adapter_1_chan_number: adapter 1 channel number
4203 * @adapter_1_quota: adapter 1 quota
4204 * @adapter_2_chan_number: adapter 2 channel number
4205 *
4206 * Return: CDF status
4207 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304208static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304209 uint32_t adapter_1_chan_freq,
4210 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4211{
Govind Singh67922e82016-04-01 16:48:57 +05304212 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304213 wmi_buf_t buf = 0;
4214 uint16_t len = 0;
4215 uint8_t *buf_ptr = NULL;
4216 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4217 wmi_resmgr_chan_time_quota chan_quota;
4218 uint32_t quota_chan1 = adapter_1_quota;
4219 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4220 uint32_t quota_chan2 = 100 - quota_chan1;
4221 /* Note: setting time quota for MCC requires info for 2 channels */
4222 uint32_t num_channels = 2;
4223 uint32_t chan1_freq = adapter_1_chan_freq;
4224 uint32_t chan2_freq = adapter_2_chan_freq;
4225
Govind Singhb53420c2016-03-09 14:32:57 +05304226 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304227 "freq2:%dMHz, Quota2:%dms", __func__,
4228 chan1_freq, quota_chan1, chan2_freq,
4229 quota_chan2);
4230
4231 /*
4232 * Perform sanity check on time quota values provided.
4233 */
4234 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4235 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304236 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304237 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304238 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304239 }
4240 /* Set WMI CMD for channel time quota here */
4241 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4242 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4243 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4244 buf = wmi_buf_alloc(wmi_handle, len);
4245 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304246 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4247 QDF_ASSERT(0);
4248 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304249 }
4250 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4251 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4252 wmi_buf_data(buf);
4253 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4254 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4255 WMITLV_GET_STRUCT_TLVLEN
4256 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4257 cmdTQ->num_chans = num_channels;
4258
4259 /* Update channel time quota information for home channel(s) */
4260 buf_ptr += sizeof(*cmdTQ);
4261 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4262 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4263 buf_ptr += WMI_TLV_HDR_SIZE;
4264 chan_quota.chan_mhz = chan1_freq;
4265 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304266 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304267 /* Construct channel and quota record for the 2nd MCC mode. */
4268 buf_ptr += sizeof(chan_quota);
4269 chan_quota.chan_mhz = chan2_freq;
4270 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304271 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304272
4273 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4274 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304275 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304276 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304277 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304278 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304279 }
Govind Singh67922e82016-04-01 16:48:57 +05304280
4281 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304282}
4283
4284/**
4285 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4286 * @wmi_handle: Pointer to wmi handle
4287 * @thermal_info: Thermal command information
4288 *
4289 * This function sends the thermal management command
4290 * to the firmware
4291 *
Govind Singhb53420c2016-03-09 14:32:57 +05304292 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304293 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304294static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304295 struct thermal_cmd_params *thermal_info)
4296{
4297 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4298 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304299 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304300 uint32_t len = 0;
4301
4302 len = sizeof(*cmd);
4303
4304 buf = wmi_buf_alloc(wmi_handle, len);
4305 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304306 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4307 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304308 }
4309
4310 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4311
4312 WMITLV_SET_HDR(&cmd->tlv_header,
4313 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4314 WMITLV_GET_STRUCT_TLVLEN
4315 (wmi_thermal_mgmt_cmd_fixed_param));
4316
4317 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4318 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4319 cmd->enable = thermal_info->thermal_enable;
4320
Govind Singhb53420c2016-03-09 14:32:57 +05304321 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304322 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4323
4324 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4325 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304326 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304327 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304328 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304329 }
4330
Govind Singh67922e82016-04-01 16:48:57 +05304331 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304332}
4333
4334
4335/**
4336 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304337 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304338 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4339 *
4340 * This function sends down the LRO configuration parameters to
4341 * the firmware to enable LRO, sets the TCP flags and sets the
4342 * seed values for the toeplitz hash generation
4343 *
Govind Singhb53420c2016-03-09 14:32:57 +05304344 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304346static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304347 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4348{
4349 wmi_lro_info_cmd_fixed_param *cmd;
4350 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304351 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304352
4353
4354 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304356 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4357 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304358 }
4359
4360 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4361
4362 WMITLV_SET_HDR(&cmd->tlv_header,
4363 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4364 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4365
4366 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4367 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4368 wmi_lro_cmd->tcp_flag);
4369 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4370 wmi_lro_cmd->tcp_flag_mask);
4371 cmd->toeplitz_hash_ipv4_0_3 =
4372 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4373 cmd->toeplitz_hash_ipv4_4_7 =
4374 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4375 cmd->toeplitz_hash_ipv4_8_11 =
4376 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4377 cmd->toeplitz_hash_ipv4_12_15 =
4378 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4379 cmd->toeplitz_hash_ipv4_16 =
4380 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4381
4382 cmd->toeplitz_hash_ipv6_0_3 =
4383 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4384 cmd->toeplitz_hash_ipv6_4_7 =
4385 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4386 cmd->toeplitz_hash_ipv6_8_11 =
4387 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4388 cmd->toeplitz_hash_ipv6_12_15 =
4389 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4390 cmd->toeplitz_hash_ipv6_16_19 =
4391 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4392 cmd->toeplitz_hash_ipv6_20_23 =
4393 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4394 cmd->toeplitz_hash_ipv6_24_27 =
4395 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4396 cmd->toeplitz_hash_ipv6_28_31 =
4397 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4398 cmd->toeplitz_hash_ipv6_32_35 =
4399 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4400 cmd->toeplitz_hash_ipv6_36_39 =
4401 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4402 cmd->toeplitz_hash_ipv6_40 =
4403 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4404
Govind Singhb53420c2016-03-09 14:32:57 +05304405 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304406 cmd->lro_enable, cmd->tcp_flag_u32);
4407
4408 status = wmi_unified_cmd_send(wmi_handle, buf,
4409 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304410 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304411 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304412 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304413 }
4414
Govind Singh67922e82016-04-01 16:48:57 +05304415 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304416}
4417
Govind Singh4eacd2b2016-03-07 14:24:22 +05304418/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304419 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4420 * @wmi_handle: Pointer to wmi handle
4421 * @rate_report_params: Pointer to peer rate report parameters
4422 *
4423 *
4424 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4425 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304426static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304427 struct wmi_peer_rate_report_params *rate_report_params)
4428{
4429 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4430 wmi_buf_t buf = NULL;
4431 QDF_STATUS status = 0;
4432 uint32_t len = 0;
4433 uint32_t i, j;
4434
4435 len = sizeof(*cmd);
4436
4437 buf = wmi_buf_alloc(wmi_handle, len);
4438 if (!buf) {
4439 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4440 return QDF_STATUS_E_FAILURE;
4441 }
4442
4443 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4444 wmi_buf_data(buf);
4445
4446 WMITLV_SET_HDR(
4447 &cmd->tlv_header,
4448 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4449 WMITLV_GET_STRUCT_TLVLEN(
4450 wmi_peer_set_rate_report_condition_fixed_param));
4451
4452 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4453 cmd->report_backoff_time = rate_report_params->backoff_time;
4454 cmd->report_timer_period = rate_report_params->timer_period;
4455 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4456 cmd->cond_per_phy[i].val_cond_flags =
4457 rate_report_params->report_per_phy[i].cond_flags;
4458 cmd->cond_per_phy[i].rate_delta.min_delta =
4459 rate_report_params->report_per_phy[i].delta.delta_min;
4460 cmd->cond_per_phy[i].rate_delta.percentage =
4461 rate_report_params->report_per_phy[i].delta.percent;
4462 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4463 cmd->cond_per_phy[i].rate_threshold[j] =
4464 rate_report_params->report_per_phy[i].
4465 report_rate_threshold[j];
4466 }
4467 }
4468
4469 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4470 cmd->enable_rate_report,
4471 cmd->report_backoff_time, cmd->report_timer_period);
4472
4473 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4474 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4475 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304476 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304477 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4478 __func__);
4479 }
4480 return status;
4481}
4482
4483/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304484 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4485 * @wmi_handle: wmi handle
4486 * @param: bcn ll cmd parameter
4487 *
Govind Singhb53420c2016-03-09 14:32:57 +05304488 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304489 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304490static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304491 wmi_bcn_send_from_host_cmd_fixed_param *param)
4492{
4493 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4494 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304495 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304496
4497 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4498 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304499 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4500 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304501 }
4502
4503 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4504 WMITLV_SET_HDR(&cmd->tlv_header,
4505 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4506 WMITLV_GET_STRUCT_TLVLEN
4507 (wmi_bcn_send_from_host_cmd_fixed_param));
4508 cmd->vdev_id = param->vdev_id;
4509 cmd->data_len = param->data_len;
4510 cmd->frame_ctrl = param->frame_ctrl;
4511 cmd->frag_ptr = param->frag_ptr;
4512 cmd->dtim_flag = param->dtim_flag;
4513
4514 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4515 WMI_PDEV_SEND_BCN_CMDID);
4516
Govind Singh67922e82016-04-01 16:48:57 +05304517 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304518 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304519 wmi_buf_free(wmi_buf);
4520 }
4521
4522 return ret;
4523}
4524
4525/**
4526 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4527 * @wmi_handle: wmi handle
4528 * @vdev_id: vdev id
4529 * @max_retries: max retries
4530 * @retry_interval: retry interval
4531 * This function sets sta query related parameters in fw.
4532 *
Govind Singhb53420c2016-03-09 14:32:57 +05304533 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304534 */
4535
Sathish Kumarfd347372017-02-13 12:29:09 +05304536static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 uint8_t vdev_id, uint32_t max_retries,
4538 uint32_t retry_interval)
4539{
4540 wmi_buf_t buf;
4541 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4542 int len;
4543
4544 len = sizeof(*cmd);
4545 buf = wmi_buf_alloc(wmi_handle, len);
4546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304547 WMI_LOGE(FL("wmi_buf_alloc failed"));
4548 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549 }
4550
4551 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4552 WMITLV_SET_HDR(&cmd->tlv_header,
4553 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4554 WMITLV_GET_STRUCT_TLVLEN
4555 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4556
4557
4558 cmd->vdev_id = vdev_id;
4559 cmd->sa_query_max_retry_count = max_retries;
4560 cmd->sa_query_retry_interval = retry_interval;
4561
Govind Singhb53420c2016-03-09 14:32:57 +05304562 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304563 vdev_id, retry_interval, max_retries);
4564
4565 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4566 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304567 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304568 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304569 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304570 }
4571
Govind Singhb53420c2016-03-09 14:32:57 +05304572 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304573 return 0;
4574}
4575
4576/**
4577 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4578 * @wmi_handle: wmi handle
4579 * @params: sta keep alive parameter
4580 *
4581 * This function sets keep alive related parameters in fw.
4582 *
4583 * Return: CDF status
4584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304585static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304586 struct sta_params *params)
4587{
4588 wmi_buf_t buf;
4589 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4590 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4591 uint8_t *buf_ptr;
4592 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304593 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304594
Govind Singhb53420c2016-03-09 14:32:57 +05304595 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596
Govind Singh4eacd2b2016-03-07 14:24:22 +05304597 len = sizeof(*cmd) + sizeof(*arp_rsp);
4598 buf = wmi_buf_alloc(wmi_handle, len);
4599 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304600 WMI_LOGE("wmi_buf_alloc failed");
4601 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304602 }
4603
4604 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4605 buf_ptr = (uint8_t *) cmd;
4606 WMITLV_SET_HDR(&cmd->tlv_header,
4607 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4608 WMITLV_GET_STRUCT_TLVLEN
4609 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4610 cmd->interval = params->timeperiod;
4611 cmd->enable = (params->timeperiod) ? 1 : 0;
4612 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304613 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304614 params->timeperiod, params->method);
4615 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4616 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4617 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4618 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4619
4620 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4621 if ((NULL == params->hostv4addr) ||
4622 (NULL == params->destv4addr) ||
4623 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304624 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304625 "destv4addr:%p destmac:%p ", __func__,
4626 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304627 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304628 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304629 }
4630 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304631 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304632 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304633 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634 WMI_IPV4_ADDR_LEN);
4635 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4636 } else {
4637 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4638 }
4639
Govind Singh67922e82016-04-01 16:48:57 +05304640 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4641 WMI_STA_KEEPALIVE_CMDID);
4642 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304643 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304644 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304645 }
4646
Govind Singhb53420c2016-03-09 14:32:57 +05304647 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304648 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304649}
4650
4651/**
4652 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4653 * @wmi_handle: wmi handle
4654 * @if_id: vdev id
4655 * @gtx_info: GTX config params
4656 *
4657 * This function set GTX related params in firmware.
4658 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304659 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304660 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304661static 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 +05304662 struct wmi_gtx_config *gtx_info)
4663{
4664 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4665 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304666 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304667 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304668
Govind Singh4eacd2b2016-03-07 14:24:22 +05304669 buf = wmi_buf_alloc(wmi_handle, len);
4670 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304671 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304672 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304673 }
4674 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4675 WMITLV_SET_HDR(&cmd->tlv_header,
4676 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4677 WMITLV_GET_STRUCT_TLVLEN
4678 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4679 cmd->vdev_id = if_id;
4680
4681 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4682 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4683 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4684 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4685 cmd->gtxPERMargin = gtx_info->gtx_margin;
4686 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4687 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4688 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4689
Govind Singhb53420c2016-03-09 14:32:57 +05304690 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304691 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4692 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4693 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4694 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4695
Abhishek Singh716c46c2016-05-04 16:24:07 +05304696 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304697 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304698 if (QDF_IS_STATUS_ERROR(ret)) {
4699 WMI_LOGE("Failed to set GTX PARAMS");
4700 wmi_buf_free(buf);
4701 }
4702 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304703}
4704
4705/**
4706 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4707 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304708 * @vdev_id: vdev id.
4709 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05304710 *
4711 * This function updates EDCA parameters to the target
4712 *
4713 * Return: CDF Status
4714 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304715static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304716 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304717 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05304718{
4719 uint8_t *buf_ptr;
4720 wmi_buf_t buf;
4721 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304722 wmi_wmm_vparams *wmm_param;
4723 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304724 int len = sizeof(*cmd);
4725 int ac;
4726
4727 buf = wmi_buf_alloc(wmi_handle, len);
4728
4729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304730 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4731 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304732 }
4733
4734 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4735 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4736 WMITLV_SET_HDR(&cmd->tlv_header,
4737 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4738 WMITLV_GET_STRUCT_TLVLEN
4739 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4740 cmd->vdev_id = vdev_id;
4741
4742 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4743 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304744 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304745 WMITLV_SET_HDR(&wmm_param->tlv_header,
4746 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4747 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4748 wmm_param->cwmin = twmm_param->cwmin;
4749 wmm_param->cwmax = twmm_param->cwmax;
4750 wmm_param->aifs = twmm_param->aifs;
4751 wmm_param->txoplimit = twmm_param->txoplimit;
4752 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05304753 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304754 }
4755
4756 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4757 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4758 goto fail;
4759
Govind Singhb53420c2016-03-09 14:32:57 +05304760 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304761
4762fail:
4763 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304764 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4765 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304766}
4767
4768/**
4769 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4770 * @wmi_handle: wmi handle
4771 * @vdev_id: vdev id
4772 * @probe_rsp_info: probe response info
4773 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304774 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304775 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304776static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304777 uint8_t vdev_id,
4778 struct wmi_probe_resp_params *probe_rsp_info,
4779 uint8_t *frm)
4780{
4781 wmi_prb_tmpl_cmd_fixed_param *cmd;
4782 wmi_bcn_prb_info *bcn_prb_info;
4783 wmi_buf_t wmi_buf;
4784 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4785 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304786 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304787
Govind Singhb53420c2016-03-09 14:32:57 +05304788 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304789
4790 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4791 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4792
4793 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4794 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4795 tmpl_len_aligned;
4796
4797 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304798 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304799 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304800 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304801 }
4802
4803 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4804 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304806 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304807 }
4808
4809 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4810
4811 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4812 WMITLV_SET_HDR(&cmd->tlv_header,
4813 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4814 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4815 cmd->vdev_id = vdev_id;
4816 cmd->buf_len = tmpl_len;
4817 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4818
4819 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4820 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4821 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4822 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4823 bcn_prb_info->caps = 0;
4824 bcn_prb_info->erp = 0;
4825 buf_ptr += sizeof(wmi_bcn_prb_info);
4826
4827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4828 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304829 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304830
4831 ret = wmi_unified_cmd_send(wmi_handle,
4832 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304833 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304834 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304835 wmi_buf_free(wmi_buf);
4836 }
4837
4838 return ret;
4839}
4840
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304841#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304842#define WPI_IV_LEN 16
4843
4844/**
4845 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4846 *
4847 * @dest_tx: destination address of tsc key counter
4848 * @src_tx: source address of tsc key counter
4849 * @dest_rx: destination address of rsc key counter
4850 * @src_rx: source address of rsc key counter
4851 *
4852 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4853 *
4854 * Return: None
4855 *
4856 */
4857static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4858 uint8_t *dest_rx, uint8_t *src_rx)
4859{
4860 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4861 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4862}
4863#else
4864static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4865 uint8_t *dest_rx, uint8_t *src_rx)
4866{
4867 return;
4868}
4869#endif
4870
4871/**
4872 * send_setup_install_key_cmd_tlv() - set key parameters
4873 * @wmi_handle: wmi handle
4874 * @key_params: key parameters
4875 *
4876 * This function fills structure from information
4877 * passed in key_params.
4878 *
4879 * Return: QDF_STATUS_SUCCESS - success
4880 * QDF_STATUS_E_FAILURE - failure
4881 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304883static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304884 struct set_key_params *key_params)
4885{
4886 wmi_vdev_install_key_cmd_fixed_param *cmd;
4887 wmi_buf_t buf;
4888 uint8_t *buf_ptr;
4889 uint32_t len;
4890 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304891 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304892
4893 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4894 WMI_TLV_HDR_SIZE;
4895
4896 buf = wmi_buf_alloc(wmi_handle, len);
4897 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304898 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304899 return QDF_STATUS_E_NOMEM;
4900 }
4901
4902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4903 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4904 WMITLV_SET_HDR(&cmd->tlv_header,
4905 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4906 WMITLV_GET_STRUCT_TLVLEN
4907 (wmi_vdev_install_key_cmd_fixed_param));
4908 cmd->vdev_id = key_params->vdev_id;
4909 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304910
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304911
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304912 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4913 cmd->key_flags |= key_params->key_flags;
4914 cmd->key_cipher = key_params->key_cipher;
4915 if ((key_params->key_txmic_len) &&
4916 (key_params->key_rxmic_len)) {
4917 cmd->key_txmic_len = key_params->key_txmic_len;
4918 cmd->key_rxmic_len = key_params->key_rxmic_len;
4919 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304920#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304921 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4922 key_params->tx_iv,
4923 cmd->wpi_key_rsc_counter,
4924 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304925#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304926 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4928 roundup(key_params->key_len, sizeof(uint32_t)));
4929 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4930 qdf_mem_copy((void *)key_data,
4931 (const void *)key_params->key_data, key_params->key_len);
4932 cmd->key_len = key_params->key_len;
4933
4934 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4935 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304936 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304937 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304938
Govind Singh67922e82016-04-01 16:48:57 +05304939 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304940}
4941
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304942/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004943 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4944 * @wmi_handle: wmi handle
4945 * @params: sar limit params
4946 *
4947 * Return: QDF_STATUS_SUCCESS for success or error code
4948 */
4949static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4950 struct sar_limit_cmd_params *sar_limit_params)
4951{
4952 wmi_buf_t buf;
4953 QDF_STATUS qdf_status;
4954 wmi_sar_limits_cmd_fixed_param *cmd;
4955 int i;
4956 uint8_t *buf_ptr;
4957 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4958 struct sar_limit_cmd_row *sar_rows_list;
4959 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4960
4961 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4962 buf = wmi_buf_alloc(wmi_handle, len);
4963 if (!buf) {
4964 WMI_LOGE("Failed to allocate memory");
4965 qdf_status = QDF_STATUS_E_NOMEM;
4966 goto end;
4967 }
4968
4969 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4970 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4971 WMITLV_SET_HDR(&cmd->tlv_header,
4972 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4973 WMITLV_GET_STRUCT_TLVLEN
4974 (wmi_sar_limits_cmd_fixed_param));
4975 cmd->sar_enable = sar_limit_params->sar_enable;
4976 cmd->commit_limits = sar_limit_params->commit_limits;
4977 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4978
4979 WMI_LOGD("no of sar rows = %d, len = %d",
4980 sar_limit_params->num_limit_rows, len);
4981 buf_ptr += sizeof(*cmd);
4982 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4983 sizeof(wmi_sar_limit_cmd_row) *
4984 sar_limit_params->num_limit_rows);
4985 if (cmd->num_limit_rows == 0)
4986 goto send_sar_limits;
4987
4988 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4989 (buf_ptr + WMI_TLV_HDR_SIZE);
4990 sar_rows_list = sar_limit_params->sar_limit_row_list;
4991
4992 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4993 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4994 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4995 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4996 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4997 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4998 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4999 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5000 wmi_sar_rows_list->validity_bitmap =
5001 sar_rows_list->validity_bitmap;
5002 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5003 i, wmi_sar_rows_list->band_id,
5004 wmi_sar_rows_list->chain_id,
5005 wmi_sar_rows_list->mod_id,
5006 wmi_sar_rows_list->limit_value,
5007 wmi_sar_rows_list->validity_bitmap);
5008 sar_rows_list++;
5009 wmi_sar_rows_list++;
5010 }
5011send_sar_limits:
5012 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5013 WMI_SAR_LIMITS_CMDID);
5014
5015 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5016 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5017 wmi_buf_free(buf);
5018 }
5019
5020end:
5021 return qdf_status;
5022}
5023
5024/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305025 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5026 * @wmi_handle: wmi handle
5027 * @params: encrypt/decrypt params
5028 *
5029 * Return: QDF_STATUS_SUCCESS for success or error code
5030 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005031static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305032QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
5033 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
5034{
5035 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5036 wmi_buf_t wmi_buf;
5037 uint8_t *buf_ptr;
5038 QDF_STATUS ret;
5039 uint32_t len;
5040
5041 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5042
5043 len = sizeof(*cmd) +
5044 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5045 WMI_TLV_HDR_SIZE;
5046 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5047 if (!wmi_buf) {
5048 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5049 __func__);
5050 return QDF_STATUS_E_NOMEM;
5051 }
5052
5053 buf_ptr = wmi_buf_data(wmi_buf);
5054 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5055
5056 WMITLV_SET_HDR(&cmd->tlv_header,
5057 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5058 WMITLV_GET_STRUCT_TLVLEN(
5059 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5060
5061 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5062 cmd->key_flag = encrypt_decrypt_params->key_flag;
5063 cmd->key_idx = encrypt_decrypt_params->key_idx;
5064 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5065 cmd->key_len = encrypt_decrypt_params->key_len;
5066 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5067 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5068
5069 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5070 encrypt_decrypt_params->key_len);
5071
5072 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5073 MAX_MAC_HEADER_LEN);
5074
5075 cmd->data_len = encrypt_decrypt_params->data_len;
5076
5077 if (cmd->data_len) {
5078 buf_ptr += sizeof(*cmd);
5079 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5080 roundup(encrypt_decrypt_params->data_len,
5081 sizeof(A_UINT32)));
5082 buf_ptr += WMI_TLV_HDR_SIZE;
5083 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5084 encrypt_decrypt_params->data_len);
5085 }
5086
5087 /* This conversion is to facilitate data to FW in little endian */
5088 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5089 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5090 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5091 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5092 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5093 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5094
5095 ret = wmi_unified_cmd_send(wmi_handle,
5096 wmi_buf, len,
5097 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5098 if (QDF_IS_STATUS_ERROR(ret)) {
5099 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5100 wmi_buf_free(wmi_buf);
5101 }
5102
5103 return ret;
5104}
5105
5106
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305107
Govind Singh4eacd2b2016-03-07 14:24:22 +05305108/**
5109 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5110 * @wmi_handle: wmi handle
5111 * @vdev_id: vdev id
5112 * @p2p_ie: p2p IE
5113 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305114 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305115 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305116static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305117 A_UINT32 vdev_id, uint8_t *p2p_ie)
5118{
Govind Singh67922e82016-04-01 16:48:57 +05305119 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305120 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5121 wmi_buf_t wmi_buf;
5122 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5123 uint8_t *buf_ptr;
5124
5125 ie_len = (uint32_t) (p2p_ie[1] + 2);
5126
5127 /* More than one P2P IE may be included in a single frame.
5128 If multiple P2P IEs are present, the complete P2P attribute
5129 data consists of the concatenation of the P2P Attribute
5130 fields of the P2P IEs. The P2P Attributes field of each
5131 P2P IE may be any length up to the maximum (251 octets).
5132 In this case host sends one P2P IE to firmware so the length
5133 should not exceed more than 251 bytes
5134 */
5135 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305136 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305137 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305138 }
5139
5140 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5141
5142 wmi_buf_len =
5143 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5144 WMI_TLV_HDR_SIZE;
5145
5146 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5147 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305148 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305149 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305150 }
5151
5152 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5153
5154 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5155 WMITLV_SET_HDR(&cmd->tlv_header,
5156 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5157 WMITLV_GET_STRUCT_TLVLEN
5158 (wmi_p2p_go_set_beacon_ie_fixed_param));
5159 cmd->vdev_id = vdev_id;
5160 cmd->ie_buf_len = ie_len;
5161
5162 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5163 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5164 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305165 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305166
Govind Singhb53420c2016-03-09 14:32:57 +05305167 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305168
5169 ret = wmi_unified_cmd_send(wmi_handle,
5170 wmi_buf, wmi_buf_len,
5171 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305172 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305173 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305174 wmi_buf_free(wmi_buf);
5175 }
5176
Govind Singhb53420c2016-03-09 14:32:57 +05305177 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305178 return ret;
5179}
5180
5181/**
5182 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5183 * @wmi_handle: wmi handle
5184 * @req: gateway parameter update request structure
5185 *
5186 * This function reads the incoming @req and fill in the destination
5187 * WMI structure and sends down the gateway configs down to the firmware
5188 *
Govind Singhb53420c2016-03-09 14:32:57 +05305189 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305190 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305191static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 struct gateway_update_req_param *req)
5193{
5194 wmi_roam_subnet_change_config_fixed_param *cmd;
5195 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305196 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305197 int len = sizeof(*cmd);
5198
5199 buf = wmi_buf_alloc(wmi_handle, len);
5200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305201 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5202 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305203 }
5204
5205 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5206 WMITLV_SET_HDR(&cmd->tlv_header,
5207 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5208 WMITLV_GET_STRUCT_TLVLEN(
5209 wmi_roam_subnet_change_config_fixed_param));
5210
5211 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305212 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5213 QDF_IPV4_ADDR_SIZE);
5214 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5215 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305216 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5217 &cmd->inet_gw_mac_addr);
5218 cmd->max_retries = req->max_retries;
5219 cmd->timeout = req->timeout;
5220 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5221 cmd->flag = 0;
5222 if (req->ipv4_addr_type)
5223 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5224
5225 if (req->ipv6_addr_type)
5226 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5227
5228 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5229 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305231 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305232 ret);
5233 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 }
5235
Govind Singh67922e82016-04-01 16:48:57 +05305236 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305237}
5238
5239/**
5240 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5241 * @wmi_handle: wmi handle
5242 * @req: rssi monitoring request structure
5243 *
5244 * This function reads the incoming @req and fill in the destination
5245 * WMI structure and send down the rssi monitoring configs down to the firmware
5246 *
5247 * Return: 0 on success; error number otherwise
5248 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305249static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305250 struct rssi_monitor_param *req)
5251{
5252 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5253 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305254 QDF_STATUS ret;
5255 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256
5257 buf = wmi_buf_alloc(wmi_handle, len);
5258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305259 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5260 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 }
5262
5263 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5264 WMITLV_SET_HDR(&cmd->tlv_header,
5265 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5266 WMITLV_GET_STRUCT_TLVLEN(
5267 wmi_rssi_breach_monitor_config_fixed_param));
5268
5269 cmd->vdev_id = req->session_id;
5270 cmd->request_id = req->request_id;
5271 cmd->lo_rssi_reenable_hysteresis = 0;
5272 cmd->hi_rssi_reenable_histeresis = 0;
5273 cmd->min_report_interval = 0;
5274 cmd->max_num_report = 1;
5275 if (req->control) {
5276 /* enable one threshold for each min/max */
5277 cmd->enabled_bitmap = 0x09;
5278 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5279 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5280 } else {
5281 cmd->enabled_bitmap = 0;
5282 cmd->low_rssi_breach_threshold[0] = 0;
5283 cmd->hi_rssi_breach_threshold[0] = 0;
5284 }
5285
5286 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5287 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305288 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305289 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305290 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305291 }
5292
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005293 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5294
Govind Singh67922e82016-04-01 16:48:57 +05305295 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305296}
5297
5298/**
5299 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5300 * @wmi_handle: wmi handle
5301 * @psetoui: OUI parameters
5302 *
5303 * set scan probe OUI parameters in firmware
5304 *
5305 * Return: CDF status
5306 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305307static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308 struct scan_mac_oui *psetoui)
5309{
5310 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5311 wmi_buf_t wmi_buf;
5312 uint32_t len;
5313 uint8_t *buf_ptr;
5314 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305315 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305316
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305317 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5318 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5319
Govind Singh4eacd2b2016-03-07 14:24:22 +05305320 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5321 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305322 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5323 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324 }
5325 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5326 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5327 WMITLV_SET_HDR(&cmd->tlv_header,
5328 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5329 WMITLV_GET_STRUCT_TLVLEN
5330 (wmi_scan_prob_req_oui_cmd_fixed_param));
5331
5332 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305333 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305334 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5335 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305336 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305337 cmd->prob_req_oui);
5338
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305339 cmd->vdev_id = psetoui->vdev_id;
5340 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5341 if (psetoui->enb_probe_req_sno_randomization)
5342 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5343
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305344 if (ie_whitelist->white_list) {
5345 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5346 &cmd->num_vendor_oui,
5347 ie_whitelist);
5348 cmd->flags |=
5349 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5350 }
5351
5352 buf_ptr += sizeof(*cmd);
5353 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5354 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5355 buf_ptr += WMI_TLV_HDR_SIZE;
5356
5357 if (cmd->num_vendor_oui != 0) {
5358 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5359 ie_whitelist->voui);
5360 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5361 }
5362
Govind Singh4eacd2b2016-03-07 14:24:22 +05305363 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5364 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305365 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305366 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305367 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305368 }
Govind Singhb53420c2016-03-09 14:32:57 +05305369 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305370}
5371
5372/**
5373 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5374 * @wmi_handle: wmi handle
5375 * @req: passpoint network request structure
5376 *
5377 * This function sends down WMI command with network id set to wildcard id.
5378 * firmware shall clear all the config entries
5379 *
Govind Singhb53420c2016-03-09 14:32:57 +05305380 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305381 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305382static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305383 struct wifi_passpoint_req_param *req)
5384{
5385 wmi_passpoint_config_cmd_fixed_param *cmd;
5386 wmi_buf_t buf;
5387 uint32_t len;
5388 int ret;
5389
5390 len = sizeof(*cmd);
5391 buf = wmi_buf_alloc(wmi_handle, len);
5392 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305393 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5394 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305395 }
5396
5397 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5398
5399 WMITLV_SET_HDR(&cmd->tlv_header,
5400 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5401 WMITLV_GET_STRUCT_TLVLEN(
5402 wmi_passpoint_config_cmd_fixed_param));
5403 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5404
5405 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5406 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5407 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305408 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305409 __func__);
5410 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305411 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305412 }
5413
Govind Singhb53420c2016-03-09 14:32:57 +05305414 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305415}
5416
5417/**
5418 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5419 * @wmi_handle: wmi handle
5420 * @req: passpoint network request structure
5421 *
5422 * This function reads the incoming @req and fill in the destination
5423 * WMI structure and send down the passpoint configs down to the firmware
5424 *
Govind Singhb53420c2016-03-09 14:32:57 +05305425 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305427static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305428 struct wifi_passpoint_req_param *req)
5429{
5430 wmi_passpoint_config_cmd_fixed_param *cmd;
5431 u_int8_t i, j, *bytes;
5432 wmi_buf_t buf;
5433 uint32_t len;
5434 int ret;
5435
5436 len = sizeof(*cmd);
5437 for (i = 0; i < req->num_networks; i++) {
5438 buf = wmi_buf_alloc(wmi_handle, len);
5439 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305440 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5441 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305442 }
5443
5444 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5445 wmi_buf_data(buf);
5446
5447 WMITLV_SET_HDR(&cmd->tlv_header,
5448 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5449 WMITLV_GET_STRUCT_TLVLEN(
5450 wmi_passpoint_config_cmd_fixed_param));
5451 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305452 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5453 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305454 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305455 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305456 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5457 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305458 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305459 j, bytes[0], bytes[1], bytes[2], bytes[3],
5460 bytes[4], bytes[5], bytes[6], bytes[7]);
5461
Govind Singhb53420c2016-03-09 14:32:57 +05305462 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305463 &req->networks[i].roaming_consortium_ids[j],
5464 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5465 }
Govind Singhb53420c2016-03-09 14:32:57 +05305466 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305467 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305468 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305469 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5470
5471 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5472 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5473 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305474 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305475 __func__);
5476 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305477 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305478 }
5479 }
5480
Govind Singhb53420c2016-03-09 14:32:57 +05305481 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305482}
5483
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305484/**
5485 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5486 * @wmi_handle: wmi handle
5487 * @scan_cmd_fp: start scan command ptr
5488 * @roam_req: roam request param
5489 *
5490 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5491 * of WMI_ROAM_SCAN_MODE.
5492 *
5493 * Return: QDF status
5494 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305495static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305496 wmi_start_scan_cmd_fixed_param *
5497 scan_cmd_fp,
5498 struct roam_offload_scan_params *roam_req)
5499{
5500 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305501 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305502 int len;
5503 uint8_t *buf_ptr;
5504 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305505
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305506#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5507 int auth_mode = roam_req->auth_mode;
5508 wmi_roam_offload_tlv_param *roam_offload_params;
5509 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5510 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5511 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305512 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305513#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5514 /* Need to create a buf with roam_scan command at
5515 * front and piggyback with scan command */
5516 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5517#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5518 (2 * WMI_TLV_HDR_SIZE) +
5519#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5520 sizeof(wmi_start_scan_cmd_fixed_param);
5521#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5522 if (roam_req->is_roam_req_valid &&
5523 roam_req->roam_offload_enabled) {
5524 len += sizeof(wmi_roam_offload_tlv_param);
5525 len += WMI_TLV_HDR_SIZE;
5526 if ((auth_mode != WMI_AUTH_NONE) &&
5527 ((auth_mode != WMI_AUTH_OPEN) ||
5528 (auth_mode == WMI_AUTH_OPEN &&
5529 roam_req->mdid.mdie_present) ||
5530 roam_req->is_ese_assoc)) {
5531 len += WMI_TLV_HDR_SIZE;
5532 if (roam_req->is_ese_assoc)
5533 len +=
5534 sizeof(wmi_roam_ese_offload_tlv_param);
5535 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5536 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5537 (auth_mode == WMI_AUTH_OPEN &&
5538 roam_req->mdid.mdie_present))
5539 len +=
5540 sizeof(wmi_roam_11r_offload_tlv_param);
5541 else
5542 len +=
5543 sizeof(wmi_roam_11i_offload_tlv_param);
5544 } else {
5545 len += WMI_TLV_HDR_SIZE;
5546 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305547
5548 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5549 + roundup(roam_req->assoc_ie_length,
5550 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305551 } else {
5552 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305553 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305554 __func__, roam_req->roam_offload_enabled);
5555 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305556 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305557 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305558 }
5559 if (roam_req->is_roam_req_valid &&
5560 roam_req->roam_offload_enabled) {
5561 roam_req->mode = roam_req->mode |
5562 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5563 }
5564#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5565
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305566 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5567 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5568 len = sizeof(wmi_roam_scan_mode_fixed_param);
5569
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305570 buf = wmi_buf_alloc(wmi_handle, len);
5571 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305572 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305573 return QDF_STATUS_E_NOMEM;
5574 }
5575
5576 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305577
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305578 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5579 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5580 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5581 WMITLV_GET_STRUCT_TLVLEN
5582 (wmi_roam_scan_mode_fixed_param));
5583
5584 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5585 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305586 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5587 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5588 roam_scan_mode_fp->flags |=
5589 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305590 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305591 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305592
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305593 /* Fill in scan parameters suitable for roaming scan */
5594 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305595
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305596 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5597 sizeof(wmi_start_scan_cmd_fixed_param));
5598 /* Ensure there is no additional IEs */
5599 scan_cmd_fp->ie_len = 0;
5600 WMITLV_SET_HDR(buf_ptr,
5601 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5602 WMITLV_GET_STRUCT_TLVLEN
5603 (wmi_start_scan_cmd_fixed_param));
5604#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5605 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5606 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5607 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5608 sizeof(wmi_roam_offload_tlv_param));
5609 buf_ptr += WMI_TLV_HDR_SIZE;
5610 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5611 WMITLV_SET_HDR(buf_ptr,
5612 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5613 WMITLV_GET_STRUCT_TLVLEN
5614 (wmi_roam_offload_tlv_param));
5615 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5616 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5617 roam_offload_params->select_5g_margin =
5618 roam_req->select_5ghz_margin;
5619 roam_offload_params->reassoc_failure_timeout =
5620 roam_req->reassoc_failure_timeout;
5621
5622 /* Fill the capabilities */
5623 roam_offload_params->capability =
5624 roam_req->roam_offload_params.capability;
5625 roam_offload_params->ht_caps_info =
5626 roam_req->roam_offload_params.ht_caps_info;
5627 roam_offload_params->ampdu_param =
5628 roam_req->roam_offload_params.ampdu_param;
5629 roam_offload_params->ht_ext_cap =
5630 roam_req->roam_offload_params.ht_ext_cap;
5631 roam_offload_params->ht_txbf =
5632 roam_req->roam_offload_params.ht_txbf;
5633 roam_offload_params->asel_cap =
5634 roam_req->roam_offload_params.asel_cap;
5635 roam_offload_params->qos_caps =
5636 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005637 roam_offload_params->qos_enabled =
5638 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305639 roam_offload_params->wmm_caps =
5640 roam_req->roam_offload_params.wmm_caps;
5641 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5642 (uint8_t *)roam_req->roam_offload_params.mcsset,
5643 ROAM_OFFLOAD_NUM_MCS_SET);
5644
5645 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5646 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5647 * they are filled in the same order.Depending on the
5648 * authentication type, the other mode TLV's are nullified
5649 * and only headers are filled.*/
5650 if ((auth_mode != WMI_AUTH_NONE) &&
5651 ((auth_mode != WMI_AUTH_OPEN) ||
5652 (auth_mode == WMI_AUTH_OPEN
5653 && roam_req->mdid.mdie_present) ||
5654 roam_req->is_ese_assoc)) {
5655 if (roam_req->is_ese_assoc) {
5656 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5657 WMITLV_GET_STRUCT_TLVLEN(0));
5658 buf_ptr += WMI_TLV_HDR_SIZE;
5659 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5660 WMITLV_GET_STRUCT_TLVLEN(0));
5661 buf_ptr += WMI_TLV_HDR_SIZE;
5662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5663 sizeof(wmi_roam_ese_offload_tlv_param));
5664 buf_ptr += WMI_TLV_HDR_SIZE;
5665 roam_offload_ese =
5666 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5667 qdf_mem_copy(roam_offload_ese->krk,
5668 roam_req->krk,
5669 sizeof(roam_req->krk));
5670 qdf_mem_copy(roam_offload_ese->btk,
5671 roam_req->btk,
5672 sizeof(roam_req->btk));
5673 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5674 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5675 WMITLV_GET_STRUCT_TLVLEN
5676 (wmi_roam_ese_offload_tlv_param));
5677 buf_ptr +=
5678 sizeof(wmi_roam_ese_offload_tlv_param);
5679 } else if (auth_mode == WMI_AUTH_FT_RSNA
5680 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5681 || (auth_mode == WMI_AUTH_OPEN
5682 && roam_req->mdid.mdie_present)) {
5683 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5684 0);
5685 buf_ptr += WMI_TLV_HDR_SIZE;
5686 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5687 sizeof(wmi_roam_11r_offload_tlv_param));
5688 buf_ptr += WMI_TLV_HDR_SIZE;
5689 roam_offload_11r =
5690 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5691 roam_offload_11r->r0kh_id_len =
5692 roam_req->rokh_id_length;
5693 qdf_mem_copy(roam_offload_11r->r0kh_id,
5694 roam_req->rokh_id,
5695 roam_offload_11r->r0kh_id_len);
5696 qdf_mem_copy(roam_offload_11r->psk_msk,
5697 roam_req->psk_pmk,
5698 sizeof(roam_req->psk_pmk));
5699 roam_offload_11r->psk_msk_len =
5700 roam_req->pmk_len;
5701 roam_offload_11r->mdie_present =
5702 roam_req->mdid.mdie_present;
5703 roam_offload_11r->mdid =
5704 roam_req->mdid.mobility_domain;
5705 if (auth_mode == WMI_AUTH_OPEN) {
5706 /* If FT-Open ensure pmk length
5707 and r0khid len are zero */
5708 roam_offload_11r->r0kh_id_len = 0;
5709 roam_offload_11r->psk_msk_len = 0;
5710 }
5711 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5712 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5713 WMITLV_GET_STRUCT_TLVLEN
5714 (wmi_roam_11r_offload_tlv_param));
5715 buf_ptr +=
5716 sizeof(wmi_roam_11r_offload_tlv_param);
5717 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5718 WMITLV_GET_STRUCT_TLVLEN(0));
5719 buf_ptr += WMI_TLV_HDR_SIZE;
5720 } else {
5721 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5722 sizeof(wmi_roam_11i_offload_tlv_param));
5723 buf_ptr += WMI_TLV_HDR_SIZE;
5724 roam_offload_11i =
5725 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005726
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005727 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005728 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305729 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5730 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005731 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305732 } else {
5733 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5734 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005735 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005736 }
5737 if (roam_req->roam_key_mgmt_offload_enabled &&
5738 roam_req->fw_pmksa_cache) {
5739 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5740 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005741 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005742 } else {
5743 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5744 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005745 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305746 }
5747
5748 qdf_mem_copy(roam_offload_11i->pmk,
5749 roam_req->psk_pmk,
5750 sizeof(roam_req->psk_pmk));
5751 roam_offload_11i->pmk_len = roam_req->pmk_len;
5752 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5753 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5754 WMITLV_GET_STRUCT_TLVLEN
5755 (wmi_roam_11i_offload_tlv_param));
5756 buf_ptr +=
5757 sizeof(wmi_roam_11i_offload_tlv_param);
5758 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5759 0);
5760 buf_ptr += WMI_TLV_HDR_SIZE;
5761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5762 0);
5763 buf_ptr += WMI_TLV_HDR_SIZE;
5764 }
5765 } else {
5766 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5767 WMITLV_GET_STRUCT_TLVLEN(0));
5768 buf_ptr += WMI_TLV_HDR_SIZE;
5769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5770 WMITLV_GET_STRUCT_TLVLEN(0));
5771 buf_ptr += WMI_TLV_HDR_SIZE;
5772 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5773 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305774 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305775 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305776
5777 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5778 sizeof(*assoc_ies));
5779 buf_ptr += WMI_TLV_HDR_SIZE;
5780
5781 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5782 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5783 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5784 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5785 assoc_ies->buf_len = roam_req->assoc_ie_length;
5786
5787 buf_ptr += sizeof(*assoc_ies);
5788
5789 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5790 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5791 buf_ptr += WMI_TLV_HDR_SIZE;
5792
5793 if (assoc_ies->buf_len != 0) {
5794 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5795 assoc_ies->buf_len);
5796 }
5797
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305798 } else {
5799 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5800 WMITLV_GET_STRUCT_TLVLEN(0));
5801 buf_ptr += WMI_TLV_HDR_SIZE;
5802 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5803 WMITLV_GET_STRUCT_TLVLEN(0));
5804 buf_ptr += WMI_TLV_HDR_SIZE;
5805 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5806 WMITLV_GET_STRUCT_TLVLEN(0));
5807 buf_ptr += WMI_TLV_HDR_SIZE;
5808 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5809 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305810 buf_ptr += WMI_TLV_HDR_SIZE;
5811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5812 WMITLV_GET_STRUCT_TLVLEN(0));
5813 buf_ptr += WMI_TLV_HDR_SIZE;
5814 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5815 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305816 }
5817#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305818
5819send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305820 status = wmi_unified_cmd_send(wmi_handle, buf,
5821 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305822 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305823 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305824 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5825 status);
5826 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305827 }
5828
Govind Singh67922e82016-04-01 16:48:57 +05305829 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305830}
5831
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07005832static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
5833 struct wmi_mawc_roam_params *params)
5834{
5835 wmi_buf_t buf = NULL;
5836 QDF_STATUS status;
5837 int len;
5838 uint8_t *buf_ptr;
5839 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
5840
5841 len = sizeof(*wmi_roam_mawc_params);
5842 buf = wmi_buf_alloc(wmi_handle, len);
5843 if (!buf) {
5844 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
5845 return QDF_STATUS_E_NOMEM;
5846 }
5847
5848 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5849 wmi_roam_mawc_params =
5850 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
5851 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
5852 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
5853 WMITLV_GET_STRUCT_TLVLEN
5854 (wmi_roam_configure_mawc_cmd_fixed_param));
5855 wmi_roam_mawc_params->vdev_id = params->vdev_id;
5856 if (params->enable)
5857 wmi_roam_mawc_params->enable = 1;
5858 else
5859 wmi_roam_mawc_params->enable = 0;
5860 wmi_roam_mawc_params->traffic_load_threshold =
5861 params->traffic_load_threshold;
5862 wmi_roam_mawc_params->best_ap_rssi_threshold =
5863 params->best_ap_rssi_threshold;
5864 wmi_roam_mawc_params->rssi_stationary_high_adjust =
5865 params->rssi_stationary_high_adjust;
5866 wmi_roam_mawc_params->rssi_stationary_low_adjust =
5867 params->rssi_stationary_low_adjust;
5868
5869 status = wmi_unified_cmd_send(wmi_handle, buf,
5870 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
5871 if (QDF_IS_STATUS_ERROR(status)) {
5872 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
5873 status);
5874 wmi_buf_free(buf);
5875 return status;
5876 }
5877 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
5878 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
5879 wmi_roam_mawc_params->traffic_load_threshold,
5880 wmi_roam_mawc_params->best_ap_rssi_threshold,
5881 wmi_roam_mawc_params->rssi_stationary_high_adjust,
5882 wmi_roam_mawc_params->rssi_stationary_low_adjust);
5883
5884 return QDF_STATUS_SUCCESS;
5885}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305886
5887/**
5888 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5889 * rssi threashold
5890 * @wmi_handle: wmi handle
5891 * @roam_req: Roaming request buffer
5892 *
5893 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5894 *
5895 * Return: QDF status
5896 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305897static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305898 struct roam_offload_scan_rssi_params *roam_req)
5899{
5900 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305901 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305902 int len;
5903 uint8_t *buf_ptr;
5904 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5905 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5906 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305907 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305908
5909 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5910 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5911 len += sizeof(wmi_roam_scan_extended_threshold_param);
5912 len += WMI_TLV_HDR_SIZE;
5913 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305914 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5915 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305916 buf = wmi_buf_alloc(wmi_handle, len);
5917 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305918 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305919 return QDF_STATUS_E_NOMEM;
5920 }
5921
5922 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5923 rssi_threshold_fp =
5924 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5925 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5926 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5927 WMITLV_GET_STRUCT_TLVLEN
5928 (wmi_roam_scan_rssi_threshold_fixed_param));
5929 /* fill in threshold values */
5930 rssi_threshold_fp->vdev_id = roam_req->session_id;
5931 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5932 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5933 rssi_threshold_fp->hirssi_scan_max_count =
5934 roam_req->hi_rssi_scan_max_count;
5935 rssi_threshold_fp->hirssi_scan_delta =
5936 roam_req->hi_rssi_scan_rssi_delta;
5937 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07005938 rssi_threshold_fp->rssi_thresh_offset_5g =
5939 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305940
5941 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5942 WMITLV_SET_HDR(buf_ptr,
5943 WMITLV_TAG_ARRAY_STRUC,
5944 sizeof(wmi_roam_scan_extended_threshold_param));
5945 buf_ptr += WMI_TLV_HDR_SIZE;
5946 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5947
5948 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5949 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5950 ext_thresholds->boost_threshold_5g =
5951 roam_req->boost_threshold_5g;
5952
5953 ext_thresholds->boost_algorithm_5g =
5954 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5955 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5956 ext_thresholds->penalty_algorithm_5g =
5957 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5958 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5959 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5960 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5961 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5962
5963 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5964 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5965 WMITLV_GET_STRUCT_TLVLEN
5966 (wmi_roam_scan_extended_threshold_param));
5967 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5968 WMITLV_SET_HDR(buf_ptr,
5969 WMITLV_TAG_ARRAY_STRUC,
5970 sizeof(wmi_roam_earlystop_rssi_thres_param));
5971 buf_ptr += WMI_TLV_HDR_SIZE;
5972 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5973 early_stop_thresholds->roam_earlystop_thres_min =
5974 roam_req->roam_earlystop_thres_min;
5975 early_stop_thresholds->roam_earlystop_thres_max =
5976 roam_req->roam_earlystop_thres_max;
5977 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5978 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5979 WMITLV_GET_STRUCT_TLVLEN
5980 (wmi_roam_earlystop_rssi_thres_param));
5981
Gupta, Kapil7e652922016-04-12 15:02:00 +05305982 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5983 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5984 sizeof(wmi_roam_dense_thres_param));
5985 buf_ptr += WMI_TLV_HDR_SIZE;
5986 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5987 dense_thresholds->roam_dense_rssi_thres_offset =
5988 roam_req->dense_rssi_thresh_offset;
5989 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5990 dense_thresholds->roam_dense_traffic_thres =
5991 roam_req->traffic_threshold;
5992 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5993 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5994 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5995 WMITLV_GET_STRUCT_TLVLEN
5996 (wmi_roam_dense_thres_param));
5997
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305998 status = wmi_unified_cmd_send(wmi_handle, buf,
5999 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306000 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306001 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306002 status);
6003 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306004 }
6005
Govind Singh67922e82016-04-01 16:48:57 +05306006 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306007}
6008
6009/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306010 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6011 * configuration params
6012 * @wma_handle: wma handler
6013 * @dwelltime_params: pointer to dwelltime_params
6014 *
6015 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6016 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006017static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306018QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6019 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6020{
6021 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6022 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6023 wmi_buf_t buf;
6024 uint8_t *buf_ptr;
6025 int32_t err;
6026 int len;
6027
6028 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6029 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6030 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6031 buf = wmi_buf_alloc(wmi_handle, len);
6032 if (!buf) {
6033 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6034 __func__);
6035 return QDF_STATUS_E_NOMEM;
6036 }
6037 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6038 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6039 WMITLV_SET_HDR(&dwell_param->tlv_header,
6040 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6041 WMITLV_GET_STRUCT_TLVLEN
6042 (wmi_scan_adaptive_dwell_config_fixed_param));
6043
6044 dwell_param->enable = dwelltime_params->is_enabled;
6045 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6046 WMITLV_SET_HDR(buf_ptr,
6047 WMITLV_TAG_ARRAY_STRUC,
6048 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6049 buf_ptr += WMI_TLV_HDR_SIZE;
6050
6051 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6052 WMITLV_SET_HDR(&cmd->tlv_header,
6053 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6054 WMITLV_GET_STRUCT_TLVLEN(
6055 wmi_scan_adaptive_dwell_parameters_tlv));
6056
6057 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6058 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6059 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6060 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6061 err = wmi_unified_cmd_send(wmi_handle, buf,
6062 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6063 if (err) {
6064 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6065 wmi_buf_free(buf);
6066 return QDF_STATUS_E_FAILURE;
6067 }
6068
6069 return QDF_STATUS_SUCCESS;
6070}
6071
Nitesh Shah52323d02017-05-22 15:49:00 +05306072/**
6073 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6074 * configuration params
6075 * @wmi_handle: wmi handler
6076 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6077 *
6078 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6079 */
6080static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6081 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6082{
6083 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6084 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6085 wmi_buf_t buf;
6086 uint8_t *buf_ptr;
6087 QDF_STATUS err;
6088 uint32_t i;
6089 int len;
6090
6091 len = sizeof(*dbs_scan_param);
6092 len += WMI_TLV_HDR_SIZE;
6093 len += dbs_scan_params->num_clients * sizeof(*cmd);
6094
6095 buf = wmi_buf_alloc(wmi_handle, len);
6096 if (!buf) {
6097 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6098 return QDF_STATUS_E_NOMEM;
6099 }
6100
6101 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6102 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6103 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6104 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6105 WMITLV_GET_STRUCT_TLVLEN
6106 (wmi_scan_dbs_duty_cycle_fixed_param));
6107
6108 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6109 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6110 buf_ptr += sizeof(*dbs_scan_param);
6111 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6112 (sizeof(*cmd) * dbs_scan_params->num_clients));
6113 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6114
6115 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6116 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6117 WMITLV_SET_HDR(&cmd->tlv_header,
6118 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6119 WMITLV_GET_STRUCT_TLVLEN(
6120 wmi_scan_dbs_duty_cycle_tlv_param));
6121 cmd->module_id = dbs_scan_params->module_id[i];
6122 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6123 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6124 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6125 }
6126
6127 err = wmi_unified_cmd_send(wmi_handle, buf,
6128 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6129 if (QDF_IS_STATUS_ERROR(err)) {
6130 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6131 wmi_buf_free(buf);
6132 return QDF_STATUS_E_FAILURE;
6133 }
6134
6135 return QDF_STATUS_SUCCESS;
6136}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306137
6138/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306139 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6140 * @wmi_handle: wmi handle
6141 * @roam_req: Request which contains the filters
6142 *
6143 * There are filters such as whitelist, blacklist and preferred
6144 * list that need to be applied to the scan results to form the
6145 * probable candidates for roaming.
6146 *
6147 * Return: Return success upon succesfully passing the
6148 * parameters to the firmware, otherwise failure.
6149 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306150static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306151 struct roam_scan_filter_params *roam_req)
6152{
6153 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306154 QDF_STATUS status;
6155 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306156 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306157 uint8_t *buf_ptr;
6158 wmi_roam_filter_fixed_param *roam_filter;
6159 uint8_t *bssid_src_ptr = NULL;
6160 wmi_mac_addr *bssid_dst_ptr = NULL;
6161 wmi_ssid *ssid_ptr = NULL;
6162 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306163 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306164 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306165
6166 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306167
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306168 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306169 if (roam_req->num_bssid_black_list)
6170 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6171 len += WMI_TLV_HDR_SIZE;
6172 if (roam_req->num_ssid_white_list)
6173 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6174 len += 2 * WMI_TLV_HDR_SIZE;
6175 if (roam_req->num_bssid_preferred_list) {
6176 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6177 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6178 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306179 len += WMI_TLV_HDR_SIZE;
6180 if (roam_req->lca_disallow_config_present) {
6181 len += sizeof(*blist_param);
6182 blist_len = sizeof(*blist_param);
6183 }
6184
6185 len += WMI_TLV_HDR_SIZE;
6186 if (roam_req->num_rssi_rejection_ap)
6187 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306188
6189 buf = wmi_buf_alloc(wmi_handle, len);
6190 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306191 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306192 return QDF_STATUS_E_NOMEM;
6193 }
6194
6195 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6196 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6197 WMITLV_SET_HDR(&roam_filter->tlv_header,
6198 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6199 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6200 /* fill in fixed values */
6201 roam_filter->vdev_id = roam_req->session_id;
6202 roam_filter->flags = 0;
6203 roam_filter->op_bitmap = roam_req->op_bitmap;
6204 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6205 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6206 roam_filter->num_bssid_preferred_list =
6207 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306208 roam_filter->num_rssi_rejection_ap =
6209 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306210 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6211
6212 WMITLV_SET_HDR((buf_ptr),
6213 WMITLV_TAG_ARRAY_FIXED_STRUC,
6214 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6215 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6216 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6217 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6218 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6219 bssid_src_ptr += ATH_MAC_LEN;
6220 bssid_dst_ptr++;
6221 }
6222 buf_ptr += WMI_TLV_HDR_SIZE +
6223 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6224 WMITLV_SET_HDR((buf_ptr),
6225 WMITLV_TAG_ARRAY_FIXED_STRUC,
6226 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6227 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6228 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6229 qdf_mem_copy(&ssid_ptr->ssid,
6230 &roam_req->ssid_allowed_list[i].mac_ssid,
6231 roam_req->ssid_allowed_list[i].length);
6232 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6233 ssid_ptr++;
6234 }
6235 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6236 sizeof(wmi_ssid));
6237 WMITLV_SET_HDR((buf_ptr),
6238 WMITLV_TAG_ARRAY_FIXED_STRUC,
6239 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6240 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6241 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6242 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6243 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6244 (wmi_mac_addr *)bssid_dst_ptr);
6245 bssid_src_ptr += ATH_MAC_LEN;
6246 bssid_dst_ptr++;
6247 }
6248 buf_ptr += WMI_TLV_HDR_SIZE +
6249 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6250 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6251 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6252 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6253 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6254 *bssid_preferred_factor_ptr =
6255 roam_req->bssid_favored_factor[i];
6256 bssid_preferred_factor_ptr++;
6257 }
6258 buf_ptr += WMI_TLV_HDR_SIZE +
6259 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6260
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306261 WMITLV_SET_HDR(buf_ptr,
6262 WMITLV_TAG_ARRAY_STRUC, blist_len);
6263 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306264 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306265 blist_param =
6266 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6267 WMITLV_SET_HDR(&blist_param->tlv_header,
6268 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6269 WMITLV_GET_STRUCT_TLVLEN(
6270 wmi_roam_lca_disallow_config_tlv_param));
6271
6272 blist_param->disallow_duration = roam_req->disallow_duration;
6273 blist_param->rssi_channel_penalization =
6274 roam_req->rssi_channel_penalization;
6275 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
6276 blist_param->disallow_lca_enable_source_bitmap = 0x1;
6277 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6278 }
6279
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306280 WMITLV_SET_HDR(buf_ptr,
6281 WMITLV_TAG_ARRAY_STRUC,
6282 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6283 buf_ptr += WMI_TLV_HDR_SIZE;
6284 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6285 rssi_rej =
6286 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6287 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6288 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6289 WMITLV_GET_STRUCT_TLVLEN(
6290 wmi_roam_rssi_rejection_oce_config_param));
6291 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6292 roam_req->rssi_rejection_ap[i].bssid.bytes,
6293 &rssi_rej->bssid);
6294 rssi_rej->remaining_disallow_duration =
6295 roam_req->rssi_rejection_ap[i].remaining_duration;
6296 rssi_rej->requested_rssi =
6297 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6298 buf_ptr +=
6299 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6300 }
6301
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306302 status = wmi_unified_cmd_send(wmi_handle, buf,
6303 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306304 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306305 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306306 status);
6307 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306308 }
Govind Singh67922e82016-04-01 16:48:57 +05306309
6310 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306311}
6312
Govind Singh4eacd2b2016-03-07 14:24:22 +05306313/** send_set_epno_network_list_cmd_tlv() - set epno network list
6314 * @wmi_handle: wmi handle
6315 * @req: epno config params request structure
6316 *
6317 * This function reads the incoming epno config request structure
6318 * and constructs the WMI message to the firmware.
6319 *
6320 * Returns: 0 on success, error number otherwise
6321 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306322static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306323 struct wifi_enhanched_pno_params *req)
6324{
6325 wmi_nlo_config_cmd_fixed_param *cmd;
6326 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306327 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306328 u_int8_t i, *buf_ptr;
6329 wmi_buf_t buf;
6330 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306331 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306332
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306333 /* Fixed Params */
6334 len = sizeof(*cmd);
6335 if (req->num_networks) {
6336 /* TLV place holder for array of structures
6337 * then each nlo_configured_parameters(nlo_list) TLV.
6338 */
6339 len += WMI_TLV_HDR_SIZE;
6340 len += (sizeof(nlo_configured_parameters)
6341 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6342 /* TLV for array of uint32 channel_list */
6343 len += WMI_TLV_HDR_SIZE;
6344 /* TLV for nlo_channel_prediction_cfg */
6345 len += WMI_TLV_HDR_SIZE;
6346 /* TLV for candidate score params */
6347 len += sizeof(enlo_candidate_score_params);
6348 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306349
6350 buf = wmi_buf_alloc(wmi_handle, len);
6351 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306352 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6353 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306354 }
6355
6356 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6357
6358 buf_ptr = (u_int8_t *) cmd;
6359 WMITLV_SET_HDR(&cmd->tlv_header,
6360 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6361 WMITLV_GET_STRUCT_TLVLEN(
6362 wmi_nlo_config_cmd_fixed_param));
6363 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306364
6365 /* set flag to reset if num of networks are 0 */
6366 cmd->flags = (req->num_networks == 0 ?
6367 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306368
6369 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6370
Govind Singhb53420c2016-03-09 14:32:57 +05306371 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306372 WMI_LOGD("SSID count: %d flags: %d",
6373 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306374
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306375 /* Fill nlo_config only when num_networks are non zero */
6376 if (cmd->no_of_ssids) {
6377 /* Fill networks */
6378 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6379 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6380 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306381
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306382 nlo_list = (nlo_configured_parameters *) buf_ptr;
6383 for (i = 0; i < cmd->no_of_ssids; i++) {
6384 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6385 WMITLV_TAG_ARRAY_BYTE,
6386 WMITLV_GET_STRUCT_TLVLEN(
6387 nlo_configured_parameters));
6388 /* Copy ssid and it's length */
6389 nlo_list[i].ssid.valid = true;
6390 nlo_list[i].ssid.ssid.ssid_len =
6391 req->networks[i].ssid.length;
6392 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6393 req->networks[i].ssid.mac_ssid,
6394 nlo_list[i].ssid.ssid.ssid_len);
6395 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6396 nlo_list[i].ssid.ssid.ssid_len,
6397 (char *) nlo_list[i].ssid.ssid.ssid,
6398 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306399
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306400 /* Copy pno flags */
6401 nlo_list[i].bcast_nw_type.valid = true;
6402 nlo_list[i].bcast_nw_type.bcast_nw_type =
6403 req->networks[i].flags;
6404 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306405 nlo_list[i].bcast_nw_type.bcast_nw_type);
6406
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306407 /* Copy auth bit field */
6408 nlo_list[i].auth_type.valid = true;
6409 nlo_list[i].auth_type.auth_type =
6410 req->networks[i].auth_bit_field;
6411 WMI_LOGD("Auth bit field (%u)",
6412 nlo_list[i].auth_type.auth_type);
6413 }
6414
6415 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6416 /* Fill the channel list */
6417 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6418 buf_ptr += WMI_TLV_HDR_SIZE;
6419
6420 /* Fill prediction_param */
6421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6422 buf_ptr += WMI_TLV_HDR_SIZE;
6423
6424 /* Fill epno candidate score params */
6425 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6426 WMITLV_SET_HDR(buf_ptr,
6427 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6428 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6429 cand_score_params->min5GHz_rssi =
6430 req->min_5ghz_rssi;
6431 cand_score_params->min24GHz_rssi =
6432 req->min_24ghz_rssi;
6433 cand_score_params->initial_score_max =
6434 req->initial_score_max;
6435 cand_score_params->current_connection_bonus =
6436 req->current_connection_bonus;
6437 cand_score_params->same_network_bonus =
6438 req->same_network_bonus;
6439 cand_score_params->secure_bonus =
6440 req->secure_bonus;
6441 cand_score_params->band5GHz_bonus =
6442 req->band_5ghz_bonus;
6443 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 }
6445
Govind Singh4eacd2b2016-03-07 14:24:22 +05306446 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306447 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306448 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306449 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306450 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306451 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306452 }
6453
Govind Singhb53420c2016-03-09 14:32:57 +05306454 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 req->session_id);
6456
Govind Singh67922e82016-04-01 16:48:57 +05306457 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458}
6459
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306460
Govind Singh4eacd2b2016-03-07 14:24:22 +05306461/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6462 * @wmi_handle: wmi handle
6463 * @ipa_offload: ipa offload control parameter
6464 *
6465 * Returns: 0 on success, error number otherwise
6466 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306467static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306468 struct ipa_offload_control_params *ipa_offload)
6469{
6470 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6471 wmi_buf_t wmi_buf;
6472 uint32_t len;
6473 u_int8_t *buf_ptr;
6474
6475 len = sizeof(*cmd);
6476 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6477 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306478 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6479 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306480 }
6481
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08006482 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483 ipa_offload->offload_type, ipa_offload->enable);
6484
6485 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6486
6487 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6488 WMITLV_SET_HDR(&cmd->tlv_header,
6489 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6490 WMITLV_GET_STRUCT_TLVLEN(
6491 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6492
6493 cmd->offload_type = ipa_offload->offload_type;
6494 cmd->vdev_id = ipa_offload->vdev_id;
6495 cmd->enable = ipa_offload->enable;
6496
6497 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6498 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306499 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306500 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306501 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306502 }
6503
Govind Singhb53420c2016-03-09 14:32:57 +05306504 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306505}
6506
6507/**
6508 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6509 * @wmi_handle: wmi handle
6510 * @pgetcapab: get capabilities params
6511 *
6512 * This function send request to fw to get extscan capabilities.
6513 *
6514 * Return: CDF status
6515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306516static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306517 struct extscan_capabilities_params *pgetcapab)
6518{
6519 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6520 wmi_buf_t wmi_buf;
6521 uint32_t len;
6522 uint8_t *buf_ptr;
6523
6524 len = sizeof(*cmd);
6525 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6526 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306527 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6528 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306529 }
6530 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6531
6532 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6533 WMITLV_SET_HDR(&cmd->tlv_header,
6534 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6535 WMITLV_GET_STRUCT_TLVLEN
6536 (wmi_extscan_get_capabilities_cmd_fixed_param));
6537
6538 cmd->request_id = pgetcapab->request_id;
6539
6540 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6541 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306542 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306543 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306544 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306545 }
Govind Singhb53420c2016-03-09 14:32:57 +05306546 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306547}
6548
6549/**
6550 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6551 * @wmi_handle: wmi handle
6552 * @pcached_results: cached results parameters
6553 *
6554 * This function send request to fw to get cached results.
6555 *
6556 * Return: CDF status
6557 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306558static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306559 struct extscan_cached_result_params *pcached_results)
6560{
6561 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6562 wmi_buf_t wmi_buf;
6563 uint32_t len;
6564 uint8_t *buf_ptr;
6565
6566 len = sizeof(*cmd);
6567 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6568 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306569 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6570 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306571 }
6572 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6573
6574 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6575 WMITLV_SET_HDR(&cmd->tlv_header,
6576 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6577 WMITLV_GET_STRUCT_TLVLEN
6578 (wmi_extscan_get_cached_results_cmd_fixed_param));
6579
6580 cmd->request_id = pcached_results->request_id;
6581 cmd->vdev_id = pcached_results->session_id;
6582 cmd->control_flags = pcached_results->flush;
6583
6584 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6585 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306586 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306587 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306588 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306589 }
Govind Singhb53420c2016-03-09 14:32:57 +05306590 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306591}
6592
6593/**
6594 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6595 * @wmi_handle: wmi handle
6596 * @reset_req: Reset change request params
6597 *
6598 * This function sends stop change monitor request to fw.
6599 *
6600 * Return: CDF status
6601 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306602static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306603 struct extscan_capabilities_reset_params *reset_req)
6604{
6605 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6606 wmi_buf_t wmi_buf;
6607 uint32_t len;
6608 uint8_t *buf_ptr;
6609 int change_list = 0;
6610
6611 len = sizeof(*cmd);
6612
6613 /* reset significant change tlv is set to 0 */
6614 len += WMI_TLV_HDR_SIZE;
6615 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6616 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6617 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306618 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6619 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306620 }
6621 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6622
6623 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6624 buf_ptr;
6625 WMITLV_SET_HDR(&cmd->tlv_header,
6626 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6627 WMITLV_GET_STRUCT_TLVLEN
6628 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6629
6630 cmd->request_id = reset_req->request_id;
6631 cmd->vdev_id = reset_req->session_id;
6632 cmd->mode = 0;
6633
6634 buf_ptr += sizeof(*cmd);
6635 WMITLV_SET_HDR(buf_ptr,
6636 WMITLV_TAG_ARRAY_STRUC,
6637 change_list *
6638 sizeof(wmi_extscan_wlan_change_bssid_param));
6639 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6640 sizeof
6641 (wmi_extscan_wlan_change_bssid_param));
6642
6643 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6644 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306645 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306646 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306647 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306648 }
Govind Singhb53420c2016-03-09 14:32:57 +05306649 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306650}
6651
6652/**
6653 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6654 * @wmi_handle: wmi handle
6655 * @psigchange: change monitor request params
6656 * @buf: wmi buffer
6657 * @buf_len: buffer length
6658 *
6659 * This function fills elements of change monitor request buffer.
6660 *
6661 * Return: CDF status
6662 */
Govind Singhb53420c2016-03-09 14:32:57 +05306663static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306664 struct extscan_set_sig_changereq_params
6665 *psigchange, wmi_buf_t *buf, int *buf_len)
6666{
6667 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6668 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6669 uint8_t *buf_ptr;
6670 int j;
6671 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006672 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306673 struct ap_threshold_params *src_ap = psigchange->ap;
6674
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006675 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306676 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6677 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306678 }
6679 len += WMI_TLV_HDR_SIZE;
6680 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6681
6682 *buf = wmi_buf_alloc(wmi_handle, len);
6683 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306684 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306685 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306686 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306687 }
6688 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6689 cmd =
6690 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6691 buf_ptr;
6692 WMITLV_SET_HDR(&cmd->tlv_header,
6693 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6694 WMITLV_GET_STRUCT_TLVLEN
6695 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6696
6697 cmd->request_id = psigchange->request_id;
6698 cmd->vdev_id = psigchange->session_id;
6699 cmd->total_entries = numap;
6700 cmd->mode = 1;
6701 cmd->num_entries_in_page = numap;
6702 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6703 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6704 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6705 cmd->max_out_of_range_count = psigchange->min_breaching;
6706
6707 buf_ptr += sizeof(*cmd);
6708 WMITLV_SET_HDR(buf_ptr,
6709 WMITLV_TAG_ARRAY_STRUC,
6710 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6711 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6712 (buf_ptr + WMI_TLV_HDR_SIZE);
6713
6714 for (j = 0; j < numap; j++) {
6715 WMITLV_SET_HDR(dest_chglist,
6716 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6717 WMITLV_GET_STRUCT_TLVLEN
6718 (wmi_extscan_wlan_change_bssid_param));
6719
6720 dest_chglist->lower_rssi_limit = src_ap->low;
6721 dest_chglist->upper_rssi_limit = src_ap->high;
6722 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6723 &dest_chglist->bssid);
6724
Govind Singhb53420c2016-03-09 14:32:57 +05306725 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306726 dest_chglist->lower_rssi_limit);
6727 dest_chglist++;
6728 src_ap++;
6729 }
6730 buf_ptr += WMI_TLV_HDR_SIZE +
6731 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6732 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306733 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306734}
6735
6736/**
6737 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6738 * @wmi_handle: wmi handle
6739 * @psigchange: change monitor request params
6740 *
6741 * This function sends start change monitor request to fw.
6742 *
6743 * Return: CDF status
6744 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306745static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306746 struct extscan_set_sig_changereq_params *
6747 psigchange)
6748{
Govind Singhb53420c2016-03-09 14:32:57 +05306749 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306750 wmi_buf_t buf;
6751 int len;
6752
6753
Govind Singhb53420c2016-03-09 14:32:57 +05306754 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306755 psigchange, &buf,
6756 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306757 if (qdf_status != QDF_STATUS_SUCCESS) {
6758 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306759 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306760 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306761 }
6762 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306763 WMI_LOGE("%s: Failed to get buffer", __func__);
6764 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306765 }
6766 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6767 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306768 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306769 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306770 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306771 }
Govind Singhb53420c2016-03-09 14:32:57 +05306772 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306773}
6774
6775/**
6776 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6777 * @wmi_handle: wmi handle
6778 * @photlist_reset: hotlist reset params
6779 *
6780 * This function configures hotlist monitor to stop in fw.
6781 *
6782 * Return: CDF status
6783 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306784static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306785 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6786{
6787 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6788 wmi_buf_t wmi_buf;
6789 uint32_t len;
6790 uint8_t *buf_ptr;
6791 int hotlist_entries = 0;
6792
6793 len = sizeof(*cmd);
6794
6795 /* reset bssid hotlist with tlv set to 0 */
6796 len += WMI_TLV_HDR_SIZE;
6797 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6798
6799 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6800 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306801 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6802 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306803 }
6804
6805 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6806 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6807 buf_ptr;
6808 WMITLV_SET_HDR(&cmd->tlv_header,
6809 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6810 WMITLV_GET_STRUCT_TLVLEN
6811 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6812
6813 cmd->request_id = photlist_reset->request_id;
6814 cmd->vdev_id = photlist_reset->session_id;
6815 cmd->mode = 0;
6816
6817 buf_ptr += sizeof(*cmd);
6818 WMITLV_SET_HDR(buf_ptr,
6819 WMITLV_TAG_ARRAY_STRUC,
6820 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6821 buf_ptr += WMI_TLV_HDR_SIZE +
6822 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6823
6824 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6825 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306826 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306827 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306828 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306829 }
Govind Singhb53420c2016-03-09 14:32:57 +05306830 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306831}
6832
6833/**
6834 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6835 * @wmi_handle: wmi handle
6836 * @pstopcmd: stop scan command request params
6837 *
6838 * This function sends stop extscan request to fw.
6839 *
6840 * Return: CDF Status.
6841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306842static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306843 struct extscan_stop_req_params *pstopcmd)
6844{
6845 wmi_extscan_stop_cmd_fixed_param *cmd;
6846 wmi_buf_t wmi_buf;
6847 uint32_t len;
6848 uint8_t *buf_ptr;
6849
6850 len = sizeof(*cmd);
6851 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6852 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306853 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6854 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306855 }
6856 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6857 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6858 WMITLV_SET_HDR(&cmd->tlv_header,
6859 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6860 WMITLV_GET_STRUCT_TLVLEN
6861 (wmi_extscan_stop_cmd_fixed_param));
6862
6863 cmd->request_id = pstopcmd->request_id;
6864 cmd->vdev_id = pstopcmd->session_id;
6865
6866 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6867 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306868 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306869 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306870 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306871 }
6872
Govind Singhb53420c2016-03-09 14:32:57 +05306873 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306874}
6875
6876/**
6877 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6878 * @wmi_handle: wmi handle
6879 * @pstart: scan command request params
6880 * @buf: event buffer
6881 * @buf_len: length of buffer
6882 *
6883 * This function fills individual elements of extscan request and
6884 * TLV for buckets, channel list.
6885 *
6886 * Return: CDF Status.
6887 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006888static
Govind Singhb53420c2016-03-09 14:32:57 +05306889QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306890 struct wifi_scan_cmd_req_params *pstart,
6891 wmi_buf_t *buf, int *buf_len)
6892{
6893 wmi_extscan_start_cmd_fixed_param *cmd;
6894 wmi_extscan_bucket *dest_blist;
6895 wmi_extscan_bucket_channel *dest_clist;
6896 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6897 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6898 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6899
6900 uint8_t *buf_ptr;
6901 int i, k, count = 0;
6902 int len = sizeof(*cmd);
6903 int nbuckets = pstart->numBuckets;
6904 int nchannels = 0;
6905
6906 /* These TLV's are are NULL by default */
6907 uint32_t ie_len_with_pad = 0;
6908 int num_ssid = 0;
6909 int num_bssid = 0;
6910 int ie_len = 0;
6911
6912 uint32_t base_period = pstart->basePeriod;
6913
6914 /* TLV placeholder for ssid_list (NULL) */
6915 len += WMI_TLV_HDR_SIZE;
6916 len += num_ssid * sizeof(wmi_ssid);
6917
6918 /* TLV placeholder for bssid_list (NULL) */
6919 len += WMI_TLV_HDR_SIZE;
6920 len += num_bssid * sizeof(wmi_mac_addr);
6921
6922 /* TLV placeholder for ie_data (NULL) */
6923 len += WMI_TLV_HDR_SIZE;
6924 len += ie_len * sizeof(uint32_t);
6925
6926 /* TLV placeholder for bucket */
6927 len += WMI_TLV_HDR_SIZE;
6928 len += nbuckets * sizeof(wmi_extscan_bucket);
6929
6930 /* TLV channel placeholder */
6931 len += WMI_TLV_HDR_SIZE;
6932 for (i = 0; i < nbuckets; i++) {
6933 nchannels += src_bucket->numChannels;
6934 src_bucket++;
6935 }
6936
Govind Singhb53420c2016-03-09 14:32:57 +05306937 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306938 __func__, nbuckets, nchannels);
6939 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6940 /* Allocate the memory */
6941 *buf = wmi_buf_alloc(wmi_handle, len);
6942 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306943 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306944 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306945 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306946 }
6947 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6948 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6949 WMITLV_SET_HDR(&cmd->tlv_header,
6950 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6951 WMITLV_GET_STRUCT_TLVLEN
6952 (wmi_extscan_start_cmd_fixed_param));
6953
6954 cmd->request_id = pstart->requestId;
6955 cmd->vdev_id = pstart->sessionId;
6956 cmd->base_period = pstart->basePeriod;
6957 cmd->num_buckets = nbuckets;
6958 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306959 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306960 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306961 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306962 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306963#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306964 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6965 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306966 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6967 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6968#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306969 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6970
6971 /* The max dwell time is retrieved from the first channel
6972 * of the first bucket and kept common for all channels.
6973 */
6974 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6975 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6976 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6977 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6978 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6979 cmd->max_table_usage = pstart->report_threshold_percent;
6980 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6981
6982 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306983 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306984 cmd->probe_delay = 0;
6985 cmd->probe_spacing_time = 0;
6986 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306987 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6988 WMI_SCAN_ADD_CCK_RATES |
6989 WMI_SCAN_ADD_OFDM_RATES |
6990 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6991 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306992 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6993 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306994 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306995 cmd->num_ssids = 0;
6996 cmd->num_bssid = 0;
6997 cmd->ie_len = 0;
6998 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6999 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7000
7001 buf_ptr += sizeof(*cmd);
7002 WMITLV_SET_HDR(buf_ptr,
7003 WMITLV_TAG_ARRAY_FIXED_STRUC,
7004 num_ssid * sizeof(wmi_ssid));
7005 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7006
7007 WMITLV_SET_HDR(buf_ptr,
7008 WMITLV_TAG_ARRAY_FIXED_STRUC,
7009 num_bssid * sizeof(wmi_mac_addr));
7010 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7011
7012 ie_len_with_pad = 0;
7013 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7014 ie_len_with_pad);
7015 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7016
7017 WMITLV_SET_HDR(buf_ptr,
7018 WMITLV_TAG_ARRAY_STRUC,
7019 nbuckets * sizeof(wmi_extscan_bucket));
7020 dest_blist = (wmi_extscan_bucket *)
7021 (buf_ptr + WMI_TLV_HDR_SIZE);
7022 src_bucket = pstart->buckets;
7023
7024 /* Retrieve scanning information from each bucket and
7025 * channels and send it to the target
7026 */
7027 for (i = 0; i < nbuckets; i++) {
7028 WMITLV_SET_HDR(dest_blist,
7029 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7030 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7031
7032 dest_blist->bucket_id = src_bucket->bucket;
7033 dest_blist->base_period_multiplier =
7034 src_bucket->period / base_period;
7035 dest_blist->min_period = src_bucket->period;
7036 dest_blist->max_period = src_bucket->max_period;
7037 dest_blist->exp_backoff = src_bucket->exponent;
7038 dest_blist->exp_max_step_count = src_bucket->step_count;
7039 dest_blist->channel_band = src_bucket->band;
7040 dest_blist->num_channels = src_bucket->numChannels;
7041 dest_blist->notify_extscan_events = 0;
7042
7043 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7044 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007045 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7046 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307047
7048 if (src_bucket->reportEvents &
7049 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7050 dest_blist->forwarding_flags =
7051 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7052 dest_blist->notify_extscan_events |=
7053 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7054 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7055 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7056 } else {
7057 dest_blist->forwarding_flags =
7058 WMI_EXTSCAN_NO_FORWARDING;
7059 }
7060
7061 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7062 dest_blist->configuration_flags = 0;
7063 else
7064 dest_blist->configuration_flags =
7065 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7066
Govind Singhb53420c2016-03-09 14:32:57 +05307067 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307068 __func__, dest_blist->notify_extscan_events,
7069 dest_blist->configuration_flags,
7070 dest_blist->forwarding_flags);
7071
7072 dest_blist->min_dwell_time_active =
7073 src_bucket->min_dwell_time_active;
7074 dest_blist->max_dwell_time_active =
7075 src_bucket->max_dwell_time_active;
7076 dest_blist->min_dwell_time_passive =
7077 src_bucket->min_dwell_time_passive;
7078 dest_blist->max_dwell_time_passive =
7079 src_bucket->max_dwell_time_passive;
7080 src_channel = src_bucket->channels;
7081
7082 /* save the channel info to later populate
7083 * the channel TLV
7084 */
7085 for (k = 0; k < src_bucket->numChannels; k++) {
7086 save_channel[count++].channel = src_channel->channel;
7087 src_channel++;
7088 }
7089 dest_blist++;
7090 src_bucket++;
7091 }
7092 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7093 WMITLV_SET_HDR(buf_ptr,
7094 WMITLV_TAG_ARRAY_STRUC,
7095 nchannels * sizeof(wmi_extscan_bucket_channel));
7096 dest_clist = (wmi_extscan_bucket_channel *)
7097 (buf_ptr + WMI_TLV_HDR_SIZE);
7098
7099 /* Active or passive scan is based on the bucket dwell time
7100 * and channel specific active,passive scans are not
7101 * supported yet
7102 */
7103 for (i = 0; i < nchannels; i++) {
7104 WMITLV_SET_HDR(dest_clist,
7105 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7106 WMITLV_GET_STRUCT_TLVLEN
7107 (wmi_extscan_bucket_channel));
7108 dest_clist->channel = save_channel[i].channel;
7109 dest_clist++;
7110 }
7111 buf_ptr += WMI_TLV_HDR_SIZE +
7112 (nchannels * sizeof(wmi_extscan_bucket_channel));
7113 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307114 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307115}
7116
7117/**
7118 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7119 * @wmi_handle: wmi handle
7120 * @pstart: scan command request params
7121 *
7122 * This function sends start extscan request to fw.
7123 *
7124 * Return: CDF Status.
7125 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307126static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307127 struct wifi_scan_cmd_req_params *pstart)
7128{
Govind Singhb53420c2016-03-09 14:32:57 +05307129 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307130 wmi_buf_t buf;
7131 int len;
7132
7133 /* Fill individual elements of extscan request and
7134 * TLV for buckets, channel list.
7135 */
Govind Singhb53420c2016-03-09 14:32:57 +05307136 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307137 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307138 if (qdf_status != QDF_STATUS_SUCCESS) {
7139 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7140 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307141 }
7142 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307143 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307144 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307145 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307146 }
7147 if (wmi_unified_cmd_send(wmi_handle, buf,
7148 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307149 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307150 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307151 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307152 }
7153
Govind Singhb53420c2016-03-09 14:32:57 +05307154 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307155}
7156
7157/**
7158 * send_plm_stop_cmd_tlv() - plm stop request
7159 * @wmi_handle: wmi handle
7160 * @plm: plm request parameters
7161 *
7162 * This function request FW to stop PLM.
7163 *
7164 * Return: CDF status
7165 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307166static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307167 const struct plm_req_params *plm)
7168{
7169 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7170 int32_t len;
7171 wmi_buf_t buf;
7172 uint8_t *buf_ptr;
7173 int ret;
7174
7175 len = sizeof(*cmd);
7176 buf = wmi_buf_alloc(wmi_handle, len);
7177 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307178 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7179 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307180 }
7181
7182 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7183
7184 buf_ptr = (uint8_t *) cmd;
7185
7186 WMITLV_SET_HDR(&cmd->tlv_header,
7187 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7188 WMITLV_GET_STRUCT_TLVLEN
7189 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7190
7191 cmd->vdev_id = plm->session_id;
7192
7193 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307194 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307195
7196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7197 WMI_VDEV_PLMREQ_STOP_CMDID);
7198 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307199 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307200 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307201 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307202 }
7203
Govind Singhb53420c2016-03-09 14:32:57 +05307204 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307205}
7206
7207/**
7208 * send_plm_start_cmd_tlv() - plm start request
7209 * @wmi_handle: wmi handle
7210 * @plm: plm request parameters
7211 *
7212 * This function request FW to start PLM.
7213 *
7214 * Return: CDF status
7215 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307216static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307217 const struct plm_req_params *plm,
7218 uint32_t *gchannel_list)
7219{
7220 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7221 uint32_t *channel_list;
7222 int32_t len;
7223 wmi_buf_t buf;
7224 uint8_t *buf_ptr;
7225 uint8_t count;
7226 int ret;
7227
7228 /* TLV place holder for channel_list */
7229 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7230 len += sizeof(uint32_t) * plm->plm_num_ch;
7231
7232 buf = wmi_buf_alloc(wmi_handle, len);
7233 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307234 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7235 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307236 }
7237 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7238
7239 buf_ptr = (uint8_t *) cmd;
7240
7241 WMITLV_SET_HDR(&cmd->tlv_header,
7242 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7243 WMITLV_GET_STRUCT_TLVLEN
7244 (wmi_vdev_plmreq_start_cmd_fixed_param));
7245
7246 cmd->vdev_id = plm->session_id;
7247
7248 cmd->meas_token = plm->meas_token;
7249 cmd->dialog_token = plm->diag_token;
7250 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307251 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307252 cmd->off_duration = plm->meas_duration;
7253 cmd->burst_cycle = plm->burst_len;
7254 cmd->tx_power = plm->desired_tx_pwr;
7255 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7256 cmd->num_chans = plm->plm_num_ch;
7257
7258 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7259
Govind Singhb53420c2016-03-09 14:32:57 +05307260 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7261 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7262 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7263 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7264 WMI_LOGD("off_duration: %d", cmd->off_duration);
7265 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7266 WMI_LOGD("tx_power: %d", cmd->tx_power);
7267 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307268
7269 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7270 (cmd->num_chans * sizeof(uint32_t)));
7271
7272 buf_ptr += WMI_TLV_HDR_SIZE;
7273 if (cmd->num_chans) {
7274 channel_list = (uint32_t *) buf_ptr;
7275 for (count = 0; count < cmd->num_chans; count++) {
7276 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307277 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307278 channel_list[count] =
7279 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307280 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281 }
7282 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7283 }
7284
7285 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7286 WMI_VDEV_PLMREQ_START_CMDID);
7287 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307288 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307289 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307290 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307291 }
7292
Govind Singhb53420c2016-03-09 14:32:57 +05307293 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307294}
7295
7296/**
7297 * send_pno_stop_cmd_tlv() - PNO stop request
7298 * @wmi_handle: wmi handle
7299 * @vdev_id: vdev id
7300 *
7301 * This function request FW to stop ongoing PNO operation.
7302 *
7303 * Return: CDF status
7304 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307305static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307306{
7307 wmi_nlo_config_cmd_fixed_param *cmd;
7308 int32_t len = sizeof(*cmd);
7309 wmi_buf_t buf;
7310 uint8_t *buf_ptr;
7311 int ret;
7312
7313 /*
7314 * TLV place holder for array of structures nlo_configured_parameters
7315 * TLV place holder for array of uint32_t channel_list
7316 * TLV place holder for chnl prediction cfg
7317 */
7318 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7319 buf = wmi_buf_alloc(wmi_handle, len);
7320 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307321 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7322 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307323 }
7324
7325 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7326 buf_ptr = (uint8_t *) cmd;
7327
7328 WMITLV_SET_HDR(&cmd->tlv_header,
7329 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7330 WMITLV_GET_STRUCT_TLVLEN
7331 (wmi_nlo_config_cmd_fixed_param));
7332
7333 cmd->vdev_id = vdev_id;
7334 cmd->flags = WMI_NLO_CONFIG_STOP;
7335 buf_ptr += sizeof(*cmd);
7336
7337 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7338 buf_ptr += WMI_TLV_HDR_SIZE;
7339
7340 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7341 buf_ptr += WMI_TLV_HDR_SIZE;
7342
7343 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7344 buf_ptr += WMI_TLV_HDR_SIZE;
7345
7346
7347 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7348 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7349 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307350 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307351 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307352 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307353 }
7354
Govind Singhb53420c2016-03-09 14:32:57 +05307355 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307356}
7357
7358/**
Govind Singhccb0c272016-04-01 16:30:08 +05307359 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7360 * @buf_ptr: Buffer passed by upper layers
7361 * @pno: Buffer to be sent to the firmware
7362 *
7363 * Copy the PNO Channel prediction configuration parameters
7364 * passed by the upper layers to a WMI format TLV and send it
7365 * down to the firmware.
7366 *
7367 * Return: None
7368 */
7369static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7370 struct pno_scan_req_params *pno)
7371{
7372 nlo_channel_prediction_cfg *channel_prediction_cfg =
7373 (nlo_channel_prediction_cfg *) buf_ptr;
7374 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7375 WMITLV_TAG_ARRAY_BYTE,
7376 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307377#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307378 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7379 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7380 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7381 channel_prediction_cfg->full_scan_period_ms =
7382 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307383#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307384 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7385 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7386 channel_prediction_cfg->enable,
7387 channel_prediction_cfg->top_k_num,
7388 channel_prediction_cfg->stationary_threshold,
7389 channel_prediction_cfg->full_scan_period_ms);
7390}
7391
7392/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007393 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7394 * @wmi_handle: wmi handle
7395 * @params: configuration parameters
7396 *
7397 * Return: QDF_STATUS
7398 */
7399static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7400 struct nlo_mawc_params *params)
7401{
7402 wmi_buf_t buf = NULL;
7403 QDF_STATUS status;
7404 int len;
7405 uint8_t *buf_ptr;
7406 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7407
7408 len = sizeof(*wmi_nlo_mawc_params);
7409 buf = wmi_buf_alloc(wmi_handle, len);
7410 if (!buf) {
7411 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7412 return QDF_STATUS_E_NOMEM;
7413 }
7414
7415 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7416 wmi_nlo_mawc_params =
7417 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7418 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7419 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7420 WMITLV_GET_STRUCT_TLVLEN
7421 (wmi_nlo_configure_mawc_cmd_fixed_param));
7422 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7423 if (params->enable)
7424 wmi_nlo_mawc_params->enable = 1;
7425 else
7426 wmi_nlo_mawc_params->enable = 0;
7427 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7428 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7429 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
7430
7431 status = wmi_unified_cmd_send(wmi_handle, buf,
7432 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7433 if (QDF_IS_STATUS_ERROR(status)) {
7434 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7435 status);
7436 wmi_buf_free(buf);
7437 return QDF_STATUS_E_FAILURE;
7438 }
7439 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7440 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7441 wmi_nlo_mawc_params->exp_backoff_ratio,
7442 wmi_nlo_mawc_params->init_scan_interval,
7443 wmi_nlo_mawc_params->max_scan_interval);
7444
7445 return QDF_STATUS_SUCCESS;
7446}
7447
7448/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307449 * send_pno_start_cmd_tlv() - PNO start request
7450 * @wmi_handle: wmi handle
7451 * @pno: PNO request
7452 *
7453 * This function request FW to start PNO request.
7454 * Request: CDF status
7455 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307456static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307457 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307458{
7459 wmi_nlo_config_cmd_fixed_param *cmd;
7460 nlo_configured_parameters *nlo_list;
7461 uint32_t *channel_list;
7462 int32_t len;
7463 wmi_buf_t buf;
7464 uint8_t *buf_ptr;
7465 uint8_t i;
7466 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307467 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307468
7469 /*
7470 * TLV place holder for array nlo_configured_parameters(nlo_list)
7471 * TLV place holder for array of uint32_t channel_list
7472 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307473 * TLV place holder for array of wmi_vendor_oui
Govind Singh4eacd2b2016-03-07 14:24:22 +05307474 */
7475 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307476 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
7477 WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307478
Abhishek Singh5987b632017-03-03 22:09:07 +05307479 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307480 WMI_NLO_MAX_CHAN);
7481 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307482 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307483 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307484 len += sizeof(enlo_candidate_score_params);
7485 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307486
7487 buf = wmi_buf_alloc(wmi_handle, len);
7488 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307489 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7490 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307491 }
7492
7493 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7494
7495 buf_ptr = (uint8_t *) cmd;
7496 WMITLV_SET_HDR(&cmd->tlv_header,
7497 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7498 WMITLV_GET_STRUCT_TLVLEN
7499 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307500 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307501 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7502
Govind Singh87542482016-06-08 19:40:11 +05307503#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307504 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307505 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307506#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307507 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307508 cmd->active_dwell_time = pno->active_dwell_time;
7509 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307510
7511 /* Copy scan interval */
7512 cmd->fast_scan_period = pno->fast_scan_period;
7513 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007514 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307515 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007516 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307517 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307518 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307519 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307520
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307521 /* mac randomization attributes */
7522 if (pno->scan_random.randomize) {
7523 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7524 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7525 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7526 pno->scan_random.mac_mask,
7527 &cmd->mac_addr,
7528 &cmd->mac_mask);
7529 }
7530
Govind Singh4eacd2b2016-03-07 14:24:22 +05307531 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7532
Abhishek Singh5987b632017-03-03 22:09:07 +05307533 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307534 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7536 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7537 buf_ptr += WMI_TLV_HDR_SIZE;
7538
7539 nlo_list = (nlo_configured_parameters *) buf_ptr;
7540 for (i = 0; i < cmd->no_of_ssids; i++) {
7541 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7542 WMITLV_TAG_ARRAY_BYTE,
7543 WMITLV_GET_STRUCT_TLVLEN
7544 (nlo_configured_parameters));
7545 /* Copy ssid and it's length */
7546 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307547 nlo_list[i].ssid.ssid.ssid_len =
7548 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307549 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307550 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307551 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307552 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307553 nlo_list[i].ssid.ssid.ssid_len,
7554 (char *)nlo_list[i].ssid.ssid.ssid,
7555 nlo_list[i].ssid.ssid.ssid_len);
7556
7557 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307558 if (pno->networks_list[i].rssi_thresh &&
7559 pno->networks_list[i].rssi_thresh >
7560 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307561 nlo_list[i].rssi_cond.valid = true;
7562 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307563 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307564 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307565 nlo_list[i].rssi_cond.rssi);
7566 }
7567 nlo_list[i].bcast_nw_type.valid = true;
7568 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307569 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007570 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307571 nlo_list[i].bcast_nw_type.bcast_nw_type);
7572 }
7573 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7574
7575 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307576 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307577 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307578 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307579 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7580 (cmd->num_of_channels * sizeof(uint32_t)));
7581 buf_ptr += WMI_TLV_HDR_SIZE;
7582
7583 channel_list = (uint32_t *) buf_ptr;
7584 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307585 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307586
7587 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307588 channel_list[i] =
7589 wlan_chan_to_freq(pno->
7590 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307591
Govind Singhb53420c2016-03-09 14:32:57 +05307592 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307593 }
7594 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7596 sizeof(nlo_channel_prediction_cfg));
7597 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307598 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307599 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307600 /** TODO: Discrete firmware doesn't have command/option to configure
7601 * App IE which comes from wpa_supplicant as of part PNO start request.
7602 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307603 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7604 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7605 buf_ptr += sizeof(enlo_candidate_score_params);
7606
7607 if (ie_whitelist->white_list) {
7608 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7609 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7610 &cmd->num_vendor_oui,
7611 ie_whitelist);
7612 }
7613
7614 /* ie white list */
7615 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7616 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7617 buf_ptr += WMI_TLV_HDR_SIZE;
7618 if (cmd->num_vendor_oui != 0) {
7619 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7620 ie_whitelist->voui);
7621 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7622 }
7623
Govind Singh4eacd2b2016-03-07 14:24:22 +05307624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7625 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7626 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307627 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307628 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307629 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307630 }
7631
Govind Singhb53420c2016-03-09 14:32:57 +05307632 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307633}
7634
7635/* send_set_ric_req_cmd_tlv() - set ric request element
7636 * @wmi_handle: wmi handle
7637 * @msg: message
7638 * @is_add_ts: is addts required
7639 *
7640 * This function sets ric request element for 11r roaming.
7641 *
7642 * Return: CDF status
7643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307644static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307645 void *msg, uint8_t is_add_ts)
7646{
7647 wmi_ric_request_fixed_param *cmd;
7648 wmi_ric_tspec *tspec_param;
7649 wmi_buf_t buf;
7650 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307651 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307652 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7653 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7654
7655 buf = wmi_buf_alloc(wmi_handle, len);
7656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307657 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7658 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307659 }
7660
7661 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7662
7663 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7664 WMITLV_SET_HDR(&cmd->tlv_header,
7665 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7666 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7667 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007668 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307669 else
7670 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7671 cmd->num_ric_request = 1;
7672 cmd->is_add_ric = is_add_ts;
7673
7674 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7675 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7676
7677 buf_ptr += WMI_TLV_HDR_SIZE;
7678 tspec_param = (wmi_ric_tspec *) buf_ptr;
7679 WMITLV_SET_HDR(&tspec_param->tlv_header,
7680 WMITLV_TAG_STRUC_wmi_ric_tspec,
7681 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7682
7683 if (is_add_ts)
7684 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307685#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307686 else
7687 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307688#endif
7689 if (ptspecIE) {
7690 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307691#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307692 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7693 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307694#else
Govind Singh87542482016-06-08 19:40:11 +05307695 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7696 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307697#endif /* ANI_LITTLE_BIT_ENDIAN */
7698
Govind Singh87542482016-06-08 19:40:11 +05307699 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7700 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7701 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7702 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7703 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7704 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7705 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7706 tspec_param->min_data_rate = ptspecIE->minDataRate;
7707 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7708 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7709 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7710 tspec_param->delay_bound = ptspecIE->delayBound;
7711 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7712 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7713 tspec_param->medium_time = 0;
7714 }
Govind Singhb53420c2016-03-09 14:32:57 +05307715 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307716
7717 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7718 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307719 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307720 __func__);
7721 if (is_add_ts)
7722 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307723 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307724 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307725 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307726 }
7727
Govind Singhb53420c2016-03-09 14:32:57 +05307728 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307729}
7730
7731/**
7732 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7733 * @wmi_handle: wmi handle
7734 * @clear_req: ll stats clear request command params
7735 *
Govind Singhb53420c2016-03-09 14:32:57 +05307736 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307737 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307738static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307739 const struct ll_stats_clear_params *clear_req,
7740 uint8_t addr[IEEE80211_ADDR_LEN])
7741{
7742 wmi_clear_link_stats_cmd_fixed_param *cmd;
7743 int32_t len;
7744 wmi_buf_t buf;
7745 uint8_t *buf_ptr;
7746 int ret;
7747
7748 len = sizeof(*cmd);
7749 buf = wmi_buf_alloc(wmi_handle, len);
7750
7751 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307752 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7753 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307754 }
7755
7756 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307757 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307758 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7759
7760 WMITLV_SET_HDR(&cmd->tlv_header,
7761 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7762 WMITLV_GET_STRUCT_TLVLEN
7763 (wmi_clear_link_stats_cmd_fixed_param));
7764
7765 cmd->stop_stats_collection_req = clear_req->stop_req;
7766 cmd->vdev_id = clear_req->sta_id;
7767 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7768
7769 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7770 &cmd->peer_macaddr);
7771
Govind Singhb53420c2016-03-09 14:32:57 +05307772 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7773 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7774 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7775 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7776 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307777 cmd->peer_macaddr); */
7778
7779 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7780 WMI_CLEAR_LINK_STATS_CMDID);
7781 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307782 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307783 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307784 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307785 }
7786
Govind Singhb53420c2016-03-09 14:32:57 +05307787 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7788 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307789}
7790
7791/**
7792 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7793 * @wmi_handle: wmi handle
7794 * @setReq: ll stats set request command params
7795 *
Govind Singhb53420c2016-03-09 14:32:57 +05307796 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307797 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307798static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307799 const struct ll_stats_set_params *set_req)
7800{
7801 wmi_start_link_stats_cmd_fixed_param *cmd;
7802 int32_t len;
7803 wmi_buf_t buf;
7804 uint8_t *buf_ptr;
7805 int ret;
7806
7807 len = sizeof(*cmd);
7808 buf = wmi_buf_alloc(wmi_handle, len);
7809
7810 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307811 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7812 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307813 }
7814
7815 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307816 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307817 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7818
7819 WMITLV_SET_HDR(&cmd->tlv_header,
7820 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7821 WMITLV_GET_STRUCT_TLVLEN
7822 (wmi_start_link_stats_cmd_fixed_param));
7823
7824 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7825 cmd->aggressive_statistics_gathering =
7826 set_req->aggressive_statistics_gathering;
7827
Govind Singhb53420c2016-03-09 14:32:57 +05307828 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7829 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7830 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307831
7832 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7833 WMI_START_LINK_STATS_CMDID);
7834 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307835 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307836 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307837 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307838 }
7839
Govind Singhb53420c2016-03-09 14:32:57 +05307840 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307841}
7842
7843/**
7844 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7845 * @wmi_handle:wmi handle
7846 * @get_req:ll stats get request command params
7847 * @addr: mac address
7848 *
Govind Singhb53420c2016-03-09 14:32:57 +05307849 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307850 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307851static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307852 const struct ll_stats_get_params *get_req,
7853 uint8_t addr[IEEE80211_ADDR_LEN])
7854{
7855 wmi_request_link_stats_cmd_fixed_param *cmd;
7856 int32_t len;
7857 wmi_buf_t buf;
7858 uint8_t *buf_ptr;
7859 int ret;
7860
7861 len = sizeof(*cmd);
7862 buf = wmi_buf_alloc(wmi_handle, len);
7863
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307864 if (!buf) {
7865 WMI_LOGE("%s: buf allocation failed", __func__);
7866 return QDF_STATUS_E_NOMEM;
7867 }
7868
Govind Singh4eacd2b2016-03-07 14:24:22 +05307869 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307870 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307871 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7872
7873 WMITLV_SET_HDR(&cmd->tlv_header,
7874 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7875 WMITLV_GET_STRUCT_TLVLEN
7876 (wmi_request_link_stats_cmd_fixed_param));
7877
7878 cmd->request_id = get_req->req_id;
7879 cmd->stats_type = get_req->param_id_mask;
7880 cmd->vdev_id = get_req->sta_id;
7881
7882 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7883 &cmd->peer_macaddr);
7884
Govind Singhb53420c2016-03-09 14:32:57 +05307885 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007886 WMI_LOGD("Request ID : %u", cmd->request_id);
7887 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307888 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7889 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307890
7891 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7892 WMI_REQUEST_LINK_STATS_CMDID);
7893 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307894 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307895 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307896 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307897 }
7898
Govind Singhb53420c2016-03-09 14:32:57 +05307899 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307900}
7901
7902/**
7903 * send_get_stats_cmd_tlv() - get stats request
7904 * @wmi_handle: wmi handle
7905 * @get_stats_param: stats params
7906 * @addr: mac address
7907 *
7908 * Return: CDF status
7909 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307910static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307911 struct pe_stats_req *get_stats_param,
7912 uint8_t addr[IEEE80211_ADDR_LEN])
7913{
7914 wmi_buf_t buf;
7915 wmi_request_stats_cmd_fixed_param *cmd;
7916 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7917
7918 buf = wmi_buf_alloc(wmi_handle, len);
7919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307920 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7921 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307922 }
7923
7924
7925 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7926 WMITLV_SET_HDR(&cmd->tlv_header,
7927 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7928 WMITLV_GET_STRUCT_TLVLEN
7929 (wmi_request_stats_cmd_fixed_param));
Gurumoorthi Gnanasambandhan4aec3672017-07-10 11:55:23 +05307930 cmd->stats_id = get_stats_param->stats_mask;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307931 cmd->vdev_id = get_stats_param->session_id;
7932 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307934 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7935 WMI_REQUEST_STATS_CMDID)) {
7936
Govind Singhb53420c2016-03-09 14:32:57 +05307937 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307938 __func__);
7939 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307940 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307941 }
7942
Govind Singhb53420c2016-03-09 14:32:57 +05307943 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307944
7945}
7946
Govind Singh20c5dac2016-03-07 15:33:31 +05307947/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307948 * send_congestion_cmd_tlv() - send request to fw to get CCA
7949 * @wmi_handle: wmi handle
7950 * @vdev_id: vdev id
7951 *
7952 * Return: CDF status
7953 */
7954static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7955 A_UINT8 vdev_id)
7956{
7957 wmi_buf_t buf;
7958 wmi_request_stats_cmd_fixed_param *cmd;
7959 uint8_t len;
7960 uint8_t *buf_ptr;
7961
7962 len = sizeof(*cmd);
7963 buf = wmi_buf_alloc(wmi_handle, len);
7964 if (!buf) {
7965 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7966 return QDF_STATUS_E_FAILURE;
7967 }
7968
7969 buf_ptr = wmi_buf_data(buf);
7970 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7971 WMITLV_SET_HDR(&cmd->tlv_header,
7972 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7973 WMITLV_GET_STRUCT_TLVLEN
7974 (wmi_request_stats_cmd_fixed_param));
7975
7976 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7977 cmd->vdev_id = vdev_id;
7978 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7979 cmd->vdev_id, cmd->stats_id);
7980
7981 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7982 WMI_REQUEST_STATS_CMDID)) {
7983 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7984 __func__);
7985 wmi_buf_free(buf);
7986 return QDF_STATUS_E_FAILURE;
7987 }
7988
7989 return QDF_STATUS_SUCCESS;
7990}
7991
7992/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307993 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7994 * @wmi_handle: wmi handle
7995 * @rssi_req: get RSSI request
7996 *
7997 * Return: CDF status
7998 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307999static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308000{
8001 wmi_buf_t buf;
8002 wmi_request_stats_cmd_fixed_param *cmd;
8003 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8004
8005 buf = wmi_buf_alloc(wmi_handle, len);
8006 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308007 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8008 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308009 }
8010
8011 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8012 WMITLV_SET_HDR(&cmd->tlv_header,
8013 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8014 WMITLV_GET_STRUCT_TLVLEN
8015 (wmi_request_stats_cmd_fixed_param));
8016 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8017 if (wmi_unified_cmd_send
8018 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308019 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308020 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308021 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308022 }
8023
Govind Singhb53420c2016-03-09 14:32:57 +05308024 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308025}
8026
8027/**
8028 * send_snr_cmd_tlv() - get RSSI from fw
8029 * @wmi_handle: wmi handle
8030 * @vdev_id: vdev id
8031 *
8032 * Return: CDF status
8033 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308034static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308035{
8036 wmi_buf_t buf;
8037 wmi_request_stats_cmd_fixed_param *cmd;
8038 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8039
8040 buf = wmi_buf_alloc(wmi_handle, len);
8041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308042 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8043 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308044 }
8045
8046 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8047 cmd->vdev_id = vdev_id;
8048
8049 WMITLV_SET_HDR(&cmd->tlv_header,
8050 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8051 WMITLV_GET_STRUCT_TLVLEN
8052 (wmi_request_stats_cmd_fixed_param));
8053 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8054 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8055 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308056 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308057 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308059 }
8060
Govind Singhb53420c2016-03-09 14:32:57 +05308061 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308062}
8063
8064/**
8065 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8066 * @wmi_handle: wmi handle
8067 * @link_status: get link params
8068 *
8069 * Return: CDF status
8070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308071static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308072 struct link_status_params *link_status)
8073{
8074 wmi_buf_t buf;
8075 wmi_request_stats_cmd_fixed_param *cmd;
8076 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8077
8078 buf = wmi_buf_alloc(wmi_handle, len);
8079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308080 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8081 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308082 }
8083
8084 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8085 WMITLV_SET_HDR(&cmd->tlv_header,
8086 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8087 WMITLV_GET_STRUCT_TLVLEN
8088 (wmi_request_stats_cmd_fixed_param));
8089 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8090 cmd->vdev_id = link_status->session_id;
8091 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8092 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308093 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308094 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308095 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308096 }
8097
Govind Singhb53420c2016-03-09 14:32:57 +05308098 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308099}
8100
Govind Singh20c5dac2016-03-07 15:33:31 +05308101/**
8102 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8103 * @wmi_handle: wmi handle
8104 * @ta_dhcp_ind: DHCP indication parameter
8105 *
8106 * Return: CDF Status
8107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308108static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308109 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8110{
Govind Singh67922e82016-04-01 16:48:57 +05308111 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308112 wmi_buf_t buf = NULL;
8113 uint8_t *buf_ptr;
8114 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8115 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8116
8117
8118 buf = wmi_buf_alloc(wmi_handle, len);
8119 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308120 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8121 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308122 }
8123
8124 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8125 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8126 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8127 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8128 WMITLV_GET_STRUCT_TLVLEN
8129 (wmi_peer_set_param_cmd_fixed_param));
8130
8131 /* fill in values */
8132 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8133 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8134 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308135 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308136 &ta_dhcp_ind->peer_macaddr,
8137 sizeof(ta_dhcp_ind->peer_macaddr));
8138
8139 status = wmi_unified_cmd_send(wmi_handle, buf,
8140 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308141 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308142 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308143 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308144 wmi_buf_free(buf);
8145 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308146
Govind Singh67922e82016-04-01 16:48:57 +05308147 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308148}
8149
8150/**
8151 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8152 * @wmi_handle: wmi handle
8153 * @pLinkSpeed: link speed info
8154 *
8155 * Return: CDF status
8156 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308157static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 wmi_mac_addr peer_macaddr)
8159{
8160 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8161 wmi_buf_t wmi_buf;
8162 uint32_t len;
8163 uint8_t *buf_ptr;
8164
8165 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8166 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8167 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308168 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8169 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308170 }
8171 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8172
8173 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8174 WMITLV_SET_HDR(&cmd->tlv_header,
8175 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8176 WMITLV_GET_STRUCT_TLVLEN
8177 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8178
8179 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308180 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308181 &peer_macaddr,
8182 sizeof(peer_macaddr));
8183
8184
8185 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8186 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308187 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308188 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308189 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308190 }
Govind Singhb53420c2016-03-09 14:32:57 +05308191 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308192}
8193
8194/**
8195 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8196 * @wmi_handle: wmi handler
8197 * @egap_params: pointer to egap_params
8198 *
8199 * Return: 0 for success, otherwise appropriate error code
8200 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308201static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308202 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
8203{
8204 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8205 wmi_buf_t buf;
8206 int32_t err;
8207
8208 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8209 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308210 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8211 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308212 }
8213 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8214 WMITLV_SET_HDR(&cmd->tlv_header,
8215 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8216 WMITLV_GET_STRUCT_TLVLEN(
8217 wmi_ap_ps_egap_param_cmd_fixed_param));
8218
8219 cmd->enable = egap_params->enable;
8220 cmd->inactivity_time = egap_params->inactivity_time;
8221 cmd->wait_time = egap_params->wait_time;
8222 cmd->flags = egap_params->flags;
8223 err = wmi_unified_cmd_send(wmi_handle, buf,
8224 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8225 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308226 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308227 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308228 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308229 }
8230
Govind Singhb53420c2016-03-09 14:32:57 +05308231 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308232}
8233
8234/**
8235 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8236 * @wmi_handl: wmi handle
8237 * @cmd: Profiling command index
8238 * @value1: parameter1 value
8239 * @value2: parameter2 value
8240 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308241 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308243static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308244 uint32_t cmd, uint32_t value1, uint32_t value2)
8245{
8246 wmi_buf_t buf;
8247 int32_t len = 0;
8248 int ret;
8249 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8250 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8251 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8252 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8253
8254 switch (cmd) {
8255 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8256 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8257 buf = wmi_buf_alloc(wmi_handle, len);
8258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308259 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308260 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308261 }
8262 prof_trig_cmd =
8263 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8264 wmi_buf_data(buf);
8265 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8266 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8267 WMITLV_GET_STRUCT_TLVLEN
8268 (wmi_wlan_profile_trigger_cmd_fixed_param));
8269 prof_trig_cmd->enable = value1;
8270 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8271 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8272 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308273 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308274 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308275 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308276 return ret;
8277 }
8278 break;
8279
8280 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8281 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8282 buf = wmi_buf_alloc(wmi_handle, len);
8283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308284 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308285 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308286 }
8287 profile_getdata_cmd =
8288 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8289 wmi_buf_data(buf);
8290 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8291 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8292 WMITLV_GET_STRUCT_TLVLEN
8293 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8294 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8295 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8296 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308297 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308298 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308299 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308300 return ret;
8301 }
8302 break;
8303
8304 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8305 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8306 buf = wmi_buf_alloc(wmi_handle, len);
8307 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308308 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308309 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308310 }
8311 hist_intvl_cmd =
8312 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8313 wmi_buf_data(buf);
8314 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8315 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8316 WMITLV_GET_STRUCT_TLVLEN
8317 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8318 hist_intvl_cmd->profile_id = value1;
8319 hist_intvl_cmd->value = value2;
8320 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8321 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8322 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308323 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308324 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308325 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 return ret;
8327 }
8328 break;
8329
8330 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8331 len =
8332 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8333 buf = wmi_buf_alloc(wmi_handle, len);
8334 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308335 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308336 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308337 }
8338 profile_enable_cmd =
8339 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8340 wmi_buf_data(buf);
8341 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8342 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8343 WMITLV_GET_STRUCT_TLVLEN
8344 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8345 profile_enable_cmd->profile_id = value1;
8346 profile_enable_cmd->enable = value2;
8347 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8348 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8349 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308350 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308351 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308352 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308353 return ret;
8354 }
8355 break;
8356
8357 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308358 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308359 break;
8360 }
8361
8362 return 0;
8363}
8364
Govind Singh20c5dac2016-03-07 15:33:31 +05308365/**
8366 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8367 * @wmi_handle: wmi handle
8368 * @vdev_id: vdev id
8369 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308370 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308371 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308372static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308373{
8374 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8375 wmi_buf_t buf;
8376 int32_t len = sizeof(*cmd);
8377
Govind Singhb53420c2016-03-09 14:32:57 +05308378 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308379 buf = wmi_buf_alloc(wmi_handle, len);
8380 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308381 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308382 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308383 }
8384 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8385 wmi_buf_data(buf);
8386 WMITLV_SET_HDR(&cmd->tlv_header,
8387 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8388 WMITLV_GET_STRUCT_TLVLEN
8389 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8390 cmd->vdev_id = vdev_id;
8391 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8392 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8393 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308394 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308395 __func__);
8396 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308397 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308398 }
8399
8400 return 0;
8401}
8402
8403/**
8404 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8405 * @wmi_handle: wmi handle
8406 * @vdev_id: vdev id
8407 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308408 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308410static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 uint8_t vdev_id)
8412{
8413 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8414 wmi_buf_t buf;
8415 int32_t len = sizeof(*cmd);
8416
Govind Singhb53420c2016-03-09 14:32:57 +05308417 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308418 buf = wmi_buf_alloc(wmi_handle, len);
8419 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308420 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308421 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308422 }
8423 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8424 WMITLV_SET_HDR(&cmd->tlv_header,
8425 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8426 WMITLV_GET_STRUCT_TLVLEN
8427 (wmi_csa_offload_enable_cmd_fixed_param));
8428 cmd->vdev_id = vdev_id;
8429 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8430 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8431 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308432 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308433 __func__);
8434 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308435 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308436 }
8437
8438 return 0;
8439}
8440
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008441#ifdef WLAN_FEATURE_CIF_CFR
8442/**
8443 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8444 * @wmi_handle: wmi handle
8445 * @data_len: len of dma cfg req
8446 * @data: dma cfg req
8447 *
8448 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8449 */
8450static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8451 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8452{
8453 wmi_buf_t buf;
8454 uint8_t *cmd;
8455 QDF_STATUS ret;
8456
8457 WMITLV_SET_HDR(cfg,
8458 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8459 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8460
8461 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8462 if (!buf) {
8463 WMI_LOGE(FL("wmi_buf_alloc failed"));
8464 return QDF_STATUS_E_FAILURE;
8465 }
8466
8467 cmd = (uint8_t *) wmi_buf_data(buf);
8468 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8469 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8470 sizeof(*cfg));
8471 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8472 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8473 if (QDF_IS_STATUS_ERROR(ret)) {
8474 WMI_LOGE(FL(":wmi cmd send failed"));
8475 wmi_buf_free(buf);
8476 }
8477
8478 return ret;
8479}
8480#endif
8481
Govind Singh20c5dac2016-03-07 15:33:31 +05308482/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008483 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8484 * @wmi_handle: wmi handle
8485 * @start_11d_scan: 11d scan start request parameters
8486 *
8487 * This function request FW to start 11d scan.
8488 *
8489 * Return: QDF status
8490 */
8491static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8492 struct reg_start_11d_scan_req *start_11d_scan)
8493{
8494 wmi_11d_scan_start_cmd_fixed_param *cmd;
8495 int32_t len;
8496 wmi_buf_t buf;
8497 int ret;
8498
8499 len = sizeof(*cmd);
8500 buf = wmi_buf_alloc(wmi_handle, len);
8501 if (!buf) {
8502 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8503 return QDF_STATUS_E_NOMEM;
8504 }
8505
8506 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8507
8508 WMITLV_SET_HDR(&cmd->tlv_header,
8509 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8510 WMITLV_GET_STRUCT_TLVLEN
8511 (wmi_11d_scan_start_cmd_fixed_param));
8512
8513 cmd->vdev_id = start_11d_scan->vdev_id;
8514 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8515 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8516
8517 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8518
8519 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8520 WMI_11D_SCAN_START_CMDID);
8521 if (ret) {
8522 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8523 wmi_buf_free(buf);
8524 return QDF_STATUS_E_FAILURE;
8525 }
8526
8527 return QDF_STATUS_SUCCESS;
8528}
8529
8530/**
8531 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8532 * @wmi_handle: wmi handle
8533 * @start_11d_scan: 11d scan stop request parameters
8534 *
8535 * This function request FW to stop 11d scan.
8536 *
8537 * Return: QDF status
8538 */
8539static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8540 struct reg_stop_11d_scan_req *stop_11d_scan)
8541{
8542 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8543 int32_t len;
8544 wmi_buf_t buf;
8545 int ret;
8546
8547 len = sizeof(*cmd);
8548 buf = wmi_buf_alloc(wmi_handle, len);
8549 if (!buf) {
8550 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8551 return QDF_STATUS_E_NOMEM;
8552 }
8553
8554 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8555
8556 WMITLV_SET_HDR(&cmd->tlv_header,
8557 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8558 WMITLV_GET_STRUCT_TLVLEN
8559 (wmi_11d_scan_stop_cmd_fixed_param));
8560
8561 cmd->vdev_id = stop_11d_scan->vdev_id;
8562
8563 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8564
8565 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8566 WMI_11D_SCAN_STOP_CMDID);
8567 if (ret) {
8568 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8569 wmi_buf_free(buf);
8570 return QDF_STATUS_E_FAILURE;
8571 }
8572
8573 return QDF_STATUS_SUCCESS;
8574}
8575
8576/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308577 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8578 * @wmi_handle: wmi handle
8579 * @startOemDataReq: start request params
8580 *
8581 * Return: CDF status
8582 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308583static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008584 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308585 uint8_t *data)
8586{
8587 wmi_buf_t buf;
8588 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308589 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308590
8591 buf = wmi_buf_alloc(wmi_handle,
8592 (data_len + WMI_TLV_HDR_SIZE));
8593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308594 WMI_LOGE(FL("wmi_buf_alloc failed"));
8595 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308596 }
8597
8598 cmd = (uint8_t *) wmi_buf_data(buf);
8599
8600 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8601 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308602 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308603 data_len);
8604
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008605 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308606 data_len);
8607
8608 ret = wmi_unified_cmd_send(wmi_handle, buf,
8609 (data_len +
8610 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8611
Govind Singh67922e82016-04-01 16:48:57 +05308612 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308613 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308614 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308615 }
8616
Govind Singh67922e82016-04-01 16:48:57 +05308617 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308618}
8619
8620/**
8621 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8622 * @wmi_handle: wmi handle
8623 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8624 *
8625 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8626 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8627 * to firmware based on phyerr filtering
8628 * offload status.
8629 *
8630 * Return: 1 success, 0 failure
8631 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308632static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308633send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8634 bool dfs_phyerr_filter_offload)
8635{
8636 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8637 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8638 wmi_buf_t buf;
8639 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308640 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308641
8642
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008643 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308644 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308645 __func__);
8646 len = sizeof(*disable_phyerr_offload_cmd);
8647 buf = wmi_buf_alloc(wmi_handle, len);
8648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308649 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308650 return 0;
8651 }
8652 disable_phyerr_offload_cmd =
8653 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8654 wmi_buf_data(buf);
8655
8656 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8657 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8658 WMITLV_GET_STRUCT_TLVLEN
8659 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8660
8661 /*
8662 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8663 * to the firmware to disable the phyerror
8664 * filtering offload.
8665 */
8666 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8667 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308668 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308669 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308670 __func__, ret);
8671 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308672 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308673 }
Govind Singhb53420c2016-03-09 14:32:57 +05308674 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308675 __func__);
8676 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308677 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308678 __func__);
8679
8680 len = sizeof(*enable_phyerr_offload_cmd);
8681 buf = wmi_buf_alloc(wmi_handle, len);
8682 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308683 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8684 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308685 }
8686
8687 enable_phyerr_offload_cmd =
8688 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8689 wmi_buf_data(buf);
8690
8691 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8692 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8693 WMITLV_GET_STRUCT_TLVLEN
8694 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8695
8696 /*
8697 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8698 * to the firmware to enable the phyerror
8699 * filtering offload.
8700 */
8701 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8702 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8703
Govind Singh67922e82016-04-01 16:48:57 +05308704 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308705 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308706 __func__, ret);
8707 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308708 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308709 }
Govind Singhb53420c2016-03-09 14:32:57 +05308710 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308711 __func__);
8712 }
8713
Govind Singhb53420c2016-03-09 14:32:57 +05308714 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308715}
8716
8717#if !defined(REMOVE_PKT_LOG)
8718/**
8719 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8720 * @wmi_handle: wmi handle
8721 * @pktlog_event: pktlog event
8722 * @cmd_id: pktlog cmd id
8723 *
8724 * Return: CDF status
8725 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308726static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308728 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308729{
8730 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8731 WMI_CMD_ID CMD_ID;
8732 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8733 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8734 int len = 0;
8735 wmi_buf_t buf;
8736
8737 PKTLOG_EVENT = pktlog_event;
8738 CMD_ID = cmd_id;
8739
8740 switch (CMD_ID) {
8741 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8742 len = sizeof(*cmd);
8743 buf = wmi_buf_alloc(wmi_handle, len);
8744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308745 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8746 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308747 }
8748 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8749 wmi_buf_data(buf);
8750 WMITLV_SET_HDR(&cmd->tlv_header,
8751 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8752 WMITLV_GET_STRUCT_TLVLEN
8753 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8754 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308755 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8756 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308757 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8758 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308759 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8760 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308761 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308762 goto wmi_send_failed;
8763 }
8764 break;
8765 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8766 len = sizeof(*disable_cmd);
8767 buf = wmi_buf_alloc(wmi_handle, len);
8768 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8770 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308771 }
8772 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8773 wmi_buf_data(buf);
8774 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8775 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8776 WMITLV_GET_STRUCT_TLVLEN
8777 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308778 disable_cmd->pdev_id =
8779 wmi_handle->ops->convert_pdev_id_host_to_target(
8780 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308781 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8782 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308783 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308784 goto wmi_send_failed;
8785 }
8786 break;
8787 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308788 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308789 break;
8790 }
8791
Govind Singhb53420c2016-03-09 14:32:57 +05308792 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308793
8794wmi_send_failed:
8795 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308796 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308797}
8798#endif /* REMOVE_PKT_LOG */
8799
8800/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308801 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8802 * @wmi_handle: wmi handle
8803 * @ptrn_id: pattern id
8804 * @vdev_id: vdev id
8805 *
8806 * Return: CDF status
8807 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308808static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8809 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308810{
8811 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8812 wmi_buf_t buf;
8813 int32_t len;
8814 int ret;
8815
8816 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8817
8818
8819 buf = wmi_buf_alloc(wmi_handle, len);
8820 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308821 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8822 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308823 }
8824
8825 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8826
8827 WMITLV_SET_HDR(&cmd->tlv_header,
8828 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8829 WMITLV_GET_STRUCT_TLVLEN(
8830 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8831 cmd->vdev_id = vdev_id;
8832 cmd->pattern_id = ptrn_id;
8833 cmd->pattern_type = WOW_BITMAP_PATTERN;
8834
Govind Singhb53420c2016-03-09 14:32:57 +05308835 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 cmd->pattern_id, vdev_id);
8837
8838 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8839 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8840 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308841 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308843 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 }
8845
Govind Singhb53420c2016-03-09 14:32:57 +05308846 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308847}
8848
8849/**
8850 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8851 * @wmi_handle: wmi handle
8852 *
8853 * Sends host wakeup indication to FW. On receiving this indication,
8854 * FW will come out of WOW.
8855 *
8856 * Return: CDF status
8857 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308858static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308859{
8860 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8861 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308862 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308863 int32_t len;
8864 int ret;
8865
8866 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8867
8868 buf = wmi_buf_alloc(wmi_handle, len);
8869 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308870 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8871 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 }
8873
8874 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8875 wmi_buf_data(buf);
8876 WMITLV_SET_HDR(&cmd->tlv_header,
8877 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8878 WMITLV_GET_STRUCT_TLVLEN
8879 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8880
8881
8882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8883 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8884 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308885 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308886 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308887 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308888 }
8889
Govind Singhb53420c2016-03-09 14:32:57 +05308890 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308891}
8892
8893/**
8894 * send_del_ts_cmd_tlv() - send DELTS request to fw
8895 * @wmi_handle: wmi handle
8896 * @msg: delts params
8897 *
8898 * Return: CDF status
8899 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308900static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308901 uint8_t ac)
8902{
8903 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8904 wmi_buf_t buf;
8905 int32_t len = sizeof(*cmd);
8906
8907 buf = wmi_buf_alloc(wmi_handle, len);
8908 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308909 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8910 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308911 }
8912 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8913 WMITLV_SET_HDR(&cmd->tlv_header,
8914 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8915 WMITLV_GET_STRUCT_TLVLEN
8916 (wmi_vdev_wmm_delts_cmd_fixed_param));
8917 cmd->vdev_id = vdev_id;
8918 cmd->ac = ac;
8919
Govind Singhb53420c2016-03-09 14:32:57 +05308920 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308921 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8922 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8923 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308924 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308925 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308926 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308927 }
8928
Govind Singhb53420c2016-03-09 14:32:57 +05308929 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308930}
8931
8932/**
8933 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8934 * @wmi_handle: handle to wmi
8935 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8936 *
Govind Singhb53420c2016-03-09 14:32:57 +05308937 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308938 * ADD_TS requestes to firmware in loop for all the ACs with
8939 * active flow.
8940 *
8941 * Return: CDF status
8942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308943static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308944 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8945{
8946 int i = 0;
8947 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8948 wmi_buf_t buf;
8949 int32_t len = sizeof(*cmd);
8950
8951 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8952 /* if flow in this AC is active */
8953 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8954 /*
8955 * as per implementation of wma_add_ts_req() we
8956 * are not waiting any response from firmware so
8957 * apart from sending ADDTS to firmware just send
8958 * success to upper layers
8959 */
Govind Singhb53420c2016-03-09 14:32:57 +05308960 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308961
8962 buf = wmi_buf_alloc(wmi_handle, len);
8963 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308964 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8965 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308966 }
8967 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8968 wmi_buf_data(buf);
8969 WMITLV_SET_HDR(&cmd->tlv_header,
8970 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8971 WMITLV_GET_STRUCT_TLVLEN
8972 (wmi_vdev_wmm_addts_cmd_fixed_param));
8973 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8974 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308975 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308976 traffic.userPrio);
8977 cmd->medium_time_us =
8978 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8979 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308980 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308981 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8982 cmd->medium_time_us, cmd->downgrade_type);
8983 if (wmi_unified_cmd_send
8984 (wmi_handle, buf, len,
8985 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308986 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308987 __func__);
8988 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308989 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308990 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308991 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308992 }
8993 }
8994 }
8995
Govind Singhb53420c2016-03-09 14:32:57 +05308996 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308997}
8998
8999/**
9000 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9001 * @wmi_handle: wmi handle
9002 * @msg: ADDTS params
9003 *
9004 * Return: CDF status
9005 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309006static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309007 struct add_ts_param *msg)
9008{
9009 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9010 wmi_buf_t buf;
9011 int32_t len = sizeof(*cmd);
9012
Govind Singhb53420c2016-03-09 14:32:57 +05309013 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309014
9015 buf = wmi_buf_alloc(wmi_handle, len);
9016 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309017 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9018 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309019 }
9020 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9021 WMITLV_SET_HDR(&cmd->tlv_header,
9022 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9023 WMITLV_GET_STRUCT_TLVLEN
9024 (wmi_vdev_wmm_addts_cmd_fixed_param));
9025 cmd->vdev_id = msg->sme_session_id;
9026 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9027 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9028 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309029 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309030 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9031 cmd->downgrade_type, __func__, __LINE__);
9032 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9033 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309034 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9035 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309036 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309037 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309038 }
9039
Govind Singhb53420c2016-03-09 14:32:57 +05309040 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309041}
9042
9043/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309044 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9045 * @wmi_handle: wmi handle
9046 * @pAddPeriodicTxPtrnParams: tx ptrn params
9047 *
9048 * Retrun: CDF status
9049 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309050static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309051 struct periodic_tx_pattern *
9052 pAddPeriodicTxPtrnParams,
9053 uint8_t vdev_id)
9054{
9055 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9056 wmi_buf_t wmi_buf;
9057 uint32_t len;
9058 uint8_t *buf_ptr;
9059 uint32_t ptrn_len, ptrn_len_aligned;
9060 int j;
9061
9062 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9063 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9064 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9065 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9066
9067 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9068 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309069 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9070 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 }
9072
9073 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9074
9075 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9076 WMITLV_SET_HDR(&cmd->tlv_header,
9077 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9078 WMITLV_GET_STRUCT_TLVLEN
9079 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9080
9081 /* Pass the pattern id to delete for the corresponding vdev id */
9082 cmd->vdev_id = vdev_id;
9083 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9084 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9085 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9086
9087 /* Pattern info */
9088 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9089 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9090 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309091 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309092 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309093 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309094
Govind Singhb53420c2016-03-09 14:32:57 +05309095 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309096 __func__, cmd->pattern_id, cmd->vdev_id);
9097
9098 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9099 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309100 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309101 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309102 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309103 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 }
Govind Singhb53420c2016-03-09 14:32:57 +05309105 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309106}
9107
9108/**
9109 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9110 * @wmi_handle: wmi handle
9111 * @vdev_id: vdev id
9112 * @pattern_id: pattern id
9113 *
9114 * Retrun: CDF status
9115 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309116static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309117 uint8_t vdev_id,
9118 uint8_t pattern_id)
9119{
9120 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9121 wmi_buf_t wmi_buf;
9122 uint32_t len =
9123 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9124
9125 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9126 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309127 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9128 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309129 }
9130
9131 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9132 wmi_buf_data(wmi_buf);
9133 WMITLV_SET_HDR(&cmd->tlv_header,
9134 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9135 WMITLV_GET_STRUCT_TLVLEN
9136 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9137
9138 /* Pass the pattern id to delete for the corresponding vdev id */
9139 cmd->vdev_id = vdev_id;
9140 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309141 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309142 __func__, cmd->pattern_id, cmd->vdev_id);
9143
9144 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9145 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309146 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309147 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309148 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309149 }
Govind Singhb53420c2016-03-09 14:32:57 +05309150 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309151}
9152
9153/**
9154 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9155 * @wmi_handle: wmi handle
9156 * @preq: stats ext params
9157 *
9158 * Return: CDF status
9159 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309160static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309161 struct stats_ext_params *preq)
9162{
Govind Singh67922e82016-04-01 16:48:57 +05309163 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309164 wmi_req_stats_ext_cmd_fixed_param *cmd;
9165 wmi_buf_t buf;
9166 uint16_t len;
9167 uint8_t *buf_ptr;
9168
9169 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9170
9171 buf = wmi_buf_alloc(wmi_handle, len);
9172 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309173 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309174 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 }
9176
9177 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9178 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9179
9180 WMITLV_SET_HDR(&cmd->tlv_header,
9181 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9182 WMITLV_GET_STRUCT_TLVLEN
9183 (wmi_req_stats_ext_cmd_fixed_param));
9184 cmd->vdev_id = preq->vdev_id;
9185 cmd->data_len = preq->request_data_len;
9186
Govind Singhb53420c2016-03-09 14:32:57 +05309187 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309188 __func__, preq->request_data_len, preq->vdev_id);
9189
9190 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9191 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9192
9193 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309194 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309195
9196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9197 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309198 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309199 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309200 ret);
9201 wmi_buf_free(buf);
9202 }
9203
9204 return ret;
9205}
9206
9207/**
9208 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9209 * @wmi_handle: wmi handle
9210 * @params: ext wow params
9211 *
9212 * Return:0 for success or error code
9213 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309214static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309215 struct ext_wow_params *params)
9216{
9217 wmi_extwow_enable_cmd_fixed_param *cmd;
9218 wmi_buf_t buf;
9219 int32_t len;
9220 int ret;
9221
9222 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9223 buf = wmi_buf_alloc(wmi_handle, len);
9224 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309225 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9226 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309227 }
9228
9229 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9230
9231 WMITLV_SET_HDR(&cmd->tlv_header,
9232 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9233 WMITLV_GET_STRUCT_TLVLEN
9234 (wmi_extwow_enable_cmd_fixed_param));
9235
9236 cmd->vdev_id = params->vdev_id;
9237 cmd->type = params->type;
9238 cmd->wakeup_pin_num = params->wakeup_pin_num;
9239
Govind Singhb53420c2016-03-09 14:32:57 +05309240 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309241 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9242
9243 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9244 WMI_EXTWOW_ENABLE_CMDID);
9245 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309246 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309247 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309248 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309249 }
9250
Govind Singhb53420c2016-03-09 14:32:57 +05309251 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309252
9253}
9254
9255/**
9256 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9257 * @wmi_handle: wmi handle
9258 * @app_type1_params: app type1 params
9259 *
9260 * Return: CDF status
9261 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309262static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309263 struct app_type1_params *app_type1_params)
9264{
9265 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9266 wmi_buf_t buf;
9267 int32_t len;
9268 int ret;
9269
9270 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9271 buf = wmi_buf_alloc(wmi_handle, len);
9272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309273 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9274 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309275 }
9276
9277 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9278 wmi_buf_data(buf);
9279
9280 WMITLV_SET_HDR(&cmd->tlv_header,
9281 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9282 WMITLV_GET_STRUCT_TLVLEN
9283 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9284
9285 cmd->vdev_id = app_type1_params->vdev_id;
9286 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9287 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309288 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309289 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309290 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309291 cmd->passwd_len = app_type1_params->pass_length;
9292
Govind Singhb53420c2016-03-09 14:32:57 +05309293 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309294 "identification_id %.8s id_length %u "
9295 "password %.16s pass_length %u",
9296 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9297 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9298
9299 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9300 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9301 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309302 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309303 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309304 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309305 }
9306
Govind Singhb53420c2016-03-09 14:32:57 +05309307 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309308}
9309
9310/**
9311 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9312 * @wmi_handle: wmi handle
9313 * @appType2Params: app type2 params
9314 *
9315 * Return: CDF status
9316 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309317static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309318 struct app_type2_params *appType2Params)
9319{
9320 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9321 wmi_buf_t buf;
9322 int32_t len;
9323 int ret;
9324
9325 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9326 buf = wmi_buf_alloc(wmi_handle, len);
9327 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309328 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9329 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309330 }
9331
9332 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9333 wmi_buf_data(buf);
9334
9335 WMITLV_SET_HDR(&cmd->tlv_header,
9336 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9337 WMITLV_GET_STRUCT_TLVLEN
9338 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9339
9340 cmd->vdev_id = appType2Params->vdev_id;
9341
Govind Singhb53420c2016-03-09 14:32:57 +05309342 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309343 cmd->rc4_key_len = appType2Params->rc4_key_len;
9344
9345 cmd->ip_id = appType2Params->ip_id;
9346 cmd->ip_device_ip = appType2Params->ip_device_ip;
9347 cmd->ip_server_ip = appType2Params->ip_server_ip;
9348
9349 cmd->tcp_src_port = appType2Params->tcp_src_port;
9350 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9351 cmd->tcp_seq = appType2Params->tcp_seq;
9352 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9353
9354 cmd->keepalive_init = appType2Params->keepalive_init;
9355 cmd->keepalive_min = appType2Params->keepalive_min;
9356 cmd->keepalive_max = appType2Params->keepalive_max;
9357 cmd->keepalive_inc = appType2Params->keepalive_inc;
9358
9359 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9360 &cmd->gateway_mac);
9361 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9362 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9363
Govind Singhb53420c2016-03-09 14:32:57 +05309364 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309365 "rc4_key %.16s rc4_key_len %u "
9366 "ip_id %x ip_device_ip %x ip_server_ip %x "
9367 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9368 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9369 "keepalive_max %u keepalive_inc %u "
9370 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9371 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9372 cmd->rc4_key, cmd->rc4_key_len,
9373 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9374 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9375 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9376 cmd->keepalive_max, cmd->keepalive_inc,
9377 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9378
9379 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9380 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9381 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309382 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309383 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309384 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309385 }
9386
Govind Singhb53420c2016-03-09 14:32:57 +05309387 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309388
9389}
9390
9391/**
9392 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9393 * @wmi_handle: wmi handle
9394 * @timer_val: auto shutdown timer value
9395 *
9396 * Return: CDF status
9397 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309398static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309399 uint32_t timer_val)
9400{
Govind Singh67922e82016-04-01 16:48:57 +05309401 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309402 wmi_buf_t buf = NULL;
9403 uint8_t *buf_ptr;
9404 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9405 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9406
Govind Singhb53420c2016-03-09 14:32:57 +05309407 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309408 __func__, timer_val);
9409
9410 buf = wmi_buf_alloc(wmi_handle, len);
9411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309412 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9413 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309414 }
9415
9416 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9417 wmi_auto_sh_cmd =
9418 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9419 wmi_auto_sh_cmd->timer_value = timer_val;
9420
9421 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9422 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9423 WMITLV_GET_STRUCT_TLVLEN
9424 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9425
9426 status = wmi_unified_cmd_send(wmi_handle, buf,
9427 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309428 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309429 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309430 __func__, status);
9431 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309432 }
9433
Govind Singh67922e82016-04-01 16:48:57 +05309434 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309435}
9436
9437/**
9438 * send_nan_req_cmd_tlv() - to send nan request to target
9439 * @wmi_handle: wmi handle
9440 * @nan_req: request data which will be non-null
9441 *
9442 * Return: CDF status
9443 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309444static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309445 struct nan_req_params *nan_req)
9446{
Govind Singh67922e82016-04-01 16:48:57 +05309447 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309448 wmi_nan_cmd_param *cmd;
9449 wmi_buf_t buf;
9450 uint16_t len = sizeof(*cmd);
9451 uint16_t nan_data_len, nan_data_len_aligned;
9452 uint8_t *buf_ptr;
9453
9454 /*
9455 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9456 * +------------+----------+-----------------------+--------------+
9457 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9458 * +------------+----------+-----------------------+--------------+
9459 */
9460 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309461 WMI_LOGE("%s:nan req is not valid", __func__);
9462 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309463 }
9464 nan_data_len = nan_req->request_data_len;
9465 nan_data_len_aligned = roundup(nan_req->request_data_len,
9466 sizeof(uint32_t));
9467 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9468 buf = wmi_buf_alloc(wmi_handle, len);
9469 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309470 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9471 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 }
9473 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9474 cmd = (wmi_nan_cmd_param *) buf_ptr;
9475 WMITLV_SET_HDR(&cmd->tlv_header,
9476 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9477 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9478 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309479 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309480 __func__, nan_req->request_data_len);
9481 buf_ptr += sizeof(wmi_nan_cmd_param);
9482 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9483 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309484 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309485
9486 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9487 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309488 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309489 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309490 __func__, ret);
9491 wmi_buf_free(buf);
9492 }
9493
9494 return ret;
9495}
9496
9497/**
9498 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9499 * @wmi_handle: wmi handle
9500 * @pDhcpSrvOffloadInfo: DHCP server offload info
9501 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309502 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309503 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309504static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309505 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9506{
9507 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9508 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309509 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309510
9511 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9512 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309513 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309514 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309515 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309516 }
9517
9518 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309519 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309520
9521 WMITLV_SET_HDR(&cmd->tlv_header,
9522 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9523 WMITLV_GET_STRUCT_TLVLEN
9524 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9525 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9526 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9527 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9528 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9529 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309530 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309531 sizeof(*cmd),
9532 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309533 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309534 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309535 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309536 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309537 }
Govind Singhb53420c2016-03-09 14:32:57 +05309538 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309540
9541 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309542}
9543
9544/**
9545 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9546 * @wmi_handle: wmi handle
9547 * @flashing: flashing request
9548 *
9549 * Return: CDF status
9550 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309551static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309552 struct flashing_req_params *flashing)
9553{
9554 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309555 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309556 wmi_buf_t buf;
9557 uint8_t *buf_ptr;
9558 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9559
9560 buf = wmi_buf_alloc(wmi_handle, len);
9561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309562 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309563 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309564 }
9565 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9566 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9567 WMITLV_SET_HDR(&cmd->tlv_header,
9568 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9569 WMITLV_GET_STRUCT_TLVLEN
9570 (wmi_set_led_flashing_cmd_fixed_param));
9571 cmd->pattern_id = flashing->pattern_id;
9572 cmd->led_x0 = flashing->led_x0;
9573 cmd->led_x1 = flashing->led_x1;
9574
9575 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9576 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309577 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309578 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309579 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309580 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309581 }
Govind Singh67922e82016-04-01 16:48:57 +05309582
9583 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309584}
9585
9586/**
9587 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9588 * @wmi_handle: wmi handle
9589 * @ch_avoid_update_req: channel avoid update params
9590 *
9591 * Return: CDF status
9592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309593static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309594{
Govind Singh67922e82016-04-01 16:48:57 +05309595 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309596 wmi_buf_t buf = NULL;
9597 uint8_t *buf_ptr;
9598 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9599 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9600
9601
9602 buf = wmi_buf_alloc(wmi_handle, len);
9603 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309604 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9605 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309606 }
9607
9608 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9609 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9610 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9611 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9612 WMITLV_GET_STRUCT_TLVLEN
9613 (wmi_chan_avoid_update_cmd_param));
9614
9615 status = wmi_unified_cmd_send(wmi_handle, buf,
9616 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309617 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309618 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309619 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9620 " returned Error %d", status);
9621 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309622 }
9623
Govind Singh67922e82016-04-01 16:48:57 +05309624 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309625}
9626
9627/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309628 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9629 * @wmi_handle: wmi handle
9630 * @param: pointer to pdev regdomain params
9631 *
9632 * Return: 0 for success or error code
9633 */
9634static QDF_STATUS
9635send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9636 struct pdev_set_regdomain_params *param)
9637{
9638 wmi_buf_t buf;
9639 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9640 int32_t len = sizeof(*cmd);
9641
9642
9643 buf = wmi_buf_alloc(wmi_handle, len);
9644 if (!buf) {
9645 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9646 return QDF_STATUS_E_NOMEM;
9647 }
9648 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9649 WMITLV_SET_HDR(&cmd->tlv_header,
9650 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9651 WMITLV_GET_STRUCT_TLVLEN
9652 (wmi_pdev_set_regdomain_cmd_fixed_param));
9653
9654 cmd->reg_domain = param->currentRDinuse;
9655 cmd->reg_domain_2G = param->currentRD2G;
9656 cmd->reg_domain_5G = param->currentRD5G;
9657 cmd->conformance_test_limit_2G = param->ctl_2G;
9658 cmd->conformance_test_limit_5G = param->ctl_5G;
9659 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309660 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9661 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309662
9663 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9664 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9665 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9666 __func__);
9667 wmi_buf_free(buf);
9668 return QDF_STATUS_E_FAILURE;
9669 }
9670
9671 return QDF_STATUS_SUCCESS;
9672}
9673
9674/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309675 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9676 * @wmi_handle: wmi handle
9677 * @reg_dmn: reg domain
9678 * @regdmn2G: 2G reg domain
9679 * @regdmn5G: 5G reg domain
9680 * @ctl2G: 2G test limit
9681 * @ctl5G: 5G test limit
9682 *
9683 * Return: none
9684 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309685static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309686 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309687 uint16_t regdmn5G, uint8_t ctl2G,
9688 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309689{
9690 wmi_buf_t buf;
9691 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9692 int32_t len = sizeof(*cmd);
9693
9694
9695 buf = wmi_buf_alloc(wmi_handle, len);
9696 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309697 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9698 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309699 }
9700 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9701 WMITLV_SET_HDR(&cmd->tlv_header,
9702 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9703 WMITLV_GET_STRUCT_TLVLEN
9704 (wmi_pdev_set_regdomain_cmd_fixed_param));
9705 cmd->reg_domain = reg_dmn;
9706 cmd->reg_domain_2G = regdmn2G;
9707 cmd->reg_domain_5G = regdmn5G;
9708 cmd->conformance_test_limit_2G = ctl2G;
9709 cmd->conformance_test_limit_5G = ctl5G;
9710
9711 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9712 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309713 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309714 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309715 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309716 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309717 }
9718
Govind Singhb53420c2016-03-09 14:32:57 +05309719 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309720}
9721
9722
9723/**
9724 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9725 * @wmi_handle: wmi handle
9726 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9727 *
9728 * This function sets tdls off channel mode
9729 *
9730 * Return: 0 on success; Negative errno otherwise
9731 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309732static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309733 struct tdls_channel_switch_params *chan_switch_params)
9734{
9735 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9736 wmi_buf_t wmi_buf;
9737 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9738
9739 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9740 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309741 WMI_LOGE(FL("wmi_buf_alloc failed"));
9742 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309743 }
9744 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9745 wmi_buf_data(wmi_buf);
9746 WMITLV_SET_HDR(&cmd->tlv_header,
9747 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9748 WMITLV_GET_STRUCT_TLVLEN(
9749 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9750
9751 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9752 &cmd->peer_macaddr);
9753 cmd->vdev_id = chan_switch_params->vdev_id;
9754 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9755 cmd->is_peer_responder = chan_switch_params->is_responder;
9756 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9757 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9758 cmd->offchan_oper_class = chan_switch_params->oper_class;
9759
Govind Singhb53420c2016-03-09 14:32:57 +05309760 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309761 cmd->peer_macaddr.mac_addr31to0,
9762 cmd->peer_macaddr.mac_addr47to32);
9763
Govind Singhb53420c2016-03-09 14:32:57 +05309764 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309765 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9766 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9767 ),
9768 cmd->vdev_id,
9769 cmd->offchan_mode,
9770 cmd->offchan_num,
9771 cmd->offchan_bw_bitmap,
9772 cmd->is_peer_responder,
9773 cmd->offchan_oper_class);
9774
9775 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9776 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309777 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309778 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309779 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309780 }
9781
9782
Govind Singhb53420c2016-03-09 14:32:57 +05309783 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309784}
9785
9786/**
9787 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9788 * @wmi_handle: wmi handle
9789 * @pwmaTdlsparams: TDLS params
9790 *
9791 * Return: 0 for sucess or error code
9792 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309793static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309794 void *tdls_param, uint8_t tdls_state)
9795{
9796 wmi_tdls_set_state_cmd_fixed_param *cmd;
9797 wmi_buf_t wmi_buf;
9798
9799 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9800 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9801
9802 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9803 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309804 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9805 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309806 }
9807 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9808 WMITLV_SET_HDR(&cmd->tlv_header,
9809 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9810 WMITLV_GET_STRUCT_TLVLEN
9811 (wmi_tdls_set_state_cmd_fixed_param));
9812 cmd->vdev_id = wmi_tdls->vdev_id;
9813 cmd->state = tdls_state;
9814 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9815 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9816 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9817 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9818 cmd->rssi_delta = wmi_tdls->rssi_delta;
9819 cmd->tdls_options = wmi_tdls->tdls_options;
9820 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9821 cmd->tdls_peer_traffic_response_timeout_ms =
9822 wmi_tdls->peer_traffic_response_timeout;
9823 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9824 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9825 cmd->tdls_puapsd_rx_frame_threshold =
9826 wmi_tdls->puapsd_rx_frame_threshold;
9827 cmd->teardown_notification_ms =
9828 wmi_tdls->teardown_notification_ms;
9829 cmd->tdls_peer_kickout_threshold =
9830 wmi_tdls->tdls_peer_kickout_threshold;
9831
Govind Singhb53420c2016-03-09 14:32:57 +05309832 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309833 "notification_interval_ms: %d, "
9834 "tx_discovery_threshold: %d, "
9835 "tx_teardown_threshold: %d, "
9836 "rssi_teardown_threshold: %d, "
9837 "rssi_delta: %d, "
9838 "tdls_options: 0x%x, "
9839 "tdls_peer_traffic_ind_window: %d, "
9840 "tdls_peer_traffic_response_timeout: %d, "
9841 "tdls_puapsd_mask: 0x%x, "
9842 "tdls_puapsd_inactivity_time: %d, "
9843 "tdls_puapsd_rx_frame_threshold: %d, "
9844 "teardown_notification_ms: %d, "
9845 "tdls_peer_kickout_threshold: %d",
9846 __func__, tdls_state, cmd->state,
9847 cmd->notification_interval_ms,
9848 cmd->tx_discovery_threshold,
9849 cmd->tx_teardown_threshold,
9850 cmd->rssi_teardown_threshold,
9851 cmd->rssi_delta,
9852 cmd->tdls_options,
9853 cmd->tdls_peer_traffic_ind_window,
9854 cmd->tdls_peer_traffic_response_timeout_ms,
9855 cmd->tdls_puapsd_mask,
9856 cmd->tdls_puapsd_inactivity_time_ms,
9857 cmd->tdls_puapsd_rx_frame_threshold,
9858 cmd->teardown_notification_ms,
9859 cmd->tdls_peer_kickout_threshold);
9860
9861 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9862 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309863 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309864 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309865 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309866 }
Govind Singhb53420c2016-03-09 14:32:57 +05309867 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309868
Govind Singhb53420c2016-03-09 14:32:57 +05309869 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309870}
9871
9872/**
9873 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9874 * @wmi_handle: wmi handle
9875 * @peerStateParams: TDLS peer state params
9876 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309877 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309878 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309879static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309880 struct tdls_peer_state_params *peerStateParams,
9881 uint32_t *ch_mhz)
9882{
9883 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9884 wmi_tdls_peer_capabilities *peer_cap;
9885 wmi_channel *chan_info;
9886 wmi_buf_t wmi_buf;
9887 uint8_t *buf_ptr;
9888 uint32_t i;
9889 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9890 sizeof(wmi_tdls_peer_capabilities);
9891
9892
9893 len += WMI_TLV_HDR_SIZE +
9894 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9895
9896 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9897 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309898 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9899 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309900 }
9901
9902 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9903 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9904 WMITLV_SET_HDR(&cmd->tlv_header,
9905 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9906 WMITLV_GET_STRUCT_TLVLEN
9907 (wmi_tdls_peer_update_cmd_fixed_param));
9908
9909 cmd->vdev_id = peerStateParams->vdevId;
9910 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9911 &cmd->peer_macaddr);
9912
9913
9914 cmd->peer_state = peerStateParams->peerState;
9915
Govind Singhb53420c2016-03-09 14:32:57 +05309916 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309917 "peer_macaddr.mac_addr31to0: 0x%x, "
9918 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9919 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9920 cmd->peer_macaddr.mac_addr31to0,
9921 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9922
9923 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9924 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9925 WMITLV_SET_HDR(&peer_cap->tlv_header,
9926 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9927 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9928
9929 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9930 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9931 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9932 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9933 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9934 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9935 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9936 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9937
9938 /* Ack and More Data Ack are sent as 0, so no need to set
9939 * but fill SP
9940 */
9941 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9942 peerStateParams->peerCap.peerMaxSp);
9943
9944 peer_cap->buff_sta_support =
9945 peerStateParams->peerCap.peerBuffStaSupport;
9946 peer_cap->off_chan_support =
9947 peerStateParams->peerCap.peerOffChanSupport;
9948 peer_cap->peer_curr_operclass =
9949 peerStateParams->peerCap.peerCurrOperClass;
9950 /* self curr operclass is not being used and so pass op class for
9951 * preferred off chan in it.
9952 */
9953 peer_cap->self_curr_operclass =
9954 peerStateParams->peerCap.opClassForPrefOffChan;
9955 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9956 peer_cap->peer_operclass_len =
9957 peerStateParams->peerCap.peerOperClassLen;
9958
Govind Singhb53420c2016-03-09 14:32:57 +05309959 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309960 __func__, peer_cap->peer_operclass_len);
9961 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9962 peer_cap->peer_operclass[i] =
9963 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309964 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309965 __func__, i, peer_cap->peer_operclass[i]);
9966 }
9967
9968 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9969 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9970 peer_cap->pref_offchan_bw =
9971 peerStateParams->peerCap.prefOffChanBandwidth;
9972
Govind Singhb53420c2016-03-09 14:32:57 +05309973 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309974 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9975 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9976 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9977 " %d, pref_offchan_bw: %d",
9978 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9979 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9980 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9981 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9982 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9983
9984 /* next fill variable size array of peer chan info */
9985 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9986 WMITLV_SET_HDR(buf_ptr,
9987 WMITLV_TAG_ARRAY_STRUC,
9988 sizeof(wmi_channel) *
9989 peerStateParams->peerCap.peerChanLen);
9990 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9991
9992 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9993 WMITLV_SET_HDR(&chan_info->tlv_header,
9994 WMITLV_TAG_STRUC_wmi_channel,
9995 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9996 chan_info->mhz = ch_mhz[i];
9997 chan_info->band_center_freq1 = chan_info->mhz;
9998 chan_info->band_center_freq2 = 0;
9999
Govind Singhb53420c2016-03-09 14:32:57 +053010000 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010001
10002 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10003 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010004 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010005 peerStateParams->peerCap.peerChan[i].chanId,
10006 peerStateParams->peerCap.peerChan[i].dfsSet);
10007 }
10008
10009 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10010 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10011 else
10012 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10013
10014 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10015 peerStateParams->peerCap.
10016 peerChan[i].pwr);
10017
10018 WMI_SET_CHANNEL_REG_POWER(chan_info,
10019 peerStateParams->peerCap.peerChan[i].
10020 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010021 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010022 peerStateParams->peerCap.peerChan[i].pwr);
10023
10024 chan_info++;
10025 }
10026
10027 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10028 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010029 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010030 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010031 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010032 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010033 }
10034
10035
Govind Singhb53420c2016-03-09 14:32:57 +053010036 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010037}
10038
10039/*
10040 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
10041 * firmware
10042 * @wmi_handle: Pointer to wmi handle
10043 * @mem_dump_req: Pointer for mem_dump_req
10044 *
10045 * This function sends memory dump request to firmware
10046 *
Govind Singhb53420c2016-03-09 14:32:57 +053010047 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010048 *
10049 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010050static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010051 struct fw_dump_req_param *mem_dump_req)
10052{
10053 wmi_get_fw_mem_dump_fixed_param *cmd;
10054 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +053010055 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +053010056 int32_t len;
10057 wmi_buf_t buf;
10058 u_int8_t *buf_ptr;
10059 int ret, loop;
10060
10061 /*
10062 * len = sizeof(fixed param) that includes tlv header +
10063 * tlv header for array of struc +
10064 * sizeof (each struct)
10065 */
10066 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10067 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
10068 buf = wmi_buf_alloc(wmi_handle, len);
10069
10070 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010071 WMI_LOGE(FL("Failed allocate wmi buffer"));
10072 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010073 }
10074
10075 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010076 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010077 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
10078
10079 WMITLV_SET_HDR(&cmd->tlv_header,
10080 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
10081 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
10082
10083 cmd->request_id = mem_dump_req->request_id;
10084 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
10085
10086 /* TLV indicating array of structures to follow */
10087 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
10088 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10089 sizeof(wmi_fw_mem_dump) *
10090 cmd->num_fw_mem_dump_segs);
10091
10092 buf_ptr += WMI_TLV_HDR_SIZE;
10093 dump_params = (wmi_fw_mem_dump *) buf_ptr;
10094
Govind Singhb53420c2016-03-09 14:32:57 +053010095 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010096 mem_dump_req->request_id, mem_dump_req->num_seg);
10097 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +053010098 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +053010099 ((uint8_t *)(mem_dump_req->segment) +
10100 loop * sizeof(*seg_req));
10101 WMITLV_SET_HDR(&dump_params->tlv_header,
10102 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
10103 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
10104 dump_params->seg_id = seg_req->seg_id;
10105 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
10106 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
10107 dump_params->seg_length = seg_req->seg_length;
10108 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
10109 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +053010110 WMI_LOGI(FL("seg_number:%d"), loop);
10111 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010112 dump_params->seg_id, dump_params->seg_start_addr_lo,
10113 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +053010114 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010115 dump_params->seg_length, dump_params->dest_addr_lo,
10116 dump_params->dest_addr_hi);
10117 dump_params++;
10118 }
10119
10120 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10121 WMI_GET_FW_MEM_DUMP_CMDID);
10122 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010123 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +053010124 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010125 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010126 }
10127
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
10129 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010130}
10131
10132/*
10133 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10134 * @wmi_handle: Pointer to WMi handle
10135 * @ie_data: Pointer for ie data
10136 *
10137 * This function sends IE information to firmware
10138 *
Govind Singhb53420c2016-03-09 14:32:57 +053010139 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010140 *
10141 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010142static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010143 struct vdev_ie_info_param *ie_info)
10144{
10145 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10146 wmi_buf_t buf;
10147 uint8_t *buf_ptr;
10148 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010149 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010150
10151
10152 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10153 /* Allocate memory for the WMI command */
10154 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10155
10156 buf = wmi_buf_alloc(wmi_handle, len);
10157 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010158 WMI_LOGE(FL("wmi_buf_alloc failed"));
10159 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010160 }
10161
10162 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010163 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010164
10165 /* Populate the WMI command */
10166 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10167
10168 WMITLV_SET_HDR(&cmd->tlv_header,
10169 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10170 WMITLV_GET_STRUCT_TLVLEN(
10171 wmi_vdev_set_ie_cmd_fixed_param));
10172 cmd->vdev_id = ie_info->vdev_id;
10173 cmd->ie_id = ie_info->ie_id;
10174 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010175 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010176
Govind Singhb53420c2016-03-09 14:32:57 +053010177 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010178 ie_info->length, ie_info->vdev_id);
10179
10180 buf_ptr += sizeof(*cmd);
10181 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10182 buf_ptr += WMI_TLV_HDR_SIZE;
10183
Govind Singhb53420c2016-03-09 14:32:57 +053010184 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010185
10186 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10187 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010188 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010189 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010190 wmi_buf_free(buf);
10191 }
10192
10193 return ret;
10194}
10195
Sathish Kumar497bef42017-03-01 14:02:36 +053010196/**
10197 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10198 *
10199 * @param wmi_handle : handle to WMI.
10200 * @param param : pointer to antenna param
10201 *
10202 * This function sends smart antenna enable command to FW
10203 *
10204 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10205 */
10206static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10207 struct smart_ant_enable_params *param)
10208{
10209 /* Send WMI COMMAND to Enable */
10210 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10211 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10212 wmi_buf_t buf;
10213 uint8_t *buf_ptr;
10214 int len = 0;
10215 QDF_STATUS ret;
10216 int loop = 0;
10217
10218 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10219 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10220 buf = wmi_buf_alloc(wmi_handle, len);
10221
10222 if (!buf) {
10223 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10224 return QDF_STATUS_E_NOMEM;
10225 }
10226
10227 buf_ptr = wmi_buf_data(buf);
10228 qdf_mem_zero(buf_ptr, len);
10229 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10230
10231 WMITLV_SET_HDR(&cmd->tlv_header,
10232 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10233 WMITLV_GET_STRUCT_TLVLEN(
10234 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10235
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010236 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10237 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010238 cmd->enable = param->enable;
10239 cmd->mode = param->mode;
10240 cmd->rx_antenna = param->rx_antenna;
10241 cmd->tx_default_antenna = param->rx_antenna;
10242
10243 /* TLV indicating array of structures to follow */
10244 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10245 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10246 WMI_HAL_MAX_SANTENNA *
10247 sizeof(wmi_pdev_smart_ant_gpio_handle));
10248
10249 buf_ptr += WMI_TLV_HDR_SIZE;
10250 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10251
10252 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10253 WMITLV_SET_HDR(&gpio_param->tlv_header,
10254 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10255 WMITLV_GET_STRUCT_TLVLEN(
10256 wmi_pdev_smart_ant_gpio_handle));
10257 if (param->mode == SMART_ANT_MODE_SERIAL) {
10258 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10259 gpio_param->gpio_pin = param->gpio_pin[loop];
10260 gpio_param->gpio_func = param->gpio_func[loop];
10261 } else {
10262 gpio_param->gpio_pin = 0;
10263 gpio_param->gpio_func = 0;
10264 }
10265 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10266 gpio_param->gpio_pin = param->gpio_pin[loop];
10267 gpio_param->gpio_func = param->gpio_func[loop];
10268 }
10269 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010270 gpio_param->pdev_id =
10271 wmi_handle->ops->convert_pdev_id_host_to_target(
10272 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010273 gpio_param++;
10274 }
10275
10276 ret = wmi_unified_cmd_send(wmi_handle,
10277 buf,
10278 len,
10279 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10280
10281 if (ret != 0) {
10282 WMI_LOGE(" %s :WMI Failed\n", __func__);
10283 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10284 cmd->enable,
10285 cmd->mode,
10286 cmd->rx_antenna,
10287 param->gpio_pin[0], param->gpio_pin[1],
10288 param->gpio_pin[2], param->gpio_pin[3],
10289 param->gpio_func[0], param->gpio_func[1],
10290 param->gpio_func[2], param->gpio_func[3],
10291 ret);
10292 wmi_buf_free(buf);
10293 }
10294
10295 return ret;
10296}
10297
10298/**
10299 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10300 *
10301 * @param wmi_handle : handle to WMI.
10302 * @param param : pointer to rx antenna param
10303 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10304 */
10305static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10306 struct smart_ant_rx_ant_params *param)
10307{
10308 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10309 wmi_buf_t buf;
10310 uint8_t *buf_ptr;
10311 uint32_t len;
10312 QDF_STATUS ret;
10313
10314 len = sizeof(*cmd);
10315 buf = wmi_buf_alloc(wmi_handle, len);
10316 WMI_LOGD("%s:\n", __func__);
10317 if (!buf) {
10318 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10319 return QDF_STATUS_E_NOMEM;
10320 }
10321
10322 buf_ptr = wmi_buf_data(buf);
10323 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10324 WMITLV_SET_HDR(&cmd->tlv_header,
10325 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10326 WMITLV_GET_STRUCT_TLVLEN(
10327 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10328 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010329 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10330 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010331
10332 ret = wmi_unified_cmd_send(wmi_handle,
10333 buf,
10334 len,
10335 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10336
10337 if (ret != 0) {
10338 WMI_LOGE(" %s :WMI Failed\n", __func__);
10339 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10340 __func__,
10341 cmd->rx_antenna,
10342 ret);
10343 wmi_buf_free(buf);
10344 }
10345
10346 return ret;
10347}
10348
10349/**
10350 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10351 * @wmi_handle: wmi handle
10352 * @param: pointer to hold ctl table param
10353 *
10354 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10355 */
10356static QDF_STATUS
10357send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10358 struct ctl_table_params *param)
10359{
10360 uint16_t len, ctl_tlv_len;
10361 uint8_t *buf_ptr;
10362 wmi_buf_t buf;
10363 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10364 uint32_t *ctl_array;
10365
10366 if (!param->ctl_array)
10367 return QDF_STATUS_E_FAILURE;
10368
10369 if (param->ctl_cmd_len !=
10370 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10371 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
10372 qdf_print("CTL array len not correct\n");
10373 return QDF_STATUS_E_FAILURE;
10374 }
10375
10376 ctl_tlv_len = WMI_TLV_HDR_SIZE +
10377 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
10378 len = sizeof(*cmd) + ctl_tlv_len;
10379
10380 buf = wmi_buf_alloc(wmi_handle, len);
10381 if (!buf) {
10382 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10383 return QDF_STATUS_E_FAILURE;
10384 }
10385
10386 buf_ptr = wmi_buf_data(buf);
10387 qdf_mem_zero(buf_ptr, len);
10388
10389 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10390
10391 WMITLV_SET_HDR(&cmd->tlv_header,
10392 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10393 WMITLV_GET_STRUCT_TLVLEN(
10394 wmi_pdev_set_ctl_table_cmd_fixed_param));
10395 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010396 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10397 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010398
10399 buf_ptr += sizeof(*cmd);
10400 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10401 (cmd->ctl_len));
10402 buf_ptr += WMI_TLV_HDR_SIZE;
10403 ctl_array = (uint32_t *)buf_ptr;
10404
10405 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10406 sizeof(param->ctl_band));
10407 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10408 param->ctl_cmd_len -
10409 sizeof(param->ctl_band));
10410
10411 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10412 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10413 WMI_LOGE("%s:Failed to send command\n", __func__);
10414 wmi_buf_free(buf);
10415 return QDF_STATUS_E_FAILURE;
10416 }
10417
10418 return QDF_STATUS_SUCCESS;
10419}
10420
10421/**
10422 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10423 * @wmi_handle: wmi handle
10424 * @param: pointer to hold mimogain table param
10425 *
10426 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10427 */
10428static QDF_STATUS
10429send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10430 struct mimogain_table_params *param)
10431{
10432 uint16_t len, table_tlv_len;
10433 wmi_buf_t buf;
10434 uint8_t *buf_ptr;
10435 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10436 uint32_t *gain_table;
10437
10438 if (!param->array_gain)
10439 return QDF_STATUS_E_FAILURE;
10440
10441 /* len must be multiple of a single array gain table */
10442 if (param->tbl_len %
10443 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10444 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10445 WMI_LOGE("Array gain table len not correct\n");
10446 return QDF_STATUS_E_FAILURE;
10447 }
10448
10449 table_tlv_len = WMI_TLV_HDR_SIZE +
10450 roundup(param->tbl_len, sizeof(uint32_t));
10451 len = sizeof(*cmd) + table_tlv_len;
10452
10453 buf = wmi_buf_alloc(wmi_handle, len);
10454 if (!buf) {
10455 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10456 return QDF_STATUS_E_FAILURE;
10457 }
10458
10459 buf_ptr = wmi_buf_data(buf);
10460 qdf_mem_zero(buf_ptr, len);
10461
10462 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10463
10464 WMITLV_SET_HDR(&cmd->tlv_header,
10465 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10466 WMITLV_GET_STRUCT_TLVLEN(
10467 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10468
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010469 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10470 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010471 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10472 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10473 param->multichain_gain_bypass);
10474
10475 buf_ptr += sizeof(*cmd);
10476 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10477 (param->tbl_len));
10478 buf_ptr += WMI_TLV_HDR_SIZE;
10479 gain_table = (uint32_t *)buf_ptr;
10480
10481 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10482 param->array_gain,
10483 param->tbl_len);
10484
10485 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10486 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10487 return QDF_STATUS_E_FAILURE;
10488 }
10489
10490 return QDF_STATUS_SUCCESS;
10491}
10492
10493/**
10494 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10495 * info to fw
10496 * @wmi_handle: wmi handle
10497 * @param: pointer to hold packet power info param
10498 *
10499 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10500 */
10501static QDF_STATUS
10502send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10503 struct packet_power_info_params *param)
10504{
10505 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10506 wmi_buf_t wmibuf;
10507 uint8_t *buf_ptr;
10508 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10509
10510 wmibuf = wmi_buf_alloc(wmi_handle, len);
10511 if (wmibuf == NULL)
10512 return QDF_STATUS_E_NOMEM;
10513
10514 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10515
10516 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10517 WMITLV_SET_HDR(&cmd->tlv_header,
10518 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10519 WMITLV_GET_STRUCT_TLVLEN(
10520 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010521 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10522 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010523 cmd->rate_flags = param->rate_flags;
10524 cmd->nss = param->nss;
10525 cmd->preamble = param->preamble;
10526 cmd->hw_rate = param->hw_rate;
10527 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10528 __func__,
10529 __LINE__,
10530 WMI_PDEV_GET_TPC_CMDID,
10531 *((u_int32_t *)cmd));
10532 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10533 WMI_PDEV_GET_TPC_CMDID)) {
10534 WMI_LOGE(FL("Failed to get tpc command\n"));
10535 wmi_buf_free(wmibuf);
10536 return QDF_STATUS_E_FAILURE;
10537 }
10538
10539 return QDF_STATUS_SUCCESS;
10540}
10541
10542/**
10543 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10544 * @wmi_handle: wmi handle
10545 * @param: pointer to hold config ratemask params
10546 *
10547 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10548 */
10549static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10550 struct config_ratemask_params *param)
10551{
10552 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10553 wmi_buf_t buf;
10554 int32_t len = sizeof(*cmd);
10555
10556 buf = wmi_buf_alloc(wmi_handle, len);
10557 if (!buf) {
10558 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10559 return QDF_STATUS_E_FAILURE;
10560 }
10561 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10562 WMITLV_SET_HDR(&cmd->tlv_header,
10563 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10564 WMITLV_GET_STRUCT_TLVLEN(
10565 wmi_vdev_config_ratemask_cmd_fixed_param));
10566 cmd->vdev_id = param->vdev_id;
10567 cmd->type = param->type;
10568 cmd->mask_lower32 = param->lower32;
10569 cmd->mask_higher32 = param->higher32;
10570 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10571 param->vdev_id, param->type, param->lower32, param->higher32);
10572
10573 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10574 WMI_VDEV_RATEMASK_CMDID)) {
10575 WMI_LOGE("Seting vdev ratemask failed\n");
10576 wmi_buf_free(buf);
10577 return QDF_STATUS_E_FAILURE;
10578 }
10579
10580 return QDF_STATUS_SUCCESS;
10581}
10582
10583/**
10584 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10585 * @wmi_handle: wmi handle
10586 * @param: pointer to hold vap dscp tid map param
10587 *
10588 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10589 */
10590static QDF_STATUS
10591send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10592 struct vap_dscp_tid_map_params *param)
10593{
10594 wmi_buf_t buf;
10595 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10596 int32_t len = sizeof(*cmd);
10597
10598 buf = wmi_buf_alloc(wmi_handle, len);
10599 if (!buf) {
10600 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10601 return QDF_STATUS_E_FAILURE;
10602 }
10603
10604 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10605 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10606 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10607
10608 cmd->vdev_id = param->vdev_id;
10609 cmd->enable_override = 0;
10610
10611 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10612 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10613 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10614 WMI_LOGE("Failed to set dscp cmd\n");
10615 wmi_buf_free(buf);
10616 return QDF_STATUS_E_FAILURE;
10617 }
10618
10619 return QDF_STATUS_SUCCESS;
10620}
10621
10622/**
10623 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10624 * @wmi_handle: wmi handle
10625 * @macaddr: vdev mac address
10626 * @param: pointer to hold neigbour rx param
10627 *
10628 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10629 */
10630static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10631 uint8_t macaddr[IEEE80211_ADDR_LEN],
10632 struct set_neighbour_rx_params *param)
10633{
10634 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10635 wmi_buf_t buf;
10636 int32_t len = sizeof(*cmd);
10637
10638 buf = wmi_buf_alloc(wmi_handle, len);
10639 if (!buf) {
10640 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10641 return QDF_STATUS_E_FAILURE;
10642 }
10643 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10644 WMITLV_SET_HDR(&cmd->tlv_header,
10645 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10646 WMITLV_GET_STRUCT_TLVLEN(
10647 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10648 cmd->vdev_id = param->vdev_id;
10649 cmd->bssid_idx = param->idx;
10650 cmd->action = param->action;
10651 cmd->type = param->type;
10652 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10653 cmd->flag = 0;
10654
10655 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10656 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10657 WMI_LOGE("Failed to set neighbour rx param\n");
10658 wmi_buf_free(buf);
10659 return QDF_STATUS_E_FAILURE;
10660 }
10661
10662 return QDF_STATUS_SUCCESS;
10663}
10664
10665/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010666 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010667 * @param wmi_handle : handle to WMI.
10668 * @param macaddr : vdev mac address
10669 * @param param : pointer to tx antenna param
10670 *
10671 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10672 */
10673static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10674 uint8_t macaddr[IEEE80211_ADDR_LEN],
10675 struct smart_ant_tx_ant_params *param)
10676{
10677 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10678 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10679 wmi_buf_t buf;
10680 int32_t len = 0;
10681 int i;
10682 uint8_t *buf_ptr;
10683 QDF_STATUS ret;
10684
10685 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10686 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10687 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10688 buf = wmi_buf_alloc(wmi_handle, len);
10689
10690 if (!buf) {
10691 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10692 return QDF_STATUS_E_NOMEM;
10693 }
10694
10695 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10696 qdf_mem_zero(buf_ptr, len);
10697 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10698
10699 WMITLV_SET_HDR(&cmd->tlv_header,
10700 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10701 WMITLV_GET_STRUCT_TLVLEN(
10702 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10703
10704 cmd->vdev_id = param->vdev_id;
10705 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10706
10707 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10708 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10709 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10710 buf_ptr += WMI_TLV_HDR_SIZE;
10711 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10712
10713 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10714 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10715 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10716 WMITLV_GET_STRUCT_TLVLEN(
10717 wmi_peer_smart_ant_set_tx_antenna_series));
10718 ant_tx_series->antenna_series = param->antenna_array[i];
10719 ant_tx_series++;
10720 }
10721
10722 ret = wmi_unified_cmd_send(wmi_handle,
10723 buf,
10724 len,
10725 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10726
10727 if (ret != 0) {
10728 WMI_LOGE(" %s :WMI Failed\n", __func__);
10729 wmi_buf_free(buf);
10730 }
10731
10732 return ret;
10733}
10734
Sathish Kumar02c3b542017-02-22 17:24:45 +053010735/**
10736 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10737 * @wmi_handle: wmi handle
10738 * @param: pointer to hold ant switch tbl param
10739 *
10740 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10741 */
10742static QDF_STATUS
10743send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10744 struct ant_switch_tbl_params *param)
10745{
10746 uint8_t len;
10747 wmi_buf_t buf;
10748 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10749 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10750 uint8_t *buf_ptr;
10751
10752 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10753 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10754 buf = wmi_buf_alloc(wmi_handle, len);
10755
10756 if (!buf) {
10757 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10758 return QDF_STATUS_E_NOMEM;
10759 }
10760
10761 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10762 qdf_mem_zero(buf_ptr, len);
10763 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10764
10765 WMITLV_SET_HDR(&cmd->tlv_header,
10766 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10767 WMITLV_GET_STRUCT_TLVLEN(
10768 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10769
10770 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10771 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010772 cmd->mac_id =
10773 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010774
10775 /* TLV indicating array of structures to follow */
10776 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10777 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10778 sizeof(wmi_pdev_set_ant_ctrl_chain));
10779 buf_ptr += WMI_TLV_HDR_SIZE;
10780 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10781
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010782 ctrl_chain->pdev_id =
10783 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010784 ctrl_chain->antCtrlChain = param->antCtrlChain;
10785
10786 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10787 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10788 wmi_buf_free(buf);
10789 return QDF_STATUS_E_FAILURE;
10790 }
10791
10792 return QDF_STATUS_SUCCESS;
10793}
10794
10795/**
10796 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10797 * training information function
10798 * @param wmi_handle : handle to WMI.
10799 * @macaddr : vdev mac address
10800 * @param param : pointer to tx antenna param
10801 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10802 */
10803static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10804 wmi_unified_t wmi_handle,
10805 uint8_t macaddr[IEEE80211_ADDR_LEN],
10806 struct smart_ant_training_info_params *param)
10807{
10808 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10809 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10810 wmi_buf_t buf;
10811 uint8_t *buf_ptr;
10812 int32_t len = 0;
10813 QDF_STATUS ret;
10814 int loop;
10815
10816 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10817 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10818 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10819 buf = wmi_buf_alloc(wmi_handle, len);
10820
10821 if (!buf) {
10822 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10823 return QDF_STATUS_E_NOMEM;
10824 }
10825
10826 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10827 qdf_mem_zero(buf_ptr, len);
10828 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10829
10830 WMITLV_SET_HDR(&cmd->tlv_header,
10831 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10832 WMITLV_GET_STRUCT_TLVLEN(
10833 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10834
10835 cmd->vdev_id = param->vdev_id;
10836 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10837 cmd->num_pkts = param->numpkts;
10838
10839 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10840 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10841 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10842 WMI_SMART_ANT_MAX_RATE_SERIES);
10843
10844 buf_ptr += WMI_TLV_HDR_SIZE;
10845 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10846
10847 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10848 WMITLV_SET_HDR(&train_param->tlv_header,
10849 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10850 WMITLV_GET_STRUCT_TLVLEN(
10851 wmi_peer_smart_ant_set_train_antenna_param));
10852 train_param->train_rate_series = param->rate_array[loop];
10853 train_param->train_antenna_series = param->antenna_array[loop];
10854 train_param->rc_flags = 0;
10855 WMI_LOGI(FL("Series number:%d\n"), loop);
10856 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10857 train_param->train_rate_series,
10858 train_param->train_antenna_series);
10859 train_param++;
10860 }
10861
10862 ret = wmi_unified_cmd_send(wmi_handle,
10863 buf,
10864 len,
10865 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10866
10867 if (ret != 0) {
10868 WMI_LOGE(" %s :WMI Failed\n", __func__);
10869 wmi_buf_free(buf);
10870 return QDF_STATUS_E_FAILURE;
10871 }
10872
10873 return ret;
10874}
10875
10876/**
10877 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10878 * configuration function
10879 * @param wmi_handle : handle to WMI.
10880 * @macaddr : vdev mad address
10881 * @param param : pointer to tx antenna param
10882 *
10883 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10884 */
10885static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10886 wmi_unified_t wmi_handle,
10887 uint8_t macaddr[IEEE80211_ADDR_LEN],
10888 struct smart_ant_node_config_params *param)
10889{
10890 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10891 wmi_buf_t buf;
10892 uint8_t *buf_ptr;
10893 int32_t len = 0, args_tlv_len;
10894 int ret;
10895 int i = 0;
10896 A_UINT32 *node_config_args;
10897
10898 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10899 len = sizeof(*cmd) + args_tlv_len;
10900
10901 if ((param->args_count == 0)) {
10902 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10903 __func__, param->args_count);
10904 return QDF_STATUS_E_FAILURE;
10905 }
10906
10907 buf = wmi_buf_alloc(wmi_handle, len);
10908 if (!buf) {
10909 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10910 return QDF_STATUS_E_NOMEM;
10911 }
10912
10913 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10914 wmi_buf_data(buf);
10915 buf_ptr = (uint8_t *)cmd;
10916 WMITLV_SET_HDR(&cmd->tlv_header,
10917 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10918 WMITLV_GET_STRUCT_TLVLEN(
10919 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10920 cmd->vdev_id = param->vdev_id;
10921 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10922 cmd->cmd_id = param->cmd_id;
10923 cmd->args_count = param->args_count;
10924 buf_ptr += sizeof(
10925 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10926 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10927 (cmd->args_count * sizeof(A_UINT32)));
10928 buf_ptr += WMI_TLV_HDR_SIZE;
10929 node_config_args = (A_UINT32 *)buf_ptr;
10930
10931 for (i = 0; i < param->args_count; i++) {
10932 node_config_args[i] = param->args_arr[i];
10933 WMI_LOGI("%d", param->args_arr[i]);
10934 }
10935
10936 ret = wmi_unified_cmd_send(wmi_handle,
10937 buf,
10938 len,
10939 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10940
10941 if (ret != 0) {
10942 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10943 __func__, param->cmd_id, macaddr[0],
10944 macaddr[1], macaddr[2], macaddr[3],
10945 macaddr[4], macaddr[5], ret);
10946 wmi_buf_free(buf);
10947 }
10948
10949 return ret;
10950}
10951
10952/**
10953 * send_set_atf_cmd_tlv() - send set atf command to fw
10954 * @wmi_handle: wmi handle
10955 * @param: pointer to set atf param
10956 *
10957 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10958 */
10959static QDF_STATUS
10960send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10961 struct set_atf_params *param)
10962{
10963 wmi_atf_peer_info *peer_info;
10964 wmi_peer_atf_request_fixed_param *cmd;
10965 wmi_buf_t buf;
10966 uint8_t *buf_ptr;
10967 int i;
10968 int32_t len = 0;
10969 QDF_STATUS retval;
10970
10971 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10972 len += param->num_peers * sizeof(wmi_atf_peer_info);
10973 buf = wmi_buf_alloc(wmi_handle, len);
10974 if (!buf) {
10975 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10976 return QDF_STATUS_E_FAILURE;
10977 }
10978 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10979 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10980 WMITLV_SET_HDR(&cmd->tlv_header,
10981 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10982 WMITLV_GET_STRUCT_TLVLEN(
10983 wmi_peer_atf_request_fixed_param));
10984 cmd->num_peers = param->num_peers;
10985
10986 buf_ptr += sizeof(*cmd);
10987 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10988 sizeof(wmi_atf_peer_info) *
10989 cmd->num_peers);
10990 buf_ptr += WMI_TLV_HDR_SIZE;
10991 peer_info = (wmi_atf_peer_info *)buf_ptr;
10992
10993 for (i = 0; i < cmd->num_peers; i++) {
10994 WMITLV_SET_HDR(&peer_info->tlv_header,
10995 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10996 WMITLV_GET_STRUCT_TLVLEN(
10997 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010998 qdf_mem_copy(&(peer_info->peer_macaddr),
10999 &(param->peer_info[i].peer_macaddr),
11000 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011001 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011002 peer_info->vdev_id = param->peer_info[i].vdev_id;
11003 peer_info->pdev_id =
11004 wmi_handle->ops->convert_pdev_id_host_to_target(
11005 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011006 /*
11007 * TLV definition for peer atf request fixed param combines
11008 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11009 * stats and atf extension stats as two different
11010 * implementations.
11011 * Need to discuss with FW on this.
11012 *
11013 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11014 * peer_info->atf_units_reserved =
11015 * param->peer_ext_info[i].atf_index_reserved;
11016 */
11017 peer_info++;
11018 }
11019
11020 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11021 WMI_PEER_ATF_REQUEST_CMDID);
11022
11023 if (retval != QDF_STATUS_SUCCESS) {
11024 WMI_LOGE("%s : WMI Failed\n", __func__);
11025 wmi_buf_free(buf);
11026 }
11027
11028 return retval;
11029}
11030
11031/**
11032 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11033 * @wmi_handle: wmi handle
11034 * @param: pointer to hold fwtest param
11035 *
11036 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11037 */
11038static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11039 struct set_fwtest_params *param)
11040{
11041 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11042 wmi_buf_t buf;
11043 int32_t len = sizeof(*cmd);
11044
11045 buf = wmi_buf_alloc(wmi_handle, len);
11046
11047 if (!buf) {
11048 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11049 return QDF_STATUS_E_FAILURE;
11050 }
11051
11052 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11053 WMITLV_SET_HDR(&cmd->tlv_header,
11054 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11055 WMITLV_GET_STRUCT_TLVLEN(
11056 wmi_fwtest_set_param_cmd_fixed_param));
11057 cmd->param_id = param->arg;
11058 cmd->param_value = param->value;
11059
11060 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11061 WMI_LOGE("Setting FW test param failed\n");
11062 wmi_buf_free(buf);
11063 return QDF_STATUS_E_FAILURE;
11064 }
11065
11066 return QDF_STATUS_SUCCESS;
11067}
11068
11069/**
11070 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11071 * @wmi_handle: wmi handle
11072 * @param: pointer to qboost params
11073 * @macaddr: vdev mac address
11074 *
11075 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11076 */
11077static QDF_STATUS
11078send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11079 uint8_t macaddr[IEEE80211_ADDR_LEN],
11080 struct set_qboost_params *param)
11081{
11082 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11083 wmi_buf_t buf;
11084 int32_t len;
11085 QDF_STATUS ret;
11086
11087 len = sizeof(*cmd);
11088
11089 buf = wmi_buf_alloc(wmi_handle, len);
11090 if (!buf) {
11091 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11092 return QDF_STATUS_E_FAILURE;
11093 }
11094
11095 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11096 WMITLV_SET_HDR(&cmd->tlv_header,
11097 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11098 WMITLV_GET_STRUCT_TLVLEN(
11099 WMI_QBOOST_CFG_CMD_fixed_param));
11100 cmd->vdev_id = param->vdev_id;
11101 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11102 cmd->qb_enable = param->value;
11103
11104 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11105 WMI_QBOOST_CFG_CMDID);
11106
11107 if (ret != 0) {
11108 WMI_LOGE("Setting qboost cmd failed\n");
11109 wmi_buf_free(buf);
11110 }
11111
11112 return ret;
11113}
11114
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011115/**
11116 * send_gpio_config_cmd_tlv() - send gpio config to fw
11117 * @wmi_handle: wmi handle
11118 * @param: pointer to hold gpio config param
11119 *
11120 * Return: 0 for success or error code
11121 */
11122static QDF_STATUS
11123send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11124 struct gpio_config_params *param)
11125{
11126 wmi_gpio_config_cmd_fixed_param *cmd;
11127 wmi_buf_t buf;
11128 int32_t len;
11129 QDF_STATUS ret;
11130
11131 len = sizeof(*cmd);
11132
11133 /* Sanity Checks */
11134 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11135 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11136 return QDF_STATUS_E_FAILURE;
11137 }
11138
11139 buf = wmi_buf_alloc(wmi_handle, len);
11140 if (!buf) {
11141 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11142 return QDF_STATUS_E_FAILURE;
11143 }
11144
11145 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11146 WMITLV_SET_HDR(&cmd->tlv_header,
11147 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11148 WMITLV_GET_STRUCT_TLVLEN(
11149 wmi_gpio_config_cmd_fixed_param));
11150 cmd->gpio_num = param->gpio_num;
11151 cmd->input = param->input;
11152 cmd->pull_type = param->pull_type;
11153 cmd->intr_mode = param->intr_mode;
11154
11155 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11156 WMI_GPIO_CONFIG_CMDID);
11157
11158 if (ret != 0) {
11159 WMI_LOGE("Sending GPIO config cmd failed\n");
11160 wmi_buf_free(buf);
11161 }
11162
11163 return ret;
11164}
11165
11166/**
11167 * send_gpio_output_cmd_tlv() - send gpio output to fw
11168 * @wmi_handle: wmi handle
11169 * @param: pointer to hold gpio output param
11170 *
11171 * Return: 0 for success or error code
11172 */
11173static QDF_STATUS
11174send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11175 struct gpio_output_params *param)
11176{
11177 wmi_gpio_output_cmd_fixed_param *cmd;
11178 wmi_buf_t buf;
11179 int32_t len;
11180 QDF_STATUS ret;
11181
11182 len = sizeof(*cmd);
11183
11184 buf = wmi_buf_alloc(wmi_handle, len);
11185 if (!buf) {
11186 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11187 return QDF_STATUS_E_FAILURE;
11188 }
11189
11190 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11191 WMITLV_SET_HDR(&cmd->tlv_header,
11192 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11193 WMITLV_GET_STRUCT_TLVLEN(
11194 wmi_gpio_output_cmd_fixed_param));
11195 cmd->gpio_num = param->gpio_num;
11196 cmd->set = param->set;
11197
11198 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11199 WMI_GPIO_OUTPUT_CMDID);
11200
11201 if (ret != 0) {
11202 WMI_LOGE("Sending GPIO output cmd failed\n");
11203 wmi_buf_free(buf);
11204 }
11205
11206 return ret;
11207
11208}
11209
11210/**
11211 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11212 *
11213 * @param wmi_handle : handle to WMI.
11214 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11215 */
11216static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11217{
11218 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11219 wmi_buf_t buf;
11220 QDF_STATUS ret;
11221 int32_t len;
11222
11223 len = sizeof(*cmd);
11224
11225 buf = wmi_buf_alloc(wmi_handle, len);
11226 if (!buf) {
11227 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11228 return QDF_STATUS_E_FAILURE;
11229 }
11230
11231 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11232 WMITLV_SET_HDR(&cmd->tlv_header,
11233 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11234 WMITLV_GET_STRUCT_TLVLEN(
11235 wmi_pdev_dfs_disable_cmd_fixed_param));
11236 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011237 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11238 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011239
11240 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11241 WMI_PDEV_DFS_DISABLE_CMDID);
11242
11243 if (ret != 0) {
11244 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11245 wmi_buf_free(buf);
11246 }
11247
11248 return ret;
11249}
11250
11251/**
11252 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11253 *
11254 * @param wmi_handle : handle to WMI.
11255 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11256 */
11257static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11258{
11259 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11260 wmi_buf_t buf;
11261 QDF_STATUS ret;
11262 int32_t len;
11263
11264 len = sizeof(*cmd);
11265
11266 buf = wmi_buf_alloc(wmi_handle, len);
11267 if (!buf) {
11268 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11269 return QDF_STATUS_E_FAILURE;
11270 }
11271
11272 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11273 WMITLV_SET_HDR(&cmd->tlv_header,
11274 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11275 WMITLV_GET_STRUCT_TLVLEN(
11276 wmi_pdev_dfs_enable_cmd_fixed_param));
11277 /* Reserved for future use */
11278 cmd->reserved0 = 0;
11279
11280 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11281 WMI_PDEV_DFS_ENABLE_CMDID);
11282
11283 if (ret != 0) {
11284 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11285 wmi_buf_free(buf);
11286 }
11287
11288 return ret;
11289}
11290
11291/**
11292 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11293 * @wmi_handle: wmi handle
11294 *
11295 * Return: 0 for success or error code
11296 */
11297static QDF_STATUS
11298send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
11299{
11300 wmi_buf_t buf;
11301 QDF_STATUS ret;
11302
11303 buf = wmi_buf_alloc(wmi_handle, 0);
11304 if (buf == NULL)
11305 return QDF_STATUS_E_NOMEM;
11306
11307 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
11308 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11309 if (ret != 0) {
11310 WMI_LOGE("Sending get nfcal power cmd failed\n");
11311 wmi_buf_free(buf);
11312 }
11313
11314 return ret;
11315}
11316
11317/**
11318 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11319 * @wmi_handle: wmi handle
11320 * @param: pointer to ht ie param
11321 *
11322 * Return: 0 for success or error code
11323 */
11324static QDF_STATUS
11325send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11326 struct ht_ie_params *param)
11327{
11328 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11329 wmi_buf_t buf;
11330 QDF_STATUS ret;
11331 int32_t len;
11332 uint8_t *buf_ptr;
11333
11334 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11335 roundup(param->ie_len, sizeof(uint32_t));
11336
11337 buf = wmi_buf_alloc(wmi_handle, len);
11338 if (!buf) {
11339 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11340 return QDF_STATUS_E_FAILURE;
11341 }
11342
11343 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11344 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11345 WMITLV_SET_HDR(&cmd->tlv_header,
11346 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11347 WMITLV_GET_STRUCT_TLVLEN(
11348 wmi_pdev_set_ht_ie_cmd_fixed_param));
11349 cmd->reserved0 = 0;
11350 cmd->ie_len = param->ie_len;
11351 cmd->tx_streams = param->tx_streams;
11352 cmd->rx_streams = param->rx_streams;
11353
11354 buf_ptr += sizeof(*cmd);
11355 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11356 buf_ptr += WMI_TLV_HDR_SIZE;
11357 if (param->ie_len)
11358 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11359 cmd->ie_len);
11360
11361 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11362 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11363
11364 if (ret != 0) {
11365 WMI_LOGE("Sending set ht ie cmd failed\n");
11366 wmi_buf_free(buf);
11367 }
11368
11369 return ret;
11370}
11371
11372/**
11373 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11374 * @wmi_handle: wmi handle
11375 * @param: pointer to vht ie param
11376 *
11377 * Return: 0 for success or error code
11378 */
11379static QDF_STATUS
11380send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11381 struct vht_ie_params *param)
11382{
11383 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11384 wmi_buf_t buf;
11385 QDF_STATUS ret;
11386 int32_t len;
11387 uint8_t *buf_ptr;
11388
11389 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11390 roundup(param->ie_len, sizeof(uint32_t));
11391
11392 buf = wmi_buf_alloc(wmi_handle, len);
11393 if (!buf) {
11394 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11395 return QDF_STATUS_E_FAILURE;
11396 }
11397
11398 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11399 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11400 WMITLV_SET_HDR(&cmd->tlv_header,
11401 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11402 WMITLV_GET_STRUCT_TLVLEN(
11403 wmi_pdev_set_vht_ie_cmd_fixed_param));
11404 cmd->reserved0 = 0;
11405 cmd->ie_len = param->ie_len;
11406 cmd->tx_streams = param->tx_streams;
11407 cmd->rx_streams = param->rx_streams;
11408
11409 buf_ptr += sizeof(*cmd);
11410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11411 buf_ptr += WMI_TLV_HDR_SIZE;
11412 if (param->ie_len)
11413 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11414 cmd->ie_len);
11415
11416 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11417 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11418
11419 if (ret != 0) {
11420 WMI_LOGE("Sending set vht ie cmd failed\n");
11421 wmi_buf_free(buf);
11422 }
11423
11424 return ret;
11425}
11426
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011427/**
11428 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11429 * @wmi_handle: wmi handle
11430 * @param: pointer to quiet mode params
11431 *
11432 * Return: 0 for success or error code
11433 */
11434static QDF_STATUS
11435send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11436 struct set_quiet_mode_params *param)
11437{
11438 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11439 wmi_buf_t buf;
11440 QDF_STATUS ret;
11441 int32_t len;
11442
11443 len = sizeof(*quiet_cmd);
11444 buf = wmi_buf_alloc(wmi_handle, len);
11445 if (!buf) {
11446 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11447 return QDF_STATUS_E_FAILURE;
11448 }
11449
11450 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11451 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11452 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11453 WMITLV_GET_STRUCT_TLVLEN(
11454 wmi_pdev_set_quiet_cmd_fixed_param));
11455 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11456 quiet_cmd->enabled = param->enabled;
11457 quiet_cmd->period = (param->period)*(param->intval);
11458 quiet_cmd->duration = param->duration;
11459 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011460 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11461 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011462
11463 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11464 WMI_PDEV_SET_QUIET_MODE_CMDID);
11465
11466 if (ret != 0) {
11467 WMI_LOGE("Sending set quiet cmd failed\n");
11468 wmi_buf_free(buf);
11469 }
11470
11471 return ret;
11472}
11473
11474/**
11475 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11476 * @wmi_handle: wmi handle
11477 * @param: pointer to set bwf param
11478 *
11479 * Return: 0 for success or error code
11480 */
11481static QDF_STATUS
11482send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11483 struct set_bwf_params *param)
11484{
11485 wmi_bwf_peer_info *peer_info;
11486 wmi_peer_bwf_request_fixed_param *cmd;
11487 wmi_buf_t buf;
11488 QDF_STATUS retval;
11489 int32_t len;
11490 uint8_t *buf_ptr;
11491 int i;
11492
11493 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11494 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11495 buf = wmi_buf_alloc(wmi_handle, len);
11496 if (!buf) {
11497 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11498 return QDF_STATUS_E_FAILURE;
11499 }
11500 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11501 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11502 WMITLV_SET_HDR(&cmd->tlv_header,
11503 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11504 WMITLV_GET_STRUCT_TLVLEN(
11505 wmi_peer_bwf_request_fixed_param));
11506 cmd->num_peers = param->num_peers;
11507
11508 buf_ptr += sizeof(*cmd);
11509 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11510 sizeof(wmi_bwf_peer_info) *
11511 cmd->num_peers);
11512 buf_ptr += WMI_TLV_HDR_SIZE;
11513 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11514
11515 for (i = 0; i < cmd->num_peers; i++) {
11516 WMITLV_SET_HDR(&peer_info->tlv_header,
11517 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11518 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11519 peer_info->bwf_guaranteed_bandwidth =
11520 param->peer_info[i].throughput;
11521 peer_info->bwf_max_airtime =
11522 param->peer_info[i].max_airtime;
11523 peer_info->bwf_peer_priority =
11524 param->peer_info[i].priority;
11525 qdf_mem_copy(&peer_info->peer_macaddr,
11526 &param->peer_info[i].peer_macaddr,
11527 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011528 peer_info->vdev_id =
11529 param->peer_info[i].vdev_id;
11530 peer_info->pdev_id =
11531 wmi_handle->ops->convert_pdev_id_host_to_target(
11532 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011533 peer_info++;
11534 }
11535
11536 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11537 WMI_PEER_BWF_REQUEST_CMDID);
11538
11539 if (retval != QDF_STATUS_SUCCESS) {
11540 WMI_LOGE("%s : WMI Failed\n", __func__);
11541 wmi_buf_free(buf);
11542 }
11543
11544 return retval;
11545}
11546
11547/**
11548 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11549 * @wmi_handle: wmi handle
11550 * @param: pointer to hold mcast update param
11551 *
11552 * Return: 0 for success or error code
11553 */
11554static QDF_STATUS
11555send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11556 struct mcast_group_update_params *param)
11557{
11558 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11559 wmi_buf_t buf;
11560 QDF_STATUS ret;
11561 int32_t len;
11562 int offset = 0;
11563 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11564
11565 len = sizeof(*cmd);
11566 buf = wmi_buf_alloc(wmi_handle, len);
11567 if (!buf) {
11568 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11569 return QDF_STATUS_E_FAILURE;
11570 }
11571 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11572 WMITLV_SET_HDR(&cmd->tlv_header,
11573 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11574 WMITLV_GET_STRUCT_TLVLEN(
11575 wmi_peer_mcast_group_cmd_fixed_param));
11576 /* confirm the buffer is 4-byte aligned */
11577 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11578 qdf_mem_zero(cmd, sizeof(*cmd));
11579
11580 cmd->vdev_id = param->vap_id;
11581 /* construct the message assuming our endianness matches the target */
11582 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11583 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11584 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11585 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11586 if (param->is_action_delete)
11587 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11588
11589 if (param->is_mcast_addr_len)
11590 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11591
11592 if (param->is_filter_mode_snoop)
11593 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11594
11595 /* unicast address spec only applies for non-wildcard cases */
11596 if (!param->wildcard && param->ucast_mac_addr) {
11597 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11598 &cmd->ucast_mac_addr);
11599 }
11600 if (param->mcast_ip_addr) {
11601 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11602 sizeof(cmd->mcast_ip_addr));
11603 offset = sizeof(cmd->mcast_ip_addr) -
11604 param->mcast_ip_addr_bytes;
11605 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11606 param->mcast_ip_addr,
11607 param->mcast_ip_addr_bytes);
11608 }
11609 if (!param->mask)
11610 param->mask = &dummymask[0];
11611
11612 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11613 param->mask,
11614 param->mcast_ip_addr_bytes);
11615
11616 if (param->srcs && param->nsrcs) {
11617 cmd->num_filter_addr = param->nsrcs;
11618 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11619 sizeof(cmd->filter_addr));
11620
11621 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11622 param->nsrcs * param->mcast_ip_addr_bytes);
11623 }
11624
11625 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11626 WMI_PEER_MCAST_GROUP_CMDID);
11627
11628 if (ret != QDF_STATUS_SUCCESS) {
11629 WMI_LOGE("%s : WMI Failed\n", __func__);
11630 wmi_buf_free(buf);
11631 }
11632
11633 return ret;
11634}
11635
11636/**
11637 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11638 * command to fw
11639 * @wmi_handle: wmi handle
11640 * @param: pointer to hold spectral config parameter
11641 *
11642 * Return: 0 for success or error code
11643 */
11644static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11645 struct vdev_spectral_configure_params *param)
11646{
11647 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11648 wmi_buf_t buf;
11649 QDF_STATUS ret;
11650 int32_t len;
11651
11652 len = sizeof(*cmd);
11653 buf = wmi_buf_alloc(wmi_handle, len);
11654 if (!buf) {
11655 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11656 return QDF_STATUS_E_FAILURE;
11657 }
11658
11659 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11660 WMITLV_SET_HDR(&cmd->tlv_header,
11661 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11662 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011663 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011664
11665 cmd->vdev_id = param->vdev_id;
11666 cmd->spectral_scan_count = param->count;
11667 cmd->spectral_scan_period = param->period;
11668 cmd->spectral_scan_priority = param->spectral_pri;
11669 cmd->spectral_scan_fft_size = param->fft_size;
11670 cmd->spectral_scan_gc_ena = param->gc_enable;
11671 cmd->spectral_scan_restart_ena = param->restart_enable;
11672 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11673 cmd->spectral_scan_init_delay = param->init_delay;
11674 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11675 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11676 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11677 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11678 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11679 cmd->spectral_scan_pwr_format = param->pwr_format;
11680 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11681 cmd->spectral_scan_bin_scale = param->bin_scale;
11682 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11683 cmd->spectral_scan_chn_mask = param->chn_mask;
11684
11685 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11686 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11687
11688 if (ret != 0) {
11689 WMI_LOGE("Sending set quiet cmd failed\n");
11690 wmi_buf_free(buf);
11691 }
11692
11693 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11694 __func__);
11695
11696 WMI_LOGI("vdev_id = %u\n"
11697 "spectral_scan_count = %u\n"
11698 "spectral_scan_period = %u\n"
11699 "spectral_scan_priority = %u\n"
11700 "spectral_scan_fft_size = %u\n"
11701 "spectral_scan_gc_ena = %u\n"
11702 "spectral_scan_restart_ena = %u\n"
11703 "spectral_scan_noise_floor_ref = %u\n"
11704 "spectral_scan_init_delay = %u\n"
11705 "spectral_scan_nb_tone_thr = %u\n"
11706 "spectral_scan_str_bin_thr = %u\n"
11707 "spectral_scan_wb_rpt_mode = %u\n"
11708 "spectral_scan_rssi_rpt_mode = %u\n"
11709 "spectral_scan_rssi_thr = %u\n"
11710 "spectral_scan_pwr_format = %u\n"
11711 "spectral_scan_rpt_mode = %u\n"
11712 "spectral_scan_bin_scale = %u\n"
11713 "spectral_scan_dBm_adj = %u\n"
11714 "spectral_scan_chn_mask = %u\n",
11715 param->vdev_id,
11716 param->count,
11717 param->period,
11718 param->spectral_pri,
11719 param->fft_size,
11720 param->gc_enable,
11721 param->restart_enable,
11722 param->noise_floor_ref,
11723 param->init_delay,
11724 param->nb_tone_thr,
11725 param->str_bin_thr,
11726 param->wb_rpt_mode,
11727 param->rssi_rpt_mode,
11728 param->rssi_thr,
11729 param->pwr_format,
11730 param->rpt_mode,
11731 param->bin_scale,
11732 param->dBm_adj,
11733 param->chn_mask);
11734 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11735
11736 return ret;
11737}
11738
11739/**
11740 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11741 * command to fw
11742 * @wmi_handle: wmi handle
11743 * @param: pointer to hold spectral enable parameter
11744 *
11745 * Return: 0 for success or error code
11746 */
11747static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11748 struct vdev_spectral_enable_params *param)
11749{
11750 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11751 wmi_buf_t buf;
11752 QDF_STATUS ret;
11753 int32_t len;
11754
11755 len = sizeof(*cmd);
11756 buf = wmi_buf_alloc(wmi_handle, len);
11757 if (!buf) {
11758 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11759 return QDF_STATUS_E_FAILURE;
11760 }
11761
11762 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11763 WMITLV_SET_HDR(&cmd->tlv_header,
11764 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11765 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011766 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011767
11768 cmd->vdev_id = param->vdev_id;
11769
11770 if (param->active_valid) {
11771 cmd->trigger_cmd = param->active ? 1 : 2;
11772 /* 1: Trigger, 2: Clear Trigger */
11773 } else {
11774 cmd->trigger_cmd = 0; /* 0: Ignore */
11775 }
11776
11777 if (param->enabled_valid) {
11778 cmd->enable_cmd = param->enabled ? 1 : 2;
11779 /* 1: Enable 2: Disable */
11780 } else {
11781 cmd->enable_cmd = 0; /* 0: Ignore */
11782 }
11783
11784 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11785 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11786
11787 if (ret != 0) {
11788 WMI_LOGE("Sending scan enable CMD failed\n");
11789 wmi_buf_free(buf);
11790 }
11791
11792 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11793
11794 WMI_LOGI("vdev_id = %u\n"
11795 "trigger_cmd = %u\n"
11796 "enable_cmd = %u\n",
11797 cmd->vdev_id,
11798 cmd->trigger_cmd,
11799 cmd->enable_cmd);
11800
11801 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11802
11803 return ret;
11804}
11805
11806/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011807 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11808 * @param wmi_handle : handle to WMI.
11809 * @param param : pointer to hold thermal mitigation param
11810 *
11811 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11812 */
11813static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11814 wmi_unified_t wmi_handle,
11815 struct thermal_mitigation_params *param)
11816{
11817 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11818 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11819 wmi_buf_t buf = NULL;
11820 uint8_t *buf_ptr = NULL;
11821 int error;
11822 int32_t len;
11823 int i;
11824
11825 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11826 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11827
11828 buf = wmi_buf_alloc(wmi_handle, len);
11829 if (!buf) {
11830 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11831 return QDF_STATUS_E_NOMEM;
11832 }
11833 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11834
11835 /* init fixed params */
11836 WMITLV_SET_HDR(tt_conf,
11837 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11838 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11839
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011840 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11841 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011842 tt_conf->enable = param->enable;
11843 tt_conf->dc = param->dc;
11844 tt_conf->dc_per_event = param->dc_per_event;
11845 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11846
11847 buf_ptr = (uint8_t *) ++tt_conf;
11848 /* init TLV params */
11849 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11850 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11851
11852 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11853 for (i = 0; i < THERMAL_LEVELS; i++) {
11854 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11855 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11856 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11857 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11858 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11859 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11860 lvl_conf->prio = param->levelconf[i].priority;
11861 lvl_conf++;
11862 }
11863
11864 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11865 WMI_THERM_THROT_SET_CONF_CMDID);
11866 if (QDF_IS_STATUS_ERROR(error)) {
11867 wmi_buf_free(buf);
11868 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11869 }
11870
11871 return error;
11872}
11873
11874/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011875 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11876 * @wmi_handle: wmi handle
11877 * @param: pointer to pdev_qvit_params
11878 *
11879 * Return: 0 for success or error code
11880 */
11881static QDF_STATUS
11882send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11883 struct pdev_qvit_params *param)
11884{
11885 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011886 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011887 uint8_t *cmd;
11888 static uint8_t msgref = 1;
11889 uint8_t segnumber = 0, seginfo, numsegments;
11890 uint16_t chunk_len, total_bytes;
11891 uint8_t *bufpos;
11892 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11893
11894 bufpos = param->utf_payload;
11895 total_bytes = param->len;
11896 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11897 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11898 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11899
11900 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11901 numsegments++;
11902
11903 while (param->len) {
11904 if (param->len > MAX_WMI_QVIT_LEN)
11905 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11906 else
11907 chunk_len = param->len;
11908
11909 buf = wmi_buf_alloc(wmi_handle,
11910 (chunk_len + sizeof(seghdrinfo) +
11911 WMI_TLV_HDR_SIZE));
11912 if (!buf) {
11913 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11914 return QDF_STATUS_E_NOMEM;
11915 }
11916
11917 cmd = (uint8_t *) wmi_buf_data(buf);
11918
11919 seghdrinfo.len = total_bytes;
11920 seghdrinfo.msgref = msgref;
11921 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11922 seghdrinfo.segmentInfo = seginfo;
11923
11924 segnumber++;
11925
11926 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11927 (chunk_len + sizeof(seghdrinfo)));
11928 cmd += WMI_TLV_HDR_SIZE;
11929 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11930 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11931
11932 ret = wmi_unified_cmd_send(wmi_handle, buf,
11933 (chunk_len + sizeof(seghdrinfo) +
11934 WMI_TLV_HDR_SIZE),
11935 WMI_PDEV_QVIT_CMDID);
11936
11937 if (ret != 0) {
11938 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11939 wmi_buf_free(buf);
11940 break;
11941 }
11942
11943 param->len -= chunk_len;
11944 bufpos += chunk_len;
11945 }
11946 msgref++;
11947
11948 return ret;
11949}
11950
11951/**
11952 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11953 * @wmi_handle: wmi handle
11954 * @param: pointer to wmm update param
11955 *
11956 * Return: 0 for success or error code
11957 */
11958static QDF_STATUS
11959send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11960 struct wmm_update_params *param)
11961{
11962 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11963 wmi_wmm_params *wmm_param;
11964 wmi_buf_t buf;
11965 QDF_STATUS ret;
11966 int32_t len;
11967 int ac = 0;
11968 struct wmi_host_wmeParams *wmep;
11969 uint8_t *buf_ptr;
11970
11971 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11972 buf = wmi_buf_alloc(wmi_handle, len);
11973 if (!buf) {
11974 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11975 return QDF_STATUS_E_FAILURE;
11976 }
11977
11978 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11979 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11980 WMITLV_SET_HDR(&cmd->tlv_header,
11981 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11982 WMITLV_GET_STRUCT_TLVLEN
11983 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11984
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011985 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011986
11987 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11988
11989 for (ac = 0; ac < WME_NUM_AC; ac++) {
11990 wmep = &param->wmep_array[ac];
11991 wmm_param = (wmi_wmm_params *)buf_ptr;
11992 WMITLV_SET_HDR(&wmm_param->tlv_header,
11993 WMITLV_TAG_STRUC_wmi_wmm_params,
11994 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11995 wmm_param->aifs = wmep->wmep_aifsn;
11996 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11997 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11998 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11999 wmm_param->acm = wmep->wmep_acm;
12000 wmm_param->no_ack = wmep->wmep_noackPolicy;
12001 buf_ptr += sizeof(wmi_wmm_params);
12002 }
12003 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12004 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12005
12006 if (ret != 0) {
12007 WMI_LOGE("Sending WMM update CMD failed\n");
12008 wmi_buf_free(buf);
12009 }
12010
12011 return ret;
12012}
12013
Sathish Kumar80f4f382017-04-24 11:36:00 +053012014/**
12015 * send_coex_config_cmd_tlv() - send coex config command to fw
12016 * @wmi_handle: wmi handle
12017 * @param: pointer to coex config param
12018 *
12019 * Return: 0 for success or error code
12020 */
12021static QDF_STATUS
12022send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12023 struct coex_config_params *param)
12024{
12025 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12026 wmi_buf_t buf;
12027 QDF_STATUS ret;
12028 int32_t len;
12029
12030 len = sizeof(*cmd);
12031 buf = wmi_buf_alloc(wmi_handle, len);
12032 if (!buf) {
12033 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12034 return QDF_STATUS_E_FAILURE;
12035 }
12036
12037 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12038 WMITLV_SET_HDR(&cmd->tlv_header,
12039 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12040 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012041 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012042
12043 cmd->vdev_id = param->vdev_id;
12044 cmd->config_type = param->config_type;
12045 cmd->config_arg1 = param->config_arg1;
12046 cmd->config_arg2 = param->config_arg2;
12047 cmd->config_arg3 = param->config_arg3;
12048 cmd->config_arg4 = param->config_arg4;
12049 cmd->config_arg5 = param->config_arg5;
12050 cmd->config_arg6 = param->config_arg6;
12051
12052 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12053 WMI_COEX_CONFIG_CMDID);
12054
12055 if (ret != 0) {
12056 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12057 wmi_buf_free(buf);
12058 }
12059
12060 return ret;
12061}
12062
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012063static
Govind Singh9ddd5162016-03-07 16:30:32 +053012064void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012065 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012066{
Govind Singhe7f2f342016-05-23 12:12:52 +053012067 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012068 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12069 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12070 resource_cfg->num_offload_reorder_buffs =
12071 tgt_res_cfg->num_offload_reorder_buffs;
12072 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12073 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12074 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12075 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12076 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12077 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12078 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12079 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12080 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12081 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12082 resource_cfg->scan_max_pending_req =
12083 tgt_res_cfg->scan_max_pending_req;
12084 resource_cfg->bmiss_offload_max_vdev =
12085 tgt_res_cfg->bmiss_offload_max_vdev;
12086 resource_cfg->roam_offload_max_vdev =
12087 tgt_res_cfg->roam_offload_max_vdev;
12088 resource_cfg->roam_offload_max_ap_profiles =
12089 tgt_res_cfg->roam_offload_max_ap_profiles;
12090 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12091 resource_cfg->num_mcast_table_elems =
12092 tgt_res_cfg->num_mcast_table_elems;
12093 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12094 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12095 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12096 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12097 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12098 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12099 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12100 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12101 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12102 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12103 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12104 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12105 resource_cfg->num_tdls_conn_table_entries =
12106 tgt_res_cfg->num_tdls_conn_table_entries;
12107 resource_cfg->beacon_tx_offload_max_vdev =
12108 tgt_res_cfg->beacon_tx_offload_max_vdev;
12109 resource_cfg->num_multicast_filter_entries =
12110 tgt_res_cfg->num_multicast_filter_entries;
12111 resource_cfg->num_wow_filters =
12112 tgt_res_cfg->num_wow_filters;
12113 resource_cfg->num_keep_alive_pattern =
12114 tgt_res_cfg->num_keep_alive_pattern;
12115 resource_cfg->keep_alive_pattern_size =
12116 tgt_res_cfg->keep_alive_pattern_size;
12117 resource_cfg->max_tdls_concurrent_sleep_sta =
12118 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12119 resource_cfg->max_tdls_concurrent_buffer_sta =
12120 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12121 resource_cfg->wmi_send_separate =
12122 tgt_res_cfg->wmi_send_separate;
12123 resource_cfg->num_ocb_vdevs =
12124 tgt_res_cfg->num_ocb_vdevs;
12125 resource_cfg->num_ocb_channels =
12126 tgt_res_cfg->num_ocb_channels;
12127 resource_cfg->num_ocb_schedules =
12128 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012129 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
12130 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12131 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012132
12133 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
12134 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053012135}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012136#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012137/**
12138 * send_init_cmd_tlv() - wmi init command
12139 * @wmi_handle: pointer to wmi handle
12140 * @res_cfg: resource config
12141 * @num_mem_chunks: no of mem chunck
12142 * @mem_chunk: pointer to mem chunck structure
12143 *
12144 * This function sends IE information to firmware
12145 *
Govind Singhb53420c2016-03-09 14:32:57 +053012146 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012147 *
12148 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012149static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012150 wmi_resource_config *tgt_res_cfg,
12151 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
12152 bool action)
12153{
12154 wmi_buf_t buf;
12155 wmi_init_cmd_fixed_param *cmd;
12156 wmi_abi_version my_vers;
12157 int num_whitelist;
12158 uint8_t *buf_ptr;
12159 wmi_resource_config *resource_cfg;
12160 wlan_host_memory_chunk *host_mem_chunks;
12161 uint32_t mem_chunk_len = 0;
12162 uint16_t idx;
12163 int len;
12164 int ret;
12165
12166 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
12167 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
12168 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
12169 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012170 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
12171 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012172 }
12173
12174 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12175 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
12176 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
12177
12178 host_mem_chunks = (wlan_host_memory_chunk *)
12179 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
12180 + WMI_TLV_HDR_SIZE);
12181
12182 WMITLV_SET_HDR(&cmd->tlv_header,
12183 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
12184 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
12185
Govind Singhb53420c2016-03-09 14:32:57 +053012186 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053012187 WMITLV_SET_HDR(&resource_cfg->tlv_header,
12188 WMITLV_TAG_STRUC_wmi_resource_config,
12189 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
12190
12191 for (idx = 0; idx < num_mem_chunks; ++idx) {
12192 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
12193 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
12194 WMITLV_GET_STRUCT_TLVLEN
12195 (wlan_host_memory_chunk));
12196 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
12197 host_mem_chunks[idx].size = mem_chunks[idx].len;
12198 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053012199 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053012200 idx, host_mem_chunks[idx].size,
12201 host_mem_chunks[idx].ptr);
12202 }
12203 cmd->num_host_mem_chunks = num_mem_chunks;
12204 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
12205 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
12206 WMITLV_TAG_ARRAY_STRUC,
12207 (sizeof(wlan_host_memory_chunk) *
12208 num_mem_chunks));
12209
12210 num_whitelist = sizeof(version_whitelist) /
12211 sizeof(wmi_whitelist_version_info);
12212 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12213 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12214 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12215 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12216 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12217 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053012218#ifdef CONFIG_MCL
12219 /* This needs to be enabled for WIN Lithium after removing dependency
12220 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053012221 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12222 &my_vers,
12223 &wmi_handle->fw_abi_version,
12224 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053012225#endif
Govind Singhb53420c2016-03-09 14:32:57 +053012226 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053012227 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12228 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12229 cmd->host_abi_vers.abi_version_ns_0,
12230 cmd->host_abi_vers.abi_version_ns_1,
12231 cmd->host_abi_vers.abi_version_ns_2,
12232 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053012233#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012234 /* Save version sent from host -
12235 * Will be used to check ready event
12236 */
Govind Singhb53420c2016-03-09 14:32:57 +053012237 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012238 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012239#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012240 if (action) {
12241 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12242 WMI_INIT_CMDID);
12243 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053012244 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053012245 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012246 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012247 }
12248 } else {
12249 wmi_handle->saved_wmi_init_cmd.buf = buf;
12250 wmi_handle->saved_wmi_init_cmd.buf_len = len;
12251 }
12252
Govind Singhb53420c2016-03-09 14:32:57 +053012253 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012254
12255}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053012256#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012257/**
12258 * send_saved_init_cmd_tlv() - wmi init command
12259 * @wmi_handle: pointer to wmi handle
12260 *
12261 * This function sends IE information to firmware
12262 *
Govind Singhb53420c2016-03-09 14:32:57 +053012263 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012264 *
12265 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012266static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053012267{
12268 int status;
12269
12270 if (!wmi_handle->saved_wmi_init_cmd.buf ||
12271 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053012272 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
12273 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012274 }
12275 status = wmi_unified_cmd_send(wmi_handle,
12276 wmi_handle->saved_wmi_init_cmd.buf,
12277 wmi_handle->saved_wmi_init_cmd.buf_len,
12278 WMI_INIT_CMDID);
12279 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053012280 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053012281 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012282 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012283 }
12284 wmi_handle->saved_wmi_init_cmd.buf = NULL;
12285 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
12286
Govind Singhb53420c2016-03-09 14:32:57 +053012287 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012288}
12289
Sathish Kumarfd347372017-02-13 12:29:09 +053012290static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012291{
12292 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12293 wmi_service_ready_event_fixed_param *ev;
12294
12295
12296 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12297
12298 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12299 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012300 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012301
Govind Singh87542482016-06-08 19:40:11 +053012302#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012303 /*Save fw version from service ready message */
12304 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012305 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012306 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012307#endif
Govind Singhb53420c2016-03-09 14:32:57 +053012308 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012309}
12310
12311/**
12312 * wmi_unified_save_fw_version_cmd() - save fw version
12313 * @wmi_handle: pointer to wmi handle
12314 * @res_cfg: resource config
12315 * @num_mem_chunks: no of mem chunck
12316 * @mem_chunk: pointer to mem chunck structure
12317 *
12318 * This function sends IE information to firmware
12319 *
Govind Singhb53420c2016-03-09 14:32:57 +053012320 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012321 *
12322 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012323static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012324 void *evt_buf)
12325{
12326 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12327 wmi_ready_event_fixed_param *ev = NULL;
12328
12329 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12330 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053012331#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012332 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
12333 &ev->fw_abi_vers)) {
12334 /*
12335 * Error: Our host version and the given firmware version
12336 * are incompatible.
12337 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012338 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012339 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12340 __func__,
12341 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12342 abi_version_0),
12343 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12344 abi_version_0),
12345 wmi_handle->final_abi_vers.abi_version_ns_0,
12346 wmi_handle->final_abi_vers.abi_version_ns_1,
12347 wmi_handle->final_abi_vers.abi_version_ns_2,
12348 wmi_handle->final_abi_vers.abi_version_ns_3,
12349 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12350 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12351 ev->fw_abi_vers.abi_version_ns_0,
12352 ev->fw_abi_vers.abi_version_ns_1,
12353 ev->fw_abi_vers.abi_version_ns_2,
12354 ev->fw_abi_vers.abi_version_ns_3);
12355
Govind Singhb53420c2016-03-09 14:32:57 +053012356 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012357 }
Govind Singhb53420c2016-03-09 14:32:57 +053012358 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012359 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012360 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012361 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012362#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012363
Govind Singhb53420c2016-03-09 14:32:57 +053012364 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012365}
Govind Singha4836fd2016-03-07 16:45:38 +053012366
12367/**
12368 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12369 * @wmi_handle: wmi handle
12370 * @custom_addr: base mac address
12371 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012372 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012373 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012374static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012375 uint8_t *custom_addr)
12376{
12377 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12378 wmi_buf_t buf;
12379 int err;
12380
12381 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12382 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012383 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012384 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012385 }
12386
12387 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012388 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012389
12390 WMITLV_SET_HDR(&cmd->tlv_header,
12391 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12392 WMITLV_GET_STRUCT_TLVLEN
12393 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12394 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012395 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12396 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012397 err = wmi_unified_cmd_send(wmi_handle, buf,
12398 sizeof(*cmd),
12399 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12400 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012401 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012402 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012403 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012404 }
12405
12406 return 0;
12407}
12408
12409/**
12410 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12411 * @handle: wmi handle
12412 * @event: Event received from FW
12413 * @len: Length of the event
12414 *
12415 * Enables the low frequency events and disables the high frequency
12416 * events. Bit 17 indicates if the event if low/high frequency.
12417 * 1 - high frequency, 0 - low frequency
12418 *
12419 * Return: 0 on successfully enabling/disabling the events
12420 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012421static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012422 uint8_t *event,
12423 uint32_t len)
12424{
12425 uint32_t num_of_diag_events_logs;
12426 wmi_diag_event_log_config_fixed_param *cmd;
12427 wmi_buf_t buf;
12428 uint8_t *buf_ptr;
12429 uint32_t *cmd_args, *evt_args;
12430 uint32_t buf_len, i;
12431
12432 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12433 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12434
Govind Singhb53420c2016-03-09 14:32:57 +053012435 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012436
12437 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12438 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012439 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012440 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012441 }
12442 wmi_event = param_buf->fixed_param;
12443 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12444 evt_args = param_buf->diag_events_logs_list;
12445 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012446 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012447 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012448 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012449 }
12450
Govind Singhb53420c2016-03-09 14:32:57 +053012451 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012452 __func__, num_of_diag_events_logs);
12453
12454 /* Free any previous allocation */
12455 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012456 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012457
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012458 if (num_of_diag_events_logs >
12459 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12460 WMI_LOGE("%s: excess num of logs:%d", __func__,
12461 num_of_diag_events_logs);
12462 QDF_ASSERT(0);
12463 return QDF_STATUS_E_INVAL;
12464 }
Govind Singha4836fd2016-03-07 16:45:38 +053012465 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012466 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012467 sizeof(uint32_t));
12468 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012469 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012470 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012471 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012472 }
12473 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12474
12475 /* Prepare the send buffer */
12476 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12477 (num_of_diag_events_logs * sizeof(uint32_t));
12478
12479 buf = wmi_buf_alloc(wmi_handle, buf_len);
12480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012481 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12482 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012483 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012484 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012485 }
12486
12487 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12488 buf_ptr = (uint8_t *) cmd;
12489
12490 WMITLV_SET_HDR(&cmd->tlv_header,
12491 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12492 WMITLV_GET_STRUCT_TLVLEN(
12493 wmi_diag_event_log_config_fixed_param));
12494
12495 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12496
12497 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12498
12499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12500 (num_of_diag_events_logs * sizeof(uint32_t)));
12501
12502 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12503
12504 /* Populate the events */
12505 for (i = 0; i < num_of_diag_events_logs; i++) {
12506 /* Low freq (0) - Enable (1) the event
12507 * High freq (1) - Disable (0) the event
12508 */
12509 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12510 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12511 /* Set the event ID */
12512 WMI_DIAG_ID_SET(cmd_args[i],
12513 WMI_DIAG_ID_GET(evt_args[i]));
12514 /* Set the type */
12515 WMI_DIAG_TYPE_SET(cmd_args[i],
12516 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012517 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012518 wmi_handle->events_logs_list[i] = evt_args[i];
12519 }
12520
12521 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12522 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012523 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012524 __func__);
12525 wmi_buf_free(buf);
12526 /* Not clearing events_logs_list, though wmi cmd failed.
12527 * Host can still have this list
12528 */
Govind Singh67922e82016-04-01 16:48:57 +053012529 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012530 }
12531
12532 return 0;
12533}
12534
12535/**
12536 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12537 * @wmi_handle: wmi handle
12538 * @start_log: Start logging related parameters
12539 *
12540 * Send the command to the FW based on which specific logging of diag
12541 * event/log id can be started/stopped
12542 *
12543 * Return: None
12544 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012545static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012546 struct wmi_wifi_start_log *start_log)
12547{
12548 wmi_diag_event_log_config_fixed_param *cmd;
12549 wmi_buf_t buf;
12550 uint8_t *buf_ptr;
12551 uint32_t len, count, log_level, i;
12552 uint32_t *cmd_args;
12553 uint32_t total_len;
12554 count = 0;
12555
12556 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012557 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012558 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012559 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012560 }
12561 /* total_len stores the number of events where BITS 17 and 18 are set.
12562 * i.e., events of high frequency (17) and for extended debugging (18)
12563 */
12564 total_len = 0;
12565 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12566 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12567 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12568 total_len++;
12569 }
12570
12571 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12572 (total_len * sizeof(uint32_t));
12573
12574 buf = wmi_buf_alloc(wmi_handle, len);
12575 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012576 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012577 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012578 }
12579 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12580 buf_ptr = (uint8_t *) cmd;
12581
12582 WMITLV_SET_HDR(&cmd->tlv_header,
12583 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12584 WMITLV_GET_STRUCT_TLVLEN(
12585 wmi_diag_event_log_config_fixed_param));
12586
12587 cmd->num_of_diag_events_logs = total_len;
12588
12589 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12590
12591 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12592 (total_len * sizeof(uint32_t)));
12593
12594 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12595
Govind Singh224a7312016-06-21 14:33:26 +053012596 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012597 log_level = 1;
12598 else
12599 log_level = 0;
12600
Govind Singhb53420c2016-03-09 14:32:57 +053012601 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012602 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12603 uint32_t val = wmi_handle->events_logs_list[i];
12604 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12605 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12606
12607 WMI_DIAG_ID_SET(cmd_args[count],
12608 WMI_DIAG_ID_GET(val));
12609 WMI_DIAG_TYPE_SET(cmd_args[count],
12610 WMI_DIAG_TYPE_GET(val));
12611 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12612 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012613 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012614 count++;
12615 }
12616 }
12617
12618 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12619 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012620 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012621 __func__);
12622 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012623 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012624 }
12625
Govind Singhb53420c2016-03-09 14:32:57 +053012626 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012627}
12628
12629/**
12630 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12631 * @wmi_handle: WMI handle
12632 *
12633 * This function is used to send the flush command to the FW,
12634 * that will flush the fw logs that are residue in the FW
12635 *
12636 * Return: None
12637 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012638static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012639{
12640 wmi_debug_mesg_flush_fixed_param *cmd;
12641 wmi_buf_t buf;
12642 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012643 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012644
12645 buf = wmi_buf_alloc(wmi_handle, len);
12646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012647 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012648 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012649 }
12650
12651 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12652 WMITLV_SET_HDR(&cmd->tlv_header,
12653 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12654 WMITLV_GET_STRUCT_TLVLEN(
12655 wmi_debug_mesg_flush_fixed_param));
12656 cmd->reserved0 = 0;
12657
12658 ret = wmi_unified_cmd_send(wmi_handle,
12659 buf,
12660 len,
12661 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012662 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012663 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012664 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012665 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012666 }
Govind Singhb53420c2016-03-09 14:32:57 +053012667 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012668
Govind Singh67922e82016-04-01 16:48:57 +053012669 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012670}
12671
12672/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012673 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012674 * @wmi_handle: wmi handle
12675 * @msg: PCL structure containing the PCL and the number of channels
12676 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012677 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012678 * firmware. The DBS Manager is the consumer of this information in the WLAN
12679 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12680 * to migrate to a new channel without host driver involvement. An example of
12681 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12682 * manage the channel selection without firmware involvement.
12683 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012684 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12685 * channel list. The weights corresponds to the channels sent in
12686 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12687 * weightage compared to the non PCL channels.
12688 *
Govind Singha4836fd2016-03-07 16:45:38 +053012689 * Return: Success if the cmd is sent successfully to the firmware
12690 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012691static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012692 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012693{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012694 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012695 wmi_buf_t buf;
12696 uint8_t *buf_ptr;
12697 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012698 uint32_t chan_len;
12699
12700 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012701
12702 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012703 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012704
12705 buf = wmi_buf_alloc(wmi_handle, len);
12706 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012707 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12708 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012709 }
12710
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012711 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012712 buf_ptr = (uint8_t *) cmd;
12713 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012714 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12715 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012716
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012717 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12718 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012719 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012720 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012721
12722 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012723 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012724 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012725 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012726 for (i = 0; i < chan_len ; i++) {
12727 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012728 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012729 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012730 }
12731 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012732 WMI_PDEV_SET_PCL_CMDID)) {
12733 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012734 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012735 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012736 }
Govind Singhb53420c2016-03-09 14:32:57 +053012737 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012738}
12739
12740/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012741 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012742 * @wmi_handle: wmi handle
12743 * @msg: Structure containing the following parameters
12744 *
12745 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12746 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12747 *
12748 * Provides notification to the WLAN firmware that host driver is requesting a
12749 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12750 * configurations that include the Dual Band Simultaneous (DBS) feature.
12751 *
12752 * Return: Success if the cmd is sent successfully to the firmware
12753 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012754static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012755 uint32_t hw_mode_index)
12756{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012757 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012758 wmi_buf_t buf;
12759 uint32_t len;
12760
12761 len = sizeof(*cmd);
12762
12763 buf = wmi_buf_alloc(wmi_handle, len);
12764 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012765 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12766 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012767 }
12768
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012769 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012770 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012771 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12772 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12773
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012774 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12775 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012776 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012777 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012778
12779 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012780 WMI_PDEV_SET_HW_MODE_CMDID)) {
12781 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012782 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012783 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012784 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012785 }
12786
Govind Singhb53420c2016-03-09 14:32:57 +053012787 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012788}
12789
12790/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012791 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012792 * @wmi_handle: wmi handle
12793 * @msg: Dual MAC config parameters
12794 *
12795 * Configures WLAN firmware with the dual MAC features
12796 *
Govind Singhb53420c2016-03-09 14:32:57 +053012797 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012798 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012799static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012800QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012801 struct wmi_dual_mac_config *msg)
12802{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012803 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012804 wmi_buf_t buf;
12805 uint32_t len;
12806
12807 len = sizeof(*cmd);
12808
12809 buf = wmi_buf_alloc(wmi_handle, len);
12810 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012811 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12812 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012813 }
12814
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012815 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012816 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012817 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012818 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012819 wmi_pdev_set_mac_config_cmd_fixed_param));
12820
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012821 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12822 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012823 cmd->concurrent_scan_config_bits = msg->scan_config;
12824 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012825 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012826 __func__, msg->scan_config, msg->fw_mode_config);
12827
12828 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012829 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12830 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012831 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012832 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012833 }
Govind Singhb53420c2016-03-09 14:32:57 +053012834 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012835}
12836
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012837#ifdef BIG_ENDIAN_HOST
12838/**
12839* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12840* @param data_len - data length
12841* @param data - pointer to data
12842*
12843* Return: QDF_STATUS - success or error status
12844*/
12845static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12846 struct fips_params *param)
12847{
12848 unsigned char *key_unaligned, *data_unaligned;
12849 int c;
12850 u_int8_t *key_aligned = NULL;
12851 u_int8_t *data_aligned = NULL;
12852
12853 /* Assigning unaligned space to copy the key */
12854 key_unaligned = qdf_mem_malloc(
12855 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12856 data_unaligned = qdf_mem_malloc(
12857 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12858
12859 /* Checking if kmalloc is succesful to allocate space */
12860 if (key_unaligned == NULL)
12861 return QDF_STATUS_SUCCESS;
12862 /* Checking if space is aligned */
12863 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12864 /* align to 4 */
12865 key_aligned =
12866 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12867 FIPS_ALIGN);
12868 } else {
12869 key_aligned = (u_int8_t *)key_unaligned;
12870 }
12871
12872 /* memset and copy content from key to key aligned */
12873 OS_MEMSET(key_aligned, 0, param->key_len);
12874 OS_MEMCPY(key_aligned, param->key, param->key_len);
12875
12876 /* print a hexdump for host debug */
12877 print_hex_dump(KERN_DEBUG,
12878 "\t Aligned and Copied Key:@@@@ ",
12879 DUMP_PREFIX_NONE,
12880 16, 1, key_aligned, param->key_len, true);
12881
12882 /* Checking if kmalloc is succesful to allocate space */
12883 if (data_unaligned == NULL)
12884 return QDF_STATUS_SUCCESS;
12885 /* Checking of space is aligned */
12886 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12887 /* align to 4 */
12888 data_aligned =
12889 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12890 FIPS_ALIGN);
12891 } else {
12892 data_aligned = (u_int8_t *)data_unaligned;
12893 }
12894
12895 /* memset and copy content from data to data aligned */
12896 OS_MEMSET(data_aligned, 0, param->data_len);
12897 OS_MEMCPY(data_aligned, param->data, param->data_len);
12898
12899 /* print a hexdump for host debug */
12900 print_hex_dump(KERN_DEBUG,
12901 "\t Properly Aligned and Copied Data:@@@@ ",
12902 DUMP_PREFIX_NONE,
12903 16, 1, data_aligned, param->data_len, true);
12904
12905 /* converting to little Endian both key_aligned and
12906 * data_aligned*/
12907 for (c = 0; c < param->key_len/4; c++) {
12908 *((u_int32_t *)key_aligned+c) =
12909 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12910 }
12911 for (c = 0; c < param->data_len/4; c++) {
12912 *((u_int32_t *)data_aligned+c) =
12913 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12914 }
12915
12916 /* update endian data to key and data vectors */
12917 OS_MEMCPY(param->key, key_aligned, param->key_len);
12918 OS_MEMCPY(param->data, data_aligned, param->data_len);
12919
12920 /* clean up allocated spaces */
12921 qdf_mem_free(key_unaligned);
12922 key_unaligned = NULL;
12923 key_aligned = NULL;
12924
12925 qdf_mem_free(data_unaligned);
12926 data_unaligned = NULL;
12927 data_aligned = NULL;
12928
12929 return QDF_STATUS_SUCCESS;
12930}
12931#else
12932/**
12933* fips_align_data_be() - DUMMY for LE platform
12934*
12935* Return: QDF_STATUS - success
12936*/
12937static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12938 struct fips_params *param)
12939{
12940 return QDF_STATUS_SUCCESS;
12941}
12942#endif
12943
12944
12945/**
12946 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12947 * @wmi_handle: wmi handle
12948 * @param: pointer to hold pdev fips param
12949 *
12950 * Return: 0 for success or error code
12951 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012952static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012953send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12954 struct fips_params *param)
12955{
12956 wmi_pdev_fips_cmd_fixed_param *cmd;
12957 wmi_buf_t buf;
12958 uint8_t *buf_ptr;
12959 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12960 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12961
12962 /* Length TLV placeholder for array of bytes */
12963 len += WMI_TLV_HDR_SIZE;
12964 if (param->data_len)
12965 len += (param->data_len*sizeof(uint8_t));
12966
12967 /*
12968 * Data length must be multiples of 16 bytes - checked against 0xF -
12969 * and must be less than WMI_SVC_MSG_SIZE - static size of
12970 * wmi_pdev_fips_cmd structure
12971 */
12972
12973 /* do sanity on the input */
12974 if (!(((param->data_len & 0xF) == 0) &&
12975 ((param->data_len > 0) &&
12976 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12977 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12978 return QDF_STATUS_E_INVAL;
12979 }
12980
12981 buf = wmi_buf_alloc(wmi_handle, len);
12982 if (!buf) {
12983 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12984 return QDF_STATUS_E_FAILURE;
12985 }
12986
12987 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12988 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12989 WMITLV_SET_HDR(&cmd->tlv_header,
12990 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12991 WMITLV_GET_STRUCT_TLVLEN
12992 (wmi_pdev_fips_cmd_fixed_param));
12993
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012994 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12995 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012996 if (param->key != NULL && param->data != NULL) {
12997 cmd->key_len = param->key_len;
12998 cmd->data_len = param->data_len;
12999 cmd->fips_cmd = !!(param->op);
13000
13001 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13002 return QDF_STATUS_E_FAILURE;
13003
13004 qdf_mem_copy(cmd->key, param->key, param->key_len);
13005
13006 if (param->mode == FIPS_ENGINE_AES_CTR ||
13007 param->mode == FIPS_ENGINE_AES_MIC) {
13008 cmd->mode = param->mode;
13009 } else {
13010 cmd->mode = FIPS_ENGINE_AES_CTR;
13011 }
13012 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13013 cmd->key_len, cmd->data_len);
13014
13015 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13016 cmd->key, cmd->key_len, true);
13017 buf_ptr += sizeof(*cmd);
13018
13019 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13020
13021 buf_ptr += WMI_TLV_HDR_SIZE;
13022 if (param->data_len)
13023 qdf_mem_copy(buf_ptr,
13024 (uint8_t *) param->data, param->data_len);
13025
13026 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13027 16, 1, buf_ptr, cmd->data_len, true);
13028
13029 buf_ptr += param->data_len;
13030
13031 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13032 WMI_PDEV_FIPS_CMDID);
13033 qdf_print("%s return value %d\n", __func__, retval);
13034 } else {
13035 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13036 wmi_buf_free(buf);
13037 retval = -QDF_STATUS_E_BADMSG;
13038 }
13039
13040 return retval;
13041}
13042
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013043#ifdef WLAN_PMO_ENABLE
13044/**
13045 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13046 * @wmi_handle: wmi handle
13047 * @vdev_id: vdev id
13048 * @bitmap: Event bitmap
13049 * @enable: enable/disable
13050 *
13051 * Return: CDF status
13052 */
13053static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13054 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013055 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013056 bool enable)
13057{
13058 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13059 uint16_t len;
13060 wmi_buf_t buf;
13061 int ret;
13062
13063 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13064 buf = wmi_buf_alloc(wmi_handle, len);
13065 if (!buf) {
13066 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13067 return QDF_STATUS_E_NOMEM;
13068 }
13069 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13070 WMITLV_SET_HDR(&cmd->tlv_header,
13071 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13072 WMITLV_GET_STRUCT_TLVLEN
13073 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13074 cmd->vdev_id = vdev_id;
13075 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013076 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13077 WMI_WOW_MAX_EVENT_BM_LEN);
13078
13079 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13080 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13081 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013082
13083 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13084 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13085 if (ret) {
13086 WMI_LOGE("Failed to config wow wakeup event");
13087 wmi_buf_free(buf);
13088 return QDF_STATUS_E_FAILURE;
13089 }
13090
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013091 return QDF_STATUS_SUCCESS;
13092}
13093
13094/**
13095 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13096 * @wmi_handle: wmi handle
13097 * @vdev_id: vdev id
13098 * @ptrn_id: pattern id
13099 * @ptrn: pattern
13100 * @ptrn_len: pattern length
13101 * @ptrn_offset: pattern offset
13102 * @mask: mask
13103 * @mask_len: mask length
13104 * @user: true for user configured pattern and false for default pattern
13105 * @default_patterns: default patterns
13106 *
13107 * Return: CDF status
13108 */
13109static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13110 uint8_t vdev_id, uint8_t ptrn_id,
13111 const uint8_t *ptrn, uint8_t ptrn_len,
13112 uint8_t ptrn_offset, const uint8_t *mask,
13113 uint8_t mask_len, bool user,
13114 uint8_t default_patterns)
13115{
13116 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13117 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13118 wmi_buf_t buf;
13119 uint8_t *buf_ptr;
13120 int32_t len;
13121 int ret;
13122
13123 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13124 WMI_TLV_HDR_SIZE +
13125 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13126 WMI_TLV_HDR_SIZE +
13127 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13128 WMI_TLV_HDR_SIZE +
13129 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13130 WMI_TLV_HDR_SIZE +
13131 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13132 WMI_TLV_HDR_SIZE +
13133 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13134
13135 buf = wmi_buf_alloc(wmi_handle, len);
13136 if (!buf) {
13137 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13138 return QDF_STATUS_E_NOMEM;
13139 }
13140
13141 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13142 buf_ptr = (uint8_t *) cmd;
13143
13144 WMITLV_SET_HDR(&cmd->tlv_header,
13145 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13146 WMITLV_GET_STRUCT_TLVLEN
13147 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13148 cmd->vdev_id = vdev_id;
13149 cmd->pattern_id = ptrn_id;
13150
13151 cmd->pattern_type = WOW_BITMAP_PATTERN;
13152 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13153
13154 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13155 sizeof(WOW_BITMAP_PATTERN_T));
13156 buf_ptr += WMI_TLV_HDR_SIZE;
13157 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13158
13159 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13160 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13161 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13162
13163 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13164 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13165
13166 bitmap_pattern->pattern_offset = ptrn_offset;
13167 bitmap_pattern->pattern_len = ptrn_len;
13168
13169 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13170 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13171
13172 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13173 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13174
13175 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13176 bitmap_pattern->pattern_id = ptrn_id;
13177
13178 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13179 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13180 bitmap_pattern->pattern_offset, user);
13181 WMI_LOGI("Pattern : ");
13182 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13183 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13184
13185 WMI_LOGI("Mask : ");
13186 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13187 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13188
13189 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13190
13191 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13192 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13193 buf_ptr += WMI_TLV_HDR_SIZE;
13194
13195 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13197 buf_ptr += WMI_TLV_HDR_SIZE;
13198
13199 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13200 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13201 buf_ptr += WMI_TLV_HDR_SIZE;
13202
13203 /* Fill TLV for pattern_info_timeout but no data. */
13204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13205 buf_ptr += WMI_TLV_HDR_SIZE;
13206
13207 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
13208 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
13209 buf_ptr += WMI_TLV_HDR_SIZE;
13210 *(A_UINT32 *) buf_ptr = 0;
13211
13212 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13213 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13214 if (ret) {
13215 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13216 wmi_buf_free(buf);
13217 return QDF_STATUS_E_FAILURE;
13218 }
13219
13220 return QDF_STATUS_SUCCESS;
13221}
13222
Govind Singha4836fd2016-03-07 16:45:38 +053013223/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013224 * fill_arp_offload_params_tlv() - Fill ARP offload data
13225 * @wmi_handle: wmi handle
13226 * @offload_req: offload request
13227 * @buf_ptr: buffer pointer
13228 *
13229 * To fill ARP offload data to firmware
13230 * when target goes to wow mode.
13231 *
13232 * Return: None
13233 */
13234static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013235 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013236{
13237
13238 int i;
13239 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013240 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013241
13242 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13243 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13244 *buf_ptr += WMI_TLV_HDR_SIZE;
13245 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13246 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13247 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13248 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13249 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13250
13251 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013252 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013253 /* Copy the target ip addr and flags */
13254 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13255 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013256 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013257 WMI_IPV4_ADDR_LEN);
13258 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013259 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013260 }
13261 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13262 }
13263}
13264
13265#ifdef WLAN_NS_OFFLOAD
13266/**
13267 * fill_ns_offload_params_tlv() - Fill NS offload data
13268 * @wmi|_handle: wmi handle
13269 * @offload_req: offload request
13270 * @buf_ptr: buffer pointer
13271 *
13272 * To fill NS offload data to firmware
13273 * when target goes to wow mode.
13274 *
13275 * Return: None
13276 */
13277static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013278 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013279{
13280
13281 int i;
13282 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013283
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013284 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13285 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13286 *buf_ptr += WMI_TLV_HDR_SIZE;
13287 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13288 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13289 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13290 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13291 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13292
13293 /*
13294 * Fill data only for NS offload in the first ARP tuple for LA
13295 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013296 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013297 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13298 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013299 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013300 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013301 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013302 sizeof(WMI_IPV6_ADDR));
13303 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013304 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013305 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013306 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013307 ns_tuple->flags |=
13308 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13309 }
13310 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013311 i, &ns_req->self_ipv6_addr[i],
13312 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013313
13314 /* target MAC is optional, check if it is valid,
13315 * if this is not valid, the target will use the known
13316 * local MAC address rather than the tuple
13317 */
13318 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013319 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013320 &ns_tuple->target_mac);
13321 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13322 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13323 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13324 }
13325 }
13326 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13327 }
13328}
13329
13330
13331/**
13332 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13333 * @wmi: wmi handle
13334 * @offload_req: offload request
13335 * @buf_ptr: buffer pointer
13336 *
13337 * To fill extended NS offload extended data to firmware
13338 * when target goes to wow mode.
13339 *
13340 * Return: None
13341 */
13342static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013343 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013344{
13345 int i;
13346 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13347 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013348
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013349 count = ns_req->num_ns_offload_count;
13350 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013351 WMI_MAX_NS_OFFLOADS;
13352
13353 /* Populate extended NS offload tuples */
13354 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13355 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13356 *buf_ptr += WMI_TLV_HDR_SIZE;
13357 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13358 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13359 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13360 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13361 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13362
13363 /*
13364 * Fill data only for NS offload in the first ARP tuple for LA
13365 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013366 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013367 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13368 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013369 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013370 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013371 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013372 sizeof(WMI_IPV6_ADDR));
13373 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013374 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013375 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013376 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013377 ns_tuple->flags |=
13378 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13379 }
13380 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013381 i, &ns_req->self_ipv6_addr[i],
13382 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013383
13384 /* target MAC is optional, check if it is valid,
13385 * if this is not valid, the target will use the
13386 * known local MAC address rather than the tuple
13387 */
13388 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013389 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013390 &ns_tuple->target_mac);
13391 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13392 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13393 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13394 }
13395 }
13396 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13397 }
13398}
13399#else
13400static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013401 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013402{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013403}
13404
13405static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013406 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013407{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013408}
13409#endif
13410
13411/**
Govind Singha4836fd2016-03-07 16:45:38 +053013412 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13413 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013414 * @arp_offload_req: arp offload request
13415 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013416 * @arp_only: flag
13417 *
13418 * To configure ARP NS off load data to firmware
13419 * when target goes to wow mode.
13420 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013421 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013422 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013423static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013424 struct pmo_arp_offload_params *arp_offload_req,
13425 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013426 uint8_t vdev_id)
13427{
Govind Singha4836fd2016-03-07 16:45:38 +053013428 int32_t res;
13429 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013430 A_UINT8 *buf_ptr;
13431 wmi_buf_t buf;
13432 int32_t len;
13433 uint32_t count = 0, num_ns_ext_tuples = 0;
13434
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013435 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013436
Govind Singha4836fd2016-03-07 16:45:38 +053013437 /*
13438 * TLV place holder size for array of NS tuples
13439 * TLV place holder size for array of ARP tuples
13440 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013441 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13442 WMI_TLV_HDR_SIZE +
13443 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13444 WMI_TLV_HDR_SIZE +
13445 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013446
13447 /*
13448 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13449 * extra length for extended NS offload tuples which follows ARP offload
13450 * tuples. Host needs to fill this structure in following format:
13451 * 2 NS ofload tuples
13452 * 2 ARP offload tuples
13453 * N numbers of extended NS offload tuples if HDD has given more than
13454 * 2 NS offload addresses
13455 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013456 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013457 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013458 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13459 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013460 }
13461
13462 buf = wmi_buf_alloc(wmi_handle, len);
13463 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013464 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013465 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013466 }
13467
13468 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13469 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13470 WMITLV_SET_HDR(&cmd->tlv_header,
13471 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13472 WMITLV_GET_STRUCT_TLVLEN
13473 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13474 cmd->flags = 0;
13475 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013476 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013477
Govind Singhb53420c2016-03-09 14:32:57 +053013478 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013479
Govind Singha4836fd2016-03-07 16:45:38 +053013480 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013481 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13482 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13483 if (num_ns_ext_tuples)
13484 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013485
13486 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13487 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13488 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013489 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013490 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013491 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013492 }
13493
Govind Singhb53420c2016-03-09 14:32:57 +053013494 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013495}
13496
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013497/**
13498 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13499 * @wmi_handle: wmi handle
13500 * @vdev_id: vdev id
13501 * @action: true for enable else false
13502 *
13503 * To enable enhance multicast offload to firmware
13504 * when target goes to wow mode.
13505 *
13506 * Return: QDF Status
13507 */
13508
13509static
13510QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13511 wmi_unified_t wmi_handle,
13512 uint8_t vdev_id, bool action)
13513{
13514 QDF_STATUS status;
13515 wmi_buf_t buf;
13516 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13517
13518 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13519 if (!buf) {
13520 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13521 return QDF_STATUS_E_NOMEM;
13522 }
13523
13524 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13525 wmi_buf_data(buf);
13526
13527 WMITLV_SET_HDR(&cmd->tlv_header,
13528 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13529 WMITLV_GET_STRUCT_TLVLEN(
13530 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13531
13532 cmd->vdev_id = vdev_id;
13533 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13534 ENHANCED_MCAST_FILTER_ENABLED);
13535 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13536 __func__, action, vdev_id);
13537 status = wmi_unified_cmd_send(wmi_handle, buf,
13538 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13539 if (status != QDF_STATUS_SUCCESS) {
13540 qdf_nbuf_free(buf);
13541 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13542 __func__);
13543 }
13544
13545 return status;
13546}
13547
13548/**
13549 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13550 * @wmi_handle: wmi handle
13551 * @param evt_buf: pointer to event buffer
13552 * @param hdr: Pointer to hold header
13553 * @param bufp: Pointer to hold pointer to rx param buffer
13554 *
13555 * Return: QDF_STATUS_SUCCESS for success or error code
13556 */
13557static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13558 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13559{
13560 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13561 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13562
13563 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13564 if (!param_buf) {
13565 WMI_LOGE("gtk param_buf is NULL");
13566 return QDF_STATUS_E_INVAL;
13567 }
13568
13569 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13570 WMI_LOGE("Invalid length for GTK status");
13571 return QDF_STATUS_E_INVAL;
13572 }
13573
13574 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13575 param_buf->fixed_param;
13576 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13577 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13578 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13579 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13580 &fixed_param->replay_counter,
13581 GTK_REPLAY_COUNTER_BYTES);
13582
13583 return QDF_STATUS_SUCCESS;
13584
13585}
13586
13587#ifdef FEATURE_WLAN_RA_FILTERING
13588/**
13589 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13590 * @wmi_handle: wmi handle
13591 * @vdev_id: vdev id
13592 *
13593 * Return: CDF status
13594 */
13595static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13596 uint8_t vdev_id, uint8_t default_pattern,
13597 uint16_t rate_limit_interval)
13598{
13599
13600 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13601 wmi_buf_t buf;
13602 uint8_t *buf_ptr;
13603 int32_t len;
13604 int ret;
13605
13606 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13607 WMI_TLV_HDR_SIZE +
13608 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13609 WMI_TLV_HDR_SIZE +
13610 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13611 WMI_TLV_HDR_SIZE +
13612 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13613 WMI_TLV_HDR_SIZE +
13614 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13615 WMI_TLV_HDR_SIZE +
13616 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13617
13618 buf = wmi_buf_alloc(wmi_handle, len);
13619 if (!buf) {
13620 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13621 return QDF_STATUS_E_NOMEM;
13622 }
13623
13624 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13625 buf_ptr = (uint8_t *) cmd;
13626
13627 WMITLV_SET_HDR(&cmd->tlv_header,
13628 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13629 WMITLV_GET_STRUCT_TLVLEN
13630 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13631 cmd->vdev_id = vdev_id;
13632 cmd->pattern_id = default_pattern,
13633 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13634 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13635
13636 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13638 buf_ptr += WMI_TLV_HDR_SIZE;
13639
13640 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13642 buf_ptr += WMI_TLV_HDR_SIZE;
13643
13644 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13646 buf_ptr += WMI_TLV_HDR_SIZE;
13647
13648 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13649 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13650 buf_ptr += WMI_TLV_HDR_SIZE;
13651
13652 /* Fill TLV for pattern_info_timeout but no data. */
13653 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13654 buf_ptr += WMI_TLV_HDR_SIZE;
13655
13656 /* Fill TLV for ra_ratelimit_interval. */
13657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13658 buf_ptr += WMI_TLV_HDR_SIZE;
13659
13660 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13661
13662 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13663 rate_limit_interval, vdev_id);
13664
13665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13666 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13667 if (ret) {
13668 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13669 wmi_buf_free(buf);
13670 return QDF_STATUS_E_FAILURE;
13671 }
13672
13673 return QDF_STATUS_SUCCESS;
13674
13675}
13676#endif /* FEATURE_WLAN_RA_FILTERING */
13677
13678/**
13679 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13680 * @wmi_handle: wmi handle
13681 * @vdev_id: vdev id
13682 * @multicastAddr: mcast address
13683 * @clearList: clear list flag
13684 *
13685 * Return: QDF_STATUS_SUCCESS for success or error code
13686 */
13687static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13688 uint8_t vdev_id,
13689 struct qdf_mac_addr multicast_addr,
13690 bool clearList)
13691{
13692 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13693 wmi_buf_t buf;
13694 int err;
13695
13696 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13697 if (!buf) {
13698 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13699 return QDF_STATUS_E_NOMEM;
13700 }
13701
13702 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13703 qdf_mem_zero(cmd, sizeof(*cmd));
13704
13705 WMITLV_SET_HDR(&cmd->tlv_header,
13706 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13707 WMITLV_GET_STRUCT_TLVLEN
13708 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13709 cmd->action =
13710 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13711 cmd->vdev_id = vdev_id;
13712 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13713
13714 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13715 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13716
13717 err = wmi_unified_cmd_send(wmi_handle, buf,
13718 sizeof(*cmd),
13719 WMI_SET_MCASTBCAST_FILTER_CMDID);
13720 if (err) {
13721 WMI_LOGE("Failed to send set_param cmd");
13722 wmi_buf_free(buf);
13723 return QDF_STATUS_E_FAILURE;
13724 }
13725
13726 return QDF_STATUS_SUCCESS;
13727}
13728
13729/**
13730 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13731 * @wmi_handle: wmi handle
13732 * @vdev_id: vdev id
13733 * @params: GTK offload parameters
13734 *
13735 * Return: CDF status
13736 */
13737static
13738QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13739 struct pmo_gtk_req *params,
13740 bool enable_offload,
13741 uint32_t gtk_offload_opcode)
13742{
13743 int len;
13744 wmi_buf_t buf;
13745 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13746 QDF_STATUS status = QDF_STATUS_SUCCESS;
13747
13748 WMI_LOGD("%s Enter", __func__);
13749
13750 len = sizeof(*cmd);
13751
13752 /* alloc wmi buffer */
13753 buf = wmi_buf_alloc(wmi_handle, len);
13754 if (!buf) {
13755 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13756 status = QDF_STATUS_E_NOMEM;
13757 goto out;
13758 }
13759
13760 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13761 WMITLV_SET_HDR(&cmd->tlv_header,
13762 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13763 WMITLV_GET_STRUCT_TLVLEN
13764 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13765
13766 cmd->vdev_id = vdev_id;
13767
13768 /* Request target to enable GTK offload */
13769 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13770 cmd->flags = gtk_offload_opcode;
13771
13772 /* Copy the keys and replay counter */
13773 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13774 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13775 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13776 GTK_REPLAY_COUNTER_BYTES);
13777 } else {
13778 cmd->flags = gtk_offload_opcode;
13779 }
13780
13781 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13782
13783 /* send the wmi command */
13784 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13785 WMI_GTK_OFFLOAD_CMDID)) {
13786 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13787 wmi_buf_free(buf);
13788 status = QDF_STATUS_E_FAILURE;
13789 }
13790
13791out:
13792 WMI_LOGD("%s Exit", __func__);
13793 return status;
13794}
13795
13796/**
13797 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13798 * @wmi_handle: wmi handle
13799 * @params: GTK offload params
13800 *
13801 * Return: CDF status
13802 */
13803static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13804 wmi_unified_t wmi_handle,
13805 uint8_t vdev_id,
13806 uint64_t offload_req_opcode)
13807{
13808 int len;
13809 wmi_buf_t buf;
13810 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13811 QDF_STATUS status = QDF_STATUS_SUCCESS;
13812
13813 len = sizeof(*cmd);
13814
13815 /* alloc wmi buffer */
13816 buf = wmi_buf_alloc(wmi_handle, len);
13817 if (!buf) {
13818 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13819 status = QDF_STATUS_E_NOMEM;
13820 goto out;
13821 }
13822
13823 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13824 WMITLV_SET_HDR(&cmd->tlv_header,
13825 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13826 WMITLV_GET_STRUCT_TLVLEN
13827 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13828
13829 /* Request for GTK offload status */
13830 cmd->flags = offload_req_opcode;
13831 cmd->vdev_id = vdev_id;
13832
13833 /* send the wmi command */
13834 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13835 WMI_GTK_OFFLOAD_CMDID)) {
13836 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13837 wmi_buf_free(buf);
13838 status = QDF_STATUS_E_FAILURE;
13839 }
13840
13841out:
13842 return status;
13843}
13844
13845/**
13846 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13847 * @wmi_handle: wmi handler
13848 * @action_params: pointer to action_params
13849 *
13850 * Return: 0 for success, otherwise appropriate error code
13851 */
13852static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13853 struct pmo_action_wakeup_set_params *action_params)
13854{
13855 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13856 wmi_buf_t buf;
13857 int i;
13858 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053013859 uint32_t len = 0, *cmd_args;
13860 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013861
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053013862 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
13863 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
13864 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013865 if (!buf) {
13866 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13867 return QDF_STATUS_E_NOMEM;
13868 }
13869 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053013870 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013871 WMITLV_SET_HDR(&cmd->tlv_header,
13872 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13873 WMITLV_GET_STRUCT_TLVLEN(
13874 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13875
13876 cmd->vdev_id = action_params->vdev_id;
13877 cmd->operation = action_params->operation;
13878
13879 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13880 cmd->action_category_map[i] =
13881 action_params->action_category_map[i];
13882
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053013883 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
13884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13885 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
13886 buf_ptr += WMI_TLV_HDR_SIZE;
13887 cmd_args = (uint32_t *) buf_ptr;
13888 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
13889 cmd_args[i] = action_params->action_per_category[i];
13890
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013891 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053013892 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013893 if (err) {
13894 WMI_LOGE("Failed to send ap_ps_egap cmd");
13895 wmi_buf_free(buf);
13896 return QDF_STATUS_E_FAILURE;
13897 }
13898
13899 return QDF_STATUS_SUCCESS;
13900}
13901
13902#ifdef FEATURE_WLAN_LPHB
13903
13904/**
13905 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13906 * @wmi_handle: wmi handle
13907 * @lphb_conf_req: configuration info
13908 *
13909 * Return: CDF status
13910 */
13911static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13912 wmi_hb_set_enable_cmd_fixed_param *params)
13913{
13914 QDF_STATUS status;
13915 wmi_buf_t buf = NULL;
13916 uint8_t *buf_ptr;
13917 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13918 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13919
13920
13921 buf = wmi_buf_alloc(wmi_handle, len);
13922 if (!buf) {
13923 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13924 return QDF_STATUS_E_NOMEM;
13925 }
13926
13927 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13928 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13929 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13930 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13931 WMITLV_GET_STRUCT_TLVLEN
13932 (wmi_hb_set_enable_cmd_fixed_param));
13933
13934 /* fill in values */
13935 hb_enable_fp->vdev_id = params->session;
13936 hb_enable_fp->enable = params->enable;
13937 hb_enable_fp->item = params->item;
13938 hb_enable_fp->session = params->session;
13939
13940 status = wmi_unified_cmd_send(wmi_handle, buf,
13941 len, WMI_HB_SET_ENABLE_CMDID);
13942 if (QDF_IS_STATUS_ERROR(status)) {
13943 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13944 status);
13945 wmi_buf_free(buf);
13946 }
13947
13948 return status;
13949}
13950
13951/**
13952 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13953 * @wmi_handle: wmi handle
13954 * @lphb_conf_req: lphb config request
13955 *
13956 * Return: CDF status
13957 */
13958static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13959 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13960{
13961 QDF_STATUS status;
13962 wmi_buf_t buf = NULL;
13963 uint8_t *buf_ptr;
13964 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13965 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13966
13967 buf = wmi_buf_alloc(wmi_handle, len);
13968 if (!buf) {
13969 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13970 return QDF_STATUS_E_NOMEM;
13971 }
13972
13973 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13974 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13975 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13976 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13977 WMITLV_GET_STRUCT_TLVLEN
13978 (wmi_hb_set_tcp_params_cmd_fixed_param));
13979
13980 /* fill in values */
13981 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13982 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13983 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13984 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13985 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13986 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13987 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13988 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13989 hb_tcp_params_fp->session = lphb_conf_req->session;
13990 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13991 &lphb_conf_req->gateway_mac,
13992 sizeof(hb_tcp_params_fp->gateway_mac));
13993
13994 status = wmi_unified_cmd_send(wmi_handle, buf,
13995 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13996 if (QDF_IS_STATUS_ERROR(status)) {
13997 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13998 status);
13999 wmi_buf_free(buf);
14000 }
14001
14002 return status;
14003}
14004
14005/**
14006 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14007 * @wmi_handle: wmi handle
14008 * @lphb_conf_req: lphb config request
14009 *
14010 * Return: CDF status
14011 */
14012static
14013QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14014 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14015{
14016 QDF_STATUS status;
14017 wmi_buf_t buf = NULL;
14018 uint8_t *buf_ptr;
14019 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14020 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14021
14022 buf = wmi_buf_alloc(wmi_handle, len);
14023 if (!buf) {
14024 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14025 return QDF_STATUS_E_NOMEM;
14026 }
14027
14028 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14029 hb_tcp_filter_fp =
14030 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14031 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14032 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14033 WMITLV_GET_STRUCT_TLVLEN
14034 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14035
14036 /* fill in values */
14037 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14038 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14039 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14040 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14041 memcpy((void *)&hb_tcp_filter_fp->filter,
14042 (void *)&g_hb_tcp_filter_fp->filter,
14043 WMI_WLAN_HB_MAX_FILTER_SIZE);
14044
14045 status = wmi_unified_cmd_send(wmi_handle, buf,
14046 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14047 if (QDF_IS_STATUS_ERROR(status)) {
14048 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14049 status);
14050 wmi_buf_free(buf);
14051 }
14052
14053 return status;
14054}
14055
14056/**
14057 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14058 * @wmi_handle: wmi handle
14059 * @lphb_conf_req: lphb config request
14060 *
14061 * Return: CDF status
14062 */
14063static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14064 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14065{
14066 QDF_STATUS status;
14067 wmi_buf_t buf = NULL;
14068 uint8_t *buf_ptr;
14069 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14070 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14071
14072 buf = wmi_buf_alloc(wmi_handle, len);
14073 if (!buf) {
14074 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14075 return QDF_STATUS_E_NOMEM;
14076 }
14077
14078 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14079 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14080 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14081 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14082 WMITLV_GET_STRUCT_TLVLEN
14083 (wmi_hb_set_udp_params_cmd_fixed_param));
14084
14085 /* fill in values */
14086 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14087 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14088 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14089 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14090 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14091 hb_udp_params_fp->interval = lphb_conf_req->interval;
14092 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14093 hb_udp_params_fp->session = lphb_conf_req->session;
14094 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14095 &lphb_conf_req->gateway_mac,
14096 sizeof(lphb_conf_req->gateway_mac));
14097
14098 status = wmi_unified_cmd_send(wmi_handle, buf,
14099 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14100 if (QDF_IS_STATUS_ERROR(status)) {
14101 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14102 status);
14103 wmi_buf_free(buf);
14104 }
14105
14106 return status;
14107}
14108
14109/**
14110 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14111 * @wmi_handle: wmi handle
14112 * @lphb_conf_req: lphb config request
14113 *
14114 * Return: CDF status
14115 */
14116static
14117QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14118 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14119{
14120 QDF_STATUS status;
14121 wmi_buf_t buf = NULL;
14122 uint8_t *buf_ptr;
14123 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14124 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14125
14126 buf = wmi_buf_alloc(wmi_handle, len);
14127 if (!buf) {
14128 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14129 return QDF_STATUS_E_NOMEM;
14130 }
14131
14132 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14133 hb_udp_filter_fp =
14134 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14135 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14136 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14137 WMITLV_GET_STRUCT_TLVLEN
14138 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14139
14140 /* fill in values */
14141 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14142 hb_udp_filter_fp->length = lphb_conf_req->length;
14143 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14144 hb_udp_filter_fp->session = lphb_conf_req->session;
14145 memcpy((void *)&hb_udp_filter_fp->filter,
14146 (void *)&lphb_conf_req->filter,
14147 WMI_WLAN_HB_MAX_FILTER_SIZE);
14148
14149 status = wmi_unified_cmd_send(wmi_handle, buf,
14150 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14151 if (QDF_IS_STATUS_ERROR(status)) {
14152 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14153 status);
14154 wmi_buf_free(buf);
14155 }
14156
14157 return status;
14158}
14159#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014160
Dustin Brownf31f88b2017-05-12 14:01:44 -070014161static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14162 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014163{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014164 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014165 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014166 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014167
Dustin Brownf31f88b2017-05-12 14:01:44 -070014168 if (!req) {
14169 WMI_LOGE("req is null");
14170 return QDF_STATUS_E_INVAL;
14171 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014172
Dustin Brownf31f88b2017-05-12 14:01:44 -070014173 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14174 if (!wmi_buf) {
14175 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014176 return QDF_STATUS_E_NOMEM;
14177 }
14178
Dustin Brownf31f88b2017-05-12 14:01:44 -070014179 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014180 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014181 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14182 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14183 cmd->vdev_id = req->vdev_id;
14184 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
14185 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014186
Dustin Brownf31f88b2017-05-12 14:01:44 -070014187 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
14188 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014189
Dustin Brownf31f88b2017-05-12 14:01:44 -070014190 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14191 WMI_HW_DATA_FILTER_CMDID);
14192 if (QDF_IS_STATUS_ERROR(status)) {
14193 WMI_LOGE("Failed to configure hw filter");
14194 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014195 }
14196
Dustin Brownf31f88b2017-05-12 14:01:44 -070014197 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014198}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014199
14200/**
14201 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14202 * @wmi_handle: wmi handle
14203 * @vdev_id: vdev id
14204 * @enable: Flag to enable/disable packet filter
14205 *
14206 * Return: QDF_STATUS_SUCCESS for success or error code
14207 */
14208static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14209 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14210{
14211 int32_t len;
14212 int ret = 0;
14213 wmi_buf_t buf;
14214 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14215
14216 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14217
14218 buf = wmi_buf_alloc(wmi_handle, len);
14219 if (!buf) {
14220 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14221 return QDF_STATUS_E_NOMEM;
14222 }
14223
14224 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14225 WMITLV_SET_HDR(&cmd->tlv_header,
14226 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14227 WMITLV_GET_STRUCT_TLVLEN(
14228 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14229
14230 cmd->vdev_id = vdev_id;
14231 if (enable)
14232 cmd->enable = PACKET_FILTER_SET_ENABLE;
14233 else
14234 cmd->enable = PACKET_FILTER_SET_DISABLE;
14235
14236 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14237 __func__, cmd->enable, vdev_id);
14238
14239 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14240 WMI_PACKET_FILTER_ENABLE_CMDID);
14241 if (ret) {
14242 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14243 wmi_buf_free(buf);
14244 }
14245
14246 return ret;
14247}
14248
14249/**
14250 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14251 * @wmi_handle: wmi handle
14252 * @vdev_id: vdev id
14253 * @rcv_filter_param: Packet filter parameters
14254 * @filter_id: Filter id
14255 * @enable: Flag to add/delete packet filter configuration
14256 *
14257 * Return: QDF_STATUS_SUCCESS for success or error code
14258 */
14259static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14260 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14261 uint8_t filter_id, bool enable)
14262{
14263 int len, i;
14264 int err = 0;
14265 wmi_buf_t buf;
14266 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14267
14268
14269 /* allocate the memory */
14270 len = sizeof(*cmd);
14271 buf = wmi_buf_alloc(wmi_handle, len);
14272 if (!buf) {
14273 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14274 return QDF_STATUS_E_NOMEM;
14275 }
14276
14277 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14278 WMITLV_SET_HDR(&cmd->tlv_header,
14279 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14280 WMITLV_GET_STRUCT_TLVLEN
14281 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14282
14283 cmd->vdev_id = vdev_id;
14284 cmd->filter_id = filter_id;
14285 if (enable)
14286 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14287 else
14288 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14289
14290 if (enable) {
14291 cmd->num_params = QDF_MIN(
14292 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14293 rcv_filter_param->num_params);
14294 cmd->filter_type = rcv_filter_param->filter_type;
14295 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14296
14297 for (i = 0; i < cmd->num_params; i++) {
14298 cmd->paramsData[i].proto_type =
14299 rcv_filter_param->params_data[i].protocol_layer;
14300 cmd->paramsData[i].cmp_type =
14301 rcv_filter_param->params_data[i].compare_flag;
14302 cmd->paramsData[i].data_length =
14303 rcv_filter_param->params_data[i].data_length;
14304 cmd->paramsData[i].data_offset =
14305 rcv_filter_param->params_data[i].data_offset;
14306 memcpy(&cmd->paramsData[i].compareData,
14307 rcv_filter_param->params_data[i].compare_data,
14308 sizeof(cmd->paramsData[i].compareData));
14309 memcpy(&cmd->paramsData[i].dataMask,
14310 rcv_filter_param->params_data[i].data_mask,
14311 sizeof(cmd->paramsData[i].dataMask));
14312 }
14313 }
14314
14315 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14316 cmd->filter_action, cmd->filter_id, cmd->num_params);
14317 /* send the command along with data */
14318 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14319 WMI_PACKET_FILTER_CONFIG_CMDID);
14320 if (err) {
14321 WMI_LOGE("Failed to send pkt_filter cmd");
14322 wmi_buf_free(buf);
14323 return QDF_STATUS_E_FAILURE;
14324 }
14325
14326 return QDF_STATUS_SUCCESS;
14327}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053014328#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014329
Govind Singha4836fd2016-03-07 16:45:38 +053014330/**
14331 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14332 * @wmi_handle: wmi handle
14333 * @request: SSID hotlist set request
14334 *
Govind Singhb53420c2016-03-09 14:32:57 +053014335 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014336 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014337static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014338send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14339 struct ssid_hotlist_request_params *request)
14340{
14341 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14342 wmi_buf_t wmi_buf;
14343 uint32_t len;
14344 uint32_t array_size;
14345 uint8_t *buf_ptr;
14346
14347 /* length of fixed portion */
14348 len = sizeof(*cmd);
14349
14350 /* length of variable portion */
14351 array_size =
14352 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14353 len += WMI_TLV_HDR_SIZE + array_size;
14354
14355 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14356 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014357 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14358 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014359 }
14360
14361 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14362 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14363 buf_ptr;
14364 WMITLV_SET_HDR
14365 (&cmd->tlv_header,
14366 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14367 WMITLV_GET_STRUCT_TLVLEN
14368 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14369
14370 cmd->request_id = request->request_id;
14371 cmd->requestor_id = 0;
14372 cmd->vdev_id = request->session_id;
14373 cmd->table_id = 0;
14374 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14375 cmd->total_entries = request->ssid_count;
14376 cmd->num_entries_in_page = request->ssid_count;
14377 cmd->first_entry_index = 0;
14378
14379 buf_ptr += sizeof(*cmd);
14380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14381
14382 if (request->ssid_count) {
14383 wmi_extscan_hotlist_ssid_entry *entry;
14384 int i;
14385
14386 buf_ptr += WMI_TLV_HDR_SIZE;
14387 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14388 for (i = 0; i < request->ssid_count; i++) {
14389 WMITLV_SET_HDR
14390 (entry,
14391 WMITLV_TAG_ARRAY_STRUC,
14392 WMITLV_GET_STRUCT_TLVLEN
14393 (wmi_extscan_hotlist_ssid_entry));
14394 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014395 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014396 request->ssids[i].ssid.mac_ssid,
14397 request->ssids[i].ssid.length);
14398 entry->band = request->ssids[i].band;
14399 entry->min_rssi = request->ssids[i].rssi_low;
14400 entry->max_rssi = request->ssids[i].rssi_high;
14401 entry++;
14402 }
14403 cmd->mode = WMI_EXTSCAN_MODE_START;
14404 } else {
14405 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14406 }
14407
14408 if (wmi_unified_cmd_send
14409 (wmi_handle, wmi_buf, len,
14410 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014411 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014412 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014413 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014414 }
14415
Govind Singhb53420c2016-03-09 14:32:57 +053014416 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014417}
14418
14419/**
14420 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14421 * @wmi_handle: wmi handle
14422 * @vdev_id: vdev id
14423 *
14424 * This function sends roam synch complete event to fw.
14425 *
14426 * Return: CDF STATUS
14427 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014428static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014429 uint8_t vdev_id)
14430{
14431 wmi_roam_synch_complete_fixed_param *cmd;
14432 wmi_buf_t wmi_buf;
14433 uint8_t *buf_ptr;
14434 uint16_t len;
14435 len = sizeof(wmi_roam_synch_complete_fixed_param);
14436
14437 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14438 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014439 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14440 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014441 }
14442 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14443 buf_ptr = (uint8_t *) cmd;
14444 WMITLV_SET_HDR(&cmd->tlv_header,
14445 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14446 WMITLV_GET_STRUCT_TLVLEN
14447 (wmi_roam_synch_complete_fixed_param));
14448 cmd->vdev_id = vdev_id;
14449 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14450 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014451 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014452 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014453 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014454 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014455 }
14456
Govind Singhb53420c2016-03-09 14:32:57 +053014457 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014458}
14459
14460/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014461 * send_fw_test_cmd_tlv() - send fw test command to fw.
14462 * @wmi_handle: wmi handle
14463 * @wmi_fwtest: fw test command
14464 *
14465 * This function sends fw test command to fw.
14466 *
14467 * Return: CDF STATUS
14468 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014469static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014470QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14471 struct set_fwtest_params *wmi_fwtest)
14472{
14473 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14474 wmi_buf_t wmi_buf;
14475 uint16_t len;
14476
14477 len = sizeof(*cmd);
14478
14479 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14480 if (!wmi_buf) {
14481 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14482 return QDF_STATUS_E_NOMEM;
14483 }
14484
14485 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14486 WMITLV_SET_HDR(&cmd->tlv_header,
14487 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14488 WMITLV_GET_STRUCT_TLVLEN(
14489 wmi_fwtest_set_param_cmd_fixed_param));
14490 cmd->param_id = wmi_fwtest->arg;
14491 cmd->param_value = wmi_fwtest->value;
14492
14493 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14494 WMI_FWTEST_CMDID)) {
14495 WMI_LOGP("%s: failed to send fw test command", __func__);
14496 qdf_nbuf_free(wmi_buf);
14497 return QDF_STATUS_E_FAILURE;
14498 }
14499
14500 return QDF_STATUS_SUCCESS;
14501}
14502
14503/**
Govind Singha4836fd2016-03-07 16:45:38 +053014504 * send_unit_test_cmd_tlv() - send unit test command to fw.
14505 * @wmi_handle: wmi handle
14506 * @wmi_utest: unit test command
14507 *
14508 * This function send unit test command to fw.
14509 *
14510 * Return: CDF STATUS
14511 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014512static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014513 struct wmi_unit_test_cmd *wmi_utest)
14514{
14515 wmi_unit_test_cmd_fixed_param *cmd;
14516 wmi_buf_t wmi_buf;
14517 uint8_t *buf_ptr;
14518 int i;
14519 uint16_t len, args_tlv_len;
14520 A_UINT32 *unit_test_cmd_args;
14521
14522 args_tlv_len =
14523 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14524 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14525
14526 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14527 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014528 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14529 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014530 }
14531
14532 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14533 buf_ptr = (uint8_t *) cmd;
14534 WMITLV_SET_HDR(&cmd->tlv_header,
14535 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14536 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14537 cmd->vdev_id = wmi_utest->vdev_id;
14538 cmd->module_id = wmi_utest->module_id;
14539 cmd->num_args = wmi_utest->num_args;
14540 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14542 (wmi_utest->num_args * sizeof(uint32_t)));
14543 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014544 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014545 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14546 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014547 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014548 }
14549 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14550 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014551 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014552 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014553 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014554 }
14555
Govind Singhb53420c2016-03-09 14:32:57 +053014556 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014557}
14558
14559/**
14560 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14561 * @wmi_handle: wma handle
14562 * @roaminvoke: roam invoke command
14563 *
14564 * Send roam invoke command to fw for fastreassoc.
14565 *
14566 * Return: CDF STATUS
14567 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014568static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014569 struct wmi_roam_invoke_cmd *roaminvoke,
14570 uint32_t ch_hz)
14571{
14572 wmi_roam_invoke_cmd_fixed_param *cmd;
14573 wmi_buf_t wmi_buf;
14574 u_int8_t *buf_ptr;
14575 u_int16_t len, args_tlv_len;
14576 A_UINT32 *channel_list;
14577 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014578 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014579
14580 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014581 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14582 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14583 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014584 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14585 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14586 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014587 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14588 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014589 }
14590
14591 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14592 buf_ptr = (u_int8_t *) cmd;
14593 WMITLV_SET_HDR(&cmd->tlv_header,
14594 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14595 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14596 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014597 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014598
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014599 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080014600 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014601 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14602 cmd->num_buf = 1;
14603 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080014604 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014605 cmd->num_buf = 0;
14606 }
Naveen Rawat77797922017-01-20 17:00:07 -080014607
Govind Singha4836fd2016-03-07 16:45:38 +053014608 cmd->roam_ap_sel_mode = 0;
14609 cmd->roam_delay = 0;
14610 cmd->num_chan = 1;
14611 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014612
Govind Singha4836fd2016-03-07 16:45:38 +053014613 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14614 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14615 (sizeof(u_int32_t)));
14616 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14617 *channel_list = ch_hz;
14618 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14620 (sizeof(wmi_mac_addr)));
14621 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14622 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014623
14624 /* move to next tlv i.e. bcn_prb_buf_list */
14625 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14626
14627 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14628 sizeof(wmi_tlv_buf_len_param));
14629
14630 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14631 buf_len_tlv->buf_len = roaminvoke->frame_len;
14632
14633 /* move to next tlv i.e. bcn_prb_frm */
14634 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14636 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14637
14638 /* copy frame after the header */
14639 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14640 roaminvoke->frame_buf,
14641 roaminvoke->frame_len);
14642
14643 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14644 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14645 buf_ptr + WMI_TLV_HDR_SIZE,
14646 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014647 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
14648 cmd->flags, cmd->roam_scan_mode,
14649 cmd->roam_ap_sel_mode, cmd->roam_delay,
14650 cmd->num_chan, cmd->num_bssid);
14651 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080014652
Govind Singha4836fd2016-03-07 16:45:38 +053014653 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14654 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014655 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014656 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014657 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014658 }
14659
Govind Singhb53420c2016-03-09 14:32:57 +053014660 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014661}
14662
14663/**
14664 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14665 * @wmi_handle: wmi handle
14666 * @command: command
14667 * @vdev_id: vdev id
14668 *
14669 * This function set roam offload command to fw.
14670 *
14671 * Return: CDF status
14672 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014673static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014674 uint32_t command, uint32_t vdev_id)
14675{
Govind Singh67922e82016-04-01 16:48:57 +053014676 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014677 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14678 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014679 int len;
14680 uint8_t *buf_ptr;
14681
14682 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14683 buf = wmi_buf_alloc(wmi_handle, len);
14684 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014685 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14686 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014687 }
14688
14689 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14690
14691 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14692 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14693 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14694 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14695 cmd_fp->vdev_id = vdev_id;
14696 cmd_fp->command_arg = command;
14697
14698 status = wmi_unified_cmd_send(wmi_handle, buf,
14699 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014700 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014701 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014702 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014703 goto error;
14704 }
14705
Govind Singhb53420c2016-03-09 14:32:57 +053014706 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14707 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014708
14709error:
14710 wmi_buf_free(buf);
14711
Govind Singh67922e82016-04-01 16:48:57 +053014712 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014713}
14714
14715/**
14716 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14717 * @wmi_handle: wmi handle
14718 * @ap_profile_p: ap profile
14719 * @vdev_id: vdev id
14720 *
14721 * Send WMI_ROAM_AP_PROFILE to firmware
14722 *
14723 * Return: CDF status
14724 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014725static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014726 wmi_ap_profile *ap_profile_p,
14727 uint32_t vdev_id)
14728{
Govind Singha4836fd2016-03-07 16:45:38 +053014729 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014730 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014731 int len;
14732 uint8_t *buf_ptr;
14733 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14734
14735 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14736
14737 buf = wmi_buf_alloc(wmi_handle, len);
14738 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014739 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14740 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014741 }
14742
14743 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14744 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14745 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14746 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14747 WMITLV_GET_STRUCT_TLVLEN
14748 (wmi_roam_ap_profile_fixed_param));
14749 /* fill in threshold values */
14750 roam_ap_profile_fp->vdev_id = vdev_id;
14751 roam_ap_profile_fp->id = 0;
14752 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14753
Govind Singhb53420c2016-03-09 14:32:57 +053014754 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014755 WMITLV_SET_HDR(buf_ptr,
14756 WMITLV_TAG_STRUC_wmi_ap_profile,
14757 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14758 status = wmi_unified_cmd_send(wmi_handle, buf,
14759 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014760 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014761 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014762 status);
Govind Singh67922e82016-04-01 16:48:57 +053014763 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014764 }
14765
Govind Singhb53420c2016-03-09 14:32:57 +053014766 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014767
Govind Singh67922e82016-04-01 16:48:57 +053014768 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014769}
14770
14771/**
14772 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14773 * @wmi_handle: wmi handle
14774 * @scan_period: scan period
14775 * @scan_age: scan age
14776 * @vdev_id: vdev id
14777 *
14778 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14779 *
14780 * Return: CDF status
14781 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014782static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014783 uint32_t scan_period,
14784 uint32_t scan_age,
14785 uint32_t vdev_id)
14786{
Govind Singh67922e82016-04-01 16:48:57 +053014787 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014788 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014789 int len;
14790 uint8_t *buf_ptr;
14791 wmi_roam_scan_period_fixed_param *scan_period_fp;
14792
14793 /* Send scan period values */
14794 len = sizeof(wmi_roam_scan_period_fixed_param);
14795 buf = wmi_buf_alloc(wmi_handle, len);
14796 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014797 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14798 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014799 }
14800
14801 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14802 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14803 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14804 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14805 WMITLV_GET_STRUCT_TLVLEN
14806 (wmi_roam_scan_period_fixed_param));
14807 /* fill in scan period values */
14808 scan_period_fp->vdev_id = vdev_id;
14809 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14810 scan_period_fp->roam_scan_age = scan_age;
14811
14812 status = wmi_unified_cmd_send(wmi_handle, buf,
14813 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014814 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014815 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014816 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014817 goto error;
14818 }
14819
Govind Singhb53420c2016-03-09 14:32:57 +053014820 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014821 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014822 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014823error:
14824 wmi_buf_free(buf);
14825
Govind Singh67922e82016-04-01 16:48:57 +053014826 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014827}
14828
14829/**
14830 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14831 * @wmi_handle: wmi handle
14832 * @chan_count: channel count
14833 * @chan_list: channel list
14834 * @list_type: list type
14835 * @vdev_id: vdev id
14836 *
14837 * Set roam offload channel list.
14838 *
14839 * Return: CDF status
14840 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014841static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014842 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014843 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014844 uint8_t list_type, uint32_t vdev_id)
14845{
Govind Singha4836fd2016-03-07 16:45:38 +053014846 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014847 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014848 int len, list_tlv_len;
14849 int i;
14850 uint8_t *buf_ptr;
14851 wmi_roam_chan_list_fixed_param *chan_list_fp;
14852 A_UINT32 *roam_chan_list_array;
14853
14854 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014855 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014856 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014857 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014858 }
14859 /* Channel list is a table of 2 TLV's */
14860 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14861 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14862 buf = wmi_buf_alloc(wmi_handle, len);
14863 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014864 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14865 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014866 }
14867
14868 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14869 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14870 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14871 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14872 WMITLV_GET_STRUCT_TLVLEN
14873 (wmi_roam_chan_list_fixed_param));
14874 chan_list_fp->vdev_id = vdev_id;
14875 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014876 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014877 /* external app is controlling channel list */
14878 chan_list_fp->chan_list_type =
14879 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14880 } else {
14881 /* umac supplied occupied channel list in LFR */
14882 chan_list_fp->chan_list_type =
14883 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14884 }
14885
14886 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14887 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14888 (chan_list_fp->num_chan * sizeof(uint32_t)));
14889 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014890 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014891 for (i = 0; ((i < chan_list_fp->num_chan) &&
14892 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14893 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014894 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014895 }
14896
14897 status = wmi_unified_cmd_send(wmi_handle, buf,
14898 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014899 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014900 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014901 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014902 goto error;
14903 }
14904
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014905 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014906 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014907error:
14908 wmi_buf_free(buf);
14909
Govind Singh67922e82016-04-01 16:48:57 +053014910 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014911}
14912
14913/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014914 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14915 * @wmi_handle: wmi handle
14916 * @req_buf: per roam config buffer
14917 *
14918 * Return: QDF status
14919 */
14920static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14921 struct wmi_per_roam_config_req *req_buf)
14922{
14923 wmi_buf_t buf = NULL;
14924 QDF_STATUS status;
14925 int len;
14926 uint8_t *buf_ptr;
14927 wmi_roam_per_config_fixed_param *wmi_per_config;
14928
14929 len = sizeof(wmi_roam_per_config_fixed_param);
14930 buf = wmi_buf_alloc(wmi_handle, len);
14931 if (!buf) {
14932 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14933 return QDF_STATUS_E_NOMEM;
14934 }
14935
14936 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14937 wmi_per_config =
14938 (wmi_roam_per_config_fixed_param *) buf_ptr;
14939 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14940 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14941 WMITLV_GET_STRUCT_TLVLEN
14942 (wmi_roam_per_config_fixed_param));
14943
14944 /* fill in per roam config values */
14945 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014946
14947 wmi_per_config->enable = req_buf->per_config.enable;
14948 wmi_per_config->high_rate_thresh =
14949 (req_buf->per_config.tx_high_rate_thresh << 16) |
14950 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14951 wmi_per_config->low_rate_thresh =
14952 (req_buf->per_config.tx_low_rate_thresh << 16) |
14953 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14954 wmi_per_config->pkt_err_rate_thresh_pct =
14955 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14956 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14957 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014958 wmi_per_config->pkt_err_rate_mon_time =
14959 (req_buf->per_config.tx_per_mon_time << 16) |
14960 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014961 wmi_per_config->min_candidate_rssi =
14962 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014963
14964 /* Send per roam config parameters */
14965 status = wmi_unified_cmd_send(wmi_handle, buf,
14966 len, WMI_ROAM_PER_CONFIG_CMDID);
14967 if (QDF_IS_STATUS_ERROR(status)) {
14968 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14969 status);
14970 wmi_buf_free(buf);
14971 return status;
14972 }
14973
14974 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14975 req_buf->per_config.enable, req_buf->vdev_id);
14976 return QDF_STATUS_SUCCESS;
14977}
14978
14979/**
Govind Singha4836fd2016-03-07 16:45:38 +053014980 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14981 * @wmi_handle: wmi handle
14982 * @rssi_change_thresh: RSSI Change threshold
14983 * @bcn_rssi_weight: beacon RSSI weight
14984 * @vdev_id: vdev id
14985 *
14986 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14987 *
14988 * Return: CDF status
14989 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014990static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014991 uint32_t vdev_id,
14992 int32_t rssi_change_thresh,
14993 uint32_t bcn_rssi_weight,
14994 uint32_t hirssi_delay_btw_scans)
14995{
Govind Singha4836fd2016-03-07 16:45:38 +053014996 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014997 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014998 int len;
14999 uint8_t *buf_ptr;
15000 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15001
15002 /* Send rssi change parameters */
15003 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15004 buf = wmi_buf_alloc(wmi_handle, len);
15005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015006 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15007 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015008 }
15009
15010 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15011 rssi_change_fp =
15012 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15013 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15014 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15015 WMITLV_GET_STRUCT_TLVLEN
15016 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15017 /* fill in rssi change threshold (hysteresis) values */
15018 rssi_change_fp->vdev_id = vdev_id;
15019 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15020 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15021 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15022
15023 status = wmi_unified_cmd_send(wmi_handle, buf,
15024 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015025 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015026 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015027 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015028 goto error;
15029 }
15030
Govind Singhb53420c2016-03-09 14:32:57 +053015031 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015032 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015033 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15034 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015035error:
15036 wmi_buf_free(buf);
15037
Govind Singh67922e82016-04-01 16:48:57 +053015038 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015039}
15040
15041/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
15042 * @wmi_handle: wmi handle.
15043 * @cmd: size of command structure.
15044 * @per_entry_size: per entry size.
15045 *
15046 * This utility function calculates how many hotlist entries can
15047 * fit in one page.
15048 *
15049 * Return: number of entries
15050 */
15051static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
15052 size_t cmd_size,
15053 size_t per_entry_size)
15054{
15055 uint32_t avail_space = 0;
15056 int num_entries = 0;
15057 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
15058
15059 /* Calculate number of hotlist entries that can
15060 * be passed in wma message request.
15061 */
15062 avail_space = max_msg_len - cmd_size;
15063 num_entries = avail_space / per_entry_size;
15064 return num_entries;
15065}
15066
15067/**
15068 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
15069 * @wmi_handle: wmi handle
15070 * @photlist: hotlist command params
15071 * @buf_len: buffer length
15072 *
15073 * This function fills individual elements for hotlist request and
15074 * TLV for bssid entries
15075 *
15076 * Return: CDF Status.
15077 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015078static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015079 struct ext_scan_setbssi_hotlist_params *
15080 photlist, int *buf_len)
15081{
15082 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
15083 wmi_extscan_hotlist_entry *dest_hotlist;
15084 struct ap_threshold_params *src_ap = photlist->ap;
15085 wmi_buf_t buf;
15086 uint8_t *buf_ptr;
15087
15088 int j, index = 0;
15089 int cmd_len = 0;
15090 int num_entries;
15091 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080015092 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053015093 int len = sizeof(*cmd);
15094
15095 len += WMI_TLV_HDR_SIZE;
15096 cmd_len = len;
15097
15098 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
15099 cmd_len,
15100 sizeof(*dest_hotlist));
15101 /* setbssid hotlist expects the bssid list
15102 * to be non zero value
15103 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080015104 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080015105 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053015106 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053015107 }
15108
15109 /* Split the hot list entry pages and send multiple command
15110 * requests if the buffer reaches the maximum request size
15111 */
15112 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053015113 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053015114 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
15115 buf = wmi_buf_alloc(wmi_handle, len);
15116 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015117 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
15118 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015119 }
15120 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15121 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
15122 buf_ptr;
15123 WMITLV_SET_HDR(&cmd->tlv_header,
15124 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
15125 WMITLV_GET_STRUCT_TLVLEN
15126 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
15127
15128 /* Multiple requests are sent until the num_entries_in_page
15129 * matches the total_entries
15130 */
15131 cmd->request_id = photlist->requestId;
15132 cmd->vdev_id = photlist->sessionId;
15133 cmd->total_entries = numap;
15134 cmd->mode = 1;
15135 cmd->num_entries_in_page = min_entries;
15136 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
15137 cmd->first_entry_index = index;
15138
Govind Singhb53420c2016-03-09 14:32:57 +053015139 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015140 __func__, cmd->vdev_id, cmd->total_entries,
15141 cmd->num_entries_in_page,
15142 cmd->lost_ap_scan_count);
15143
15144 buf_ptr += sizeof(*cmd);
15145 WMITLV_SET_HDR(buf_ptr,
15146 WMITLV_TAG_ARRAY_STRUC,
15147 min_entries * sizeof(wmi_extscan_hotlist_entry));
15148 dest_hotlist = (wmi_extscan_hotlist_entry *)
15149 (buf_ptr + WMI_TLV_HDR_SIZE);
15150
15151 /* Populate bssid, channel info and rssi
15152 * for the bssid's that are sent as hotlists.
15153 */
15154 for (j = 0; j < min_entries; j++) {
15155 WMITLV_SET_HDR(dest_hotlist,
15156 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
15157 WMITLV_GET_STRUCT_TLVLEN
15158 (wmi_extscan_hotlist_entry));
15159
15160 dest_hotlist->min_rssi = src_ap->low;
15161 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
15162 &dest_hotlist->bssid);
15163
Govind Singhb53420c2016-03-09 14:32:57 +053015164 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015165 __func__, dest_hotlist->channel,
15166 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053015167 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053015168 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
15169 __func__, dest_hotlist->bssid.mac_addr31to0,
15170 dest_hotlist->bssid.mac_addr47to32);
15171 dest_hotlist++;
15172 src_ap++;
15173 }
15174 buf_ptr += WMI_TLV_HDR_SIZE +
15175 (min_entries * sizeof(wmi_extscan_hotlist_entry));
15176
15177 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15178 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015179 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015180 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015181 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015182 }
15183 index = index + min_entries;
15184 num_entries = numap - min_entries;
15185 len = cmd_len;
15186 }
Govind Singhb53420c2016-03-09 14:32:57 +053015187 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015188}
15189
Govind Singhbca3b1b2016-05-02 17:59:24 +053015190/**
Dustin Brown4423f632017-01-13 15:24:07 -080015191 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
15192 * @wmi_handle: the WMI handle
15193 * @vdev_id: the Id of the vdev to apply the configuration to
15194 * @ucast_mode: the active BPF mode to configure for unicast packets
15195 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
15196 * packets
15197 *
15198 * Return: QDF status
15199 */
15200static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
15201 uint8_t vdev_id,
15202 enum wmi_host_active_bpf_mode ucast_mode,
15203 enum wmi_host_active_bpf_mode mcast_bcast_mode)
15204{
15205 const WMITLV_TAG_ID tag_id =
15206 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
15207 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
15208 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
15209 QDF_STATUS status;
15210 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
15211 wmi_buf_t buf;
15212
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015213 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080015214 vdev_id, ucast_mode, mcast_bcast_mode);
15215
15216 /* allocate command buffer */
15217 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
15218 if (!buf) {
15219 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15220 return QDF_STATUS_E_NOMEM;
15221 }
15222
15223 /* set TLV header */
15224 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
15225 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
15226
15227 /* populate data */
15228 cmd->vdev_id = vdev_id;
15229 cmd->uc_mode = ucast_mode;
15230 cmd->mcbc_mode = mcast_bcast_mode;
15231
15232 /* send to FW */
15233 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
15234 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
15235 if (QDF_IS_STATUS_ERROR(status)) {
15236 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
15237 status);
15238 wmi_buf_free(buf);
15239 return status;
15240 }
15241
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015242 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080015243
15244 return QDF_STATUS_SUCCESS;
15245}
15246
15247/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053015248 * send_power_dbg_cmd_tlv() - send power debug commands
15249 * @wmi_handle: wmi handle
15250 * @param: wmi power debug parameter
15251 *
15252 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15253 *
15254 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15255 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015256static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15257 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015258{
15259 wmi_buf_t buf = NULL;
15260 QDF_STATUS status;
15261 int len, args_tlv_len;
15262 uint8_t *buf_ptr;
15263 uint8_t i;
15264 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15265 uint32_t *cmd_args;
15266
15267 /* Prepare and send power debug cmd parameters */
15268 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15269 len = sizeof(*cmd) + args_tlv_len;
15270 buf = wmi_buf_alloc(wmi_handle, len);
15271 if (!buf) {
15272 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15273 return QDF_STATUS_E_NOMEM;
15274 }
15275
15276 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15277 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15278 WMITLV_SET_HDR(&cmd->tlv_header,
15279 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15280 WMITLV_GET_STRUCT_TLVLEN
15281 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15282
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015283 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15284 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015285 cmd->module_id = param->module_id;
15286 cmd->num_args = param->num_args;
15287 buf_ptr += sizeof(*cmd);
15288 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15289 (param->num_args * sizeof(uint32_t)));
15290 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15291 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
15292 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15293 cmd_args[i] = param->args[i];
15294 WMI_LOGI("%d,", param->args[i]);
15295 }
15296
15297 status = wmi_unified_cmd_send(wmi_handle, buf,
15298 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15299 if (QDF_IS_STATUS_ERROR(status)) {
15300 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15301 status);
15302 goto error;
15303 }
15304
15305 return QDF_STATUS_SUCCESS;
15306error:
15307 wmi_buf_free(buf);
15308
15309 return status;
15310}
15311
Kiran Venkatappa26117052016-12-23 19:58:54 +053015312/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015313 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015314 * @buf_ptr: pointer to current position in init command buffer
15315 * @len: pointer to length. This will be updated with current lenght of cmd
15316 * @param: point host parameters for init command
15317 *
15318 * Return: Updated pointer of buf_ptr.
15319 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015320static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
15321 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053015322{
15323 uint16_t idx;
15324
15325 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
15326 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
15327 wmi_pdev_band_to_mac *band_to_mac;
15328
15329 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
15330 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
15331 sizeof(wmi_resource_config) +
15332 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
15333 sizeof(wlan_host_memory_chunk)));
15334
15335 WMITLV_SET_HDR(&hw_mode->tlv_header,
15336 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
15337 (WMITLV_GET_STRUCT_TLVLEN
15338 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
15339
15340 hw_mode->hw_mode_index = param->hw_mode_id;
15341 hw_mode->num_band_to_mac = param->num_band_to_mac;
15342
15343 buf_ptr = (uint8_t *) (hw_mode + 1);
15344 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
15345 WMI_TLV_HDR_SIZE);
15346 for (idx = 0; idx < param->num_band_to_mac; idx++) {
15347 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
15348 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
15349 WMITLV_GET_STRUCT_TLVLEN
15350 (wmi_pdev_band_to_mac));
15351 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015352 wmi_handle->ops->convert_pdev_id_host_to_target(
15353 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015354 band_to_mac[idx].start_freq =
15355 param->band_to_mac[idx].start_freq;
15356 band_to_mac[idx].end_freq =
15357 param->band_to_mac[idx].end_freq;
15358 }
15359 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15360 (param->num_band_to_mac *
15361 sizeof(wmi_pdev_band_to_mac)) +
15362 WMI_TLV_HDR_SIZE;
15363
15364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
15365 (param->num_band_to_mac *
15366 sizeof(wmi_pdev_band_to_mac)));
15367 }
15368
15369 return buf_ptr;
15370}
15371
Govind Singhe7f2f342016-05-23 12:12:52 +053015372/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015373 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15374 * @wmi_handle: wmi handle
15375 * @param: wmi multiple vdev restart req param
15376 *
15377 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15378 *
15379 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15380 */
15381static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15382 wmi_unified_t wmi_handle,
15383 struct multiple_vdev_restart_params *param)
15384{
15385 wmi_buf_t buf;
15386 QDF_STATUS qdf_status;
15387 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15388 int i;
15389 uint8_t *buf_ptr;
15390 uint32_t *vdev_ids;
15391 wmi_channel *chan_info;
15392 struct channel_param *tchan_info;
15393 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15394
15395 len += sizeof(wmi_channel);
15396 if (param->num_vdevs)
15397 len += sizeof(uint32_t) * param->num_vdevs;
15398
15399 buf = wmi_buf_alloc(wmi_handle, len);
15400 if (!buf) {
15401 WMI_LOGE("Failed to allocate memory\n");
15402 qdf_status = QDF_STATUS_E_NOMEM;
15403 goto end;
15404 }
15405
15406 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15407 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15408 buf_ptr;
15409
15410 WMITLV_SET_HDR(&cmd->tlv_header,
15411 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15412 WMITLV_GET_STRUCT_TLVLEN
15413 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015414 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15415 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015416 cmd->requestor_id = param->requestor_id;
15417 cmd->disable_hw_ack = param->disable_hw_ack;
15418 cmd->cac_duration_ms = param->cac_duration_ms;
15419 cmd->num_vdevs = param->num_vdevs;
15420
15421 buf_ptr += sizeof(*cmd);
15422
15423 WMITLV_SET_HDR(buf_ptr,
15424 WMITLV_TAG_ARRAY_UINT32,
15425 sizeof(A_UINT32) * param->num_vdevs);
15426 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15427 for (i = 0; i < param->num_vdevs; i++) {
15428 vdev_ids[i] = param->vdev_ids[i];
15429 }
15430
15431 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
15432
15433 WMITLV_SET_HDR(buf_ptr,
15434 WMITLV_TAG_STRUC_wmi_channel,
15435 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015436 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015437 tchan_info = &(param->ch_param);
15438 chan_info->mhz = tchan_info->mhz;
15439 chan_info->band_center_freq1 = tchan_info->cfreq1;
15440 chan_info->band_center_freq2 = tchan_info->cfreq2;
15441 if (tchan_info->is_chan_passive)
15442 WMI_SET_CHANNEL_FLAG(chan_info,
15443 WMI_CHAN_FLAG_PASSIVE);
15444 if (tchan_info->allow_vht)
15445 WMI_SET_CHANNEL_FLAG(chan_info,
15446 WMI_CHAN_FLAG_ALLOW_VHT);
15447 else if (tchan_info->allow_ht)
15448 WMI_SET_CHANNEL_FLAG(chan_info,
15449 WMI_CHAN_FLAG_ALLOW_HT);
15450 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15451 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15452 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15453 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15454 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15455 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
15456
15457 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15458 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15459
15460 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15461 WMI_LOGE("%s: Failed to send\n", __func__);
15462 wmi_buf_free(buf);
15463 }
15464
15465end:
15466 return qdf_status;
15467}
15468
15469/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015470 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15471 * @wmi_handle: wmi handle
15472 * @pdev_id: pdev id
15473 *
15474 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15475 *
15476 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15477 */
15478static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15479 uint32_t pdev_id)
15480{
15481 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15482 wmi_buf_t buf;
15483 uint16_t len;
15484 QDF_STATUS ret;
15485
15486 len = sizeof(*cmd);
15487 buf = wmi_buf_alloc(wmi_handle, len);
15488
15489 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15490
15491 if (!buf) {
15492 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15493 return QDF_STATUS_E_NOMEM;
15494 }
15495
15496 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15497 wmi_buf_data(buf);
15498
15499 WMITLV_SET_HDR(&cmd->tlv_header,
15500 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15501 WMITLV_GET_STRUCT_TLVLEN(
15502 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15503
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015504 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015505 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15506 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15507 if (QDF_IS_STATUS_ERROR(ret)) {
15508 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15509 __func__, ret, pdev_id);
15510 wmi_buf_free(buf);
15511 return QDF_STATUS_E_FAILURE;
15512 }
15513
15514 return QDF_STATUS_SUCCESS;
15515}
15516
15517/**
15518 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15519 * @wmi_handle: wmi handle
15520 * @pdev_id: pdev id
15521 *
15522 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15523 *
15524 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15525 */
15526static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15527 uint32_t pdev_id)
15528{
15529 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15530 wmi_buf_t buf;
15531 uint16_t len;
15532 QDF_STATUS ret;
15533
15534 len = sizeof(*cmd);
15535 buf = wmi_buf_alloc(wmi_handle, len);
15536
15537 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15538
15539 if (!buf) {
15540 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15541 return QDF_STATUS_E_NOMEM;
15542 }
15543
15544 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15545 wmi_buf_data(buf);
15546
15547 WMITLV_SET_HDR(&cmd->tlv_header,
15548 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15549 WMITLV_GET_STRUCT_TLVLEN(
15550 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15551
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015552 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015553 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15554 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15555 if (QDF_IS_STATUS_ERROR(ret)) {
15556 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15557 __func__, ret, pdev_id);
15558 wmi_buf_free(buf);
15559 return QDF_STATUS_E_FAILURE;
15560 }
15561
15562 return QDF_STATUS_SUCCESS;
15563}
15564
15565/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015566 * init_cmd_send_tlv() - send initialization cmd to fw
15567 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015568 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015569 *
15570 * Return: QDF_STATUS_SUCCESS for success or error code
15571 */
15572static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015573 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015574{
15575 wmi_buf_t buf;
15576 wmi_init_cmd_fixed_param *cmd;
15577 wmi_abi_version my_vers;
15578 int num_whitelist;
15579 uint8_t *buf_ptr;
15580 wmi_resource_config *resource_cfg;
15581 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015582 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015583 uint16_t idx;
15584 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015585 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015586
Kiran Venkatappa26117052016-12-23 19:58:54 +053015587 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15588 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015589 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015590
15591 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15592 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15593 WMI_TLV_HDR_SIZE +
15594 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15595
15596 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015597 if (!buf) {
15598 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15599 return QDF_STATUS_E_FAILURE;
15600 }
15601
15602 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15603 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15604 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15605
15606 host_mem_chunks = (wlan_host_memory_chunk *)
15607 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15608 + WMI_TLV_HDR_SIZE);
15609
15610 WMITLV_SET_HDR(&cmd->tlv_header,
15611 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15612 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15613
Kiran Venkatappa26117052016-12-23 19:58:54 +053015614 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015615 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15616 WMITLV_TAG_STRUC_wmi_resource_config,
15617 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15618
Kiran Venkatappa26117052016-12-23 19:58:54 +053015619 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015620 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15621 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15622 WMITLV_GET_STRUCT_TLVLEN
15623 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015624 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15625 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15626 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015627 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15628 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015629 idx, host_mem_chunks[idx].size,
15630 host_mem_chunks[idx].ptr);
15631 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015632 cmd->num_host_mem_chunks = param->num_mem_chunks;
15633 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15634
Govind Singhe7f2f342016-05-23 12:12:52 +053015635 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15636 WMITLV_TAG_ARRAY_STRUC,
15637 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015638 param->num_mem_chunks));
15639
15640 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015641 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015642
15643 num_whitelist = sizeof(version_whitelist) /
15644 sizeof(wmi_whitelist_version_info);
15645 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15646 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15647 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15648 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15649 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15650 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15651
Govind Singh87542482016-06-08 19:40:11 +053015652#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015653 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15654 &my_vers,
15655 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15656 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015657#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015658 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15659 __func__,
15660 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15661 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15662 cmd->host_abi_vers.abi_version_ns_0,
15663 cmd->host_abi_vers.abi_version_ns_1,
15664 cmd->host_abi_vers.abi_version_ns_2,
15665 cmd->host_abi_vers.abi_version_ns_3);
15666
15667 /* Save version sent from host -
15668 * Will be used to check ready event
15669 */
Govind Singh87542482016-06-08 19:40:11 +053015670#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015671 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15672 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015673#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015674 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15675 if (QDF_IS_STATUS_ERROR(ret)) {
15676 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15677 ret);
15678 wmi_buf_free(buf);
15679 }
15680 return ret;
15681
Govind Singhe7f2f342016-05-23 12:12:52 +053015682}
15683
15684/**
15685 * save_service_bitmap_tlv() - save service bitmap
15686 * @wmi_handle: wmi handle
15687 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015688 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015689 *
15690 * Return: None
15691 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015692#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015693static
Rajeev Kumar77901472017-02-12 02:12:17 -080015694void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15695 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015696{
15697 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15698 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15699
15700 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15701 param_buf->wmi_service_bitmap,
15702 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015703
15704 if (bitmap_buf)
15705 qdf_mem_copy(bitmap_buf,
15706 param_buf->wmi_service_bitmap,
15707 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015708}
15709#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015710static
Rajeev Kumar77901472017-02-12 02:12:17 -080015711void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15712 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015713{
Rajeev Kumar77901472017-02-12 02:12:17 -080015714 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15715 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015716
Rajeev Kumar77901472017-02-12 02:12:17 -080015717 if (bitmap_buf)
15718 qdf_mem_copy(bitmap_buf,
15719 param_buf->wmi_service_bitmap,
15720 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15721}
Govind Singhe7f2f342016-05-23 12:12:52 +053015722#endif
15723
15724/**
15725 * is_service_enabled_tlv() - Check if service enabled
15726 * @param wmi_handle: wmi handle
15727 * @param service_id: service identifier
15728 *
15729 * Return: 1 enabled, 0 disabled
15730 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015731#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015732static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15733 uint32_t service_id)
15734{
15735 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15736 service_id);
15737}
15738#else
15739static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15740 uint32_t service_id)
15741{
15742 return false;
15743}
15744#endif
15745
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015746static inline void copy_ht_cap_info(uint32_t ev_target_cap,
15747 struct wlan_psoc_target_capability_info *cap)
15748{
15749 /* except LDPC all flags are common betwen legacy and here
15750 * also IBFEER is not defined for TLV
15751 */
15752 cap->ht_cap_info |= ev_target_cap & (
15753 WMI_HT_CAP_ENABLED
15754 | WMI_HT_CAP_HT20_SGI
15755 | WMI_HT_CAP_DYNAMIC_SMPS
15756 | WMI_HT_CAP_TX_STBC
15757 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
15758 | WMI_HT_CAP_RX_STBC
15759 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
15760 | WMI_HT_CAP_LDPC
15761 | WMI_HT_CAP_L_SIG_TXOP_PROT
15762 | WMI_HT_CAP_MPDU_DENSITY
15763 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
15764 | WMI_HT_CAP_HT40_SGI);
15765 if (ev_target_cap & WMI_HT_CAP_LDPC)
15766 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
15767 WMI_HOST_HT_CAP_TX_LDPC;
15768}
Govind Singhe7f2f342016-05-23 12:12:52 +053015769/**
15770 * extract_service_ready_tlv() - extract service ready event
15771 * @wmi_handle: wmi handle
15772 * @param evt_buf: pointer to received event buffer
15773 * @param cap: pointer to hold target capability information extracted from even
15774 *
15775 * Return: QDF_STATUS_SUCCESS for success or error code
15776 */
15777static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015778 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015779{
15780 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15781 wmi_service_ready_event_fixed_param *ev;
15782
15783
15784 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15785
15786 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15787 if (!ev) {
15788 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15789 return QDF_STATUS_E_FAILURE;
15790 }
15791
15792 cap->phy_capability = ev->phy_capability;
15793 cap->max_frag_entry = ev->max_frag_entry;
15794 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015795 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053015796 cap->vht_cap_info = ev->vht_cap_info;
15797 cap->vht_supp_mcs = ev->vht_supp_mcs;
15798 cap->hw_min_tx_power = ev->hw_min_tx_power;
15799 cap->hw_max_tx_power = ev->hw_max_tx_power;
15800 cap->sys_cap_info = ev->sys_cap_info;
15801 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15802 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15803 cap->max_num_scan_channels = ev->max_num_scan_channels;
15804 cap->max_supported_macs = ev->max_supported_macs;
15805 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15806 cap->txrx_chainmask = ev->txrx_chainmask;
15807 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15808 cap->num_msdu_desc = ev->num_msdu_desc;
15809
15810 return QDF_STATUS_SUCCESS;
15811}
15812
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015813/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15814 * to host internal WMI_HOST_REGDMN_MODE values.
15815 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15816 * host currently. Add this in the future if required.
15817 * 11AX (Phase II) : 11ax related values are not currently
15818 * advertised separately by FW. As part of phase II regulatory bring-up,
15819 * finalize the advertisement mechanism.
15820 * @target_wireless_mode: target wireless mode received in message
15821 *
15822 * Return: returns the host internal wireless mode.
15823 */
15824static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15825{
15826
15827 uint32_t wireless_modes = 0;
15828
15829 if (target_wireless_mode & REGDMN_MODE_11A)
15830 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15831
15832 if (target_wireless_mode & REGDMN_MODE_TURBO)
15833 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15834
15835 if (target_wireless_mode & REGDMN_MODE_11B)
15836 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15837
15838 if (target_wireless_mode & REGDMN_MODE_PUREG)
15839 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15840
15841 if (target_wireless_mode & REGDMN_MODE_11G)
15842 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15843
15844 if (target_wireless_mode & REGDMN_MODE_108G)
15845 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15846
15847 if (target_wireless_mode & REGDMN_MODE_108A)
15848 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15849
15850 if (target_wireless_mode & REGDMN_MODE_XR)
15851 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15852
15853 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15854 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15855
15856 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15857 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15858
15859 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15860 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15861
15862 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15863 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15864
15865 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15866 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15867
15868 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15869 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15870
15871 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15872 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15873
15874 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15875 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15876
15877 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15878 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15879
15880 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15881 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15882
15883 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15884 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15885
15886 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15887 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15888
15889 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15890 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15891
15892 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15893 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15894
15895 return wireless_modes;
15896}
15897
Govind Singhe7f2f342016-05-23 12:12:52 +053015898/**
15899 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15900 * @wmi_handle: wmi handle
15901 * @param evt_buf: Pointer to event buffer
15902 * @param cap: pointer to hold HAL reg capabilities
15903 *
15904 * Return: QDF_STATUS_SUCCESS for success or error code
15905 */
15906static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015907 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015908{
15909 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15910
15911 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15912
15913 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15914 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015915 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015916
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015917 cap->wireless_modes = convert_wireless_modes_tlv(
15918 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015919
Govind Singhe7f2f342016-05-23 12:12:52 +053015920 return QDF_STATUS_SUCCESS;
15921}
15922
15923/**
15924 * extract_host_mem_req_tlv() - Extract host memory request event
15925 * @wmi_handle: wmi handle
15926 * @param evt_buf: pointer to event buffer
15927 * @param num_entries: pointer to hold number of entries requested
15928 *
15929 * Return: Number of entries requested
15930 */
15931static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15932 void *evt_buf, uint8_t *num_entries)
15933{
15934 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15935 wmi_service_ready_event_fixed_param *ev;
15936
15937 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15938
15939 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15940 if (!ev) {
15941 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15942 return NULL;
15943 }
15944
15945 *num_entries = ev->num_mem_reqs;
15946
15947 return (host_mem_req *)param_buf->mem_reqs;
15948}
15949
15950/**
15951 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15952 * ready function
15953 * @wmi_handle: wmi handle
15954 * @param evt_buf: pointer to event buffer
15955 *
15956 * Return: QDF_STATUS_SUCCESS for success or error code
15957 */
15958static QDF_STATUS
15959save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15960{
15961 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15962 wmi_service_ready_event_fixed_param *ev;
15963
15964
15965 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15966
15967 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15968 if (!ev) {
15969 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15970 return QDF_STATUS_E_FAILURE;
15971 }
15972
Govind Singh87542482016-06-08 19:40:11 +053015973#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015974 /*Save fw version from service ready message */
15975 /*This will be used while sending INIT message */
15976 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15977 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015978#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015979 return QDF_STATUS_SUCCESS;
15980}
15981
15982/**
15983 * ready_extract_init_status_tlv() - Extract init status from ready event
15984 * @wmi_handle: wmi handle
15985 * @param evt_buf: Pointer to event buffer
15986 *
15987 * Return: ready status
15988 */
15989static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15990 void *evt_buf)
15991{
15992 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15993 wmi_ready_event_fixed_param *ev = NULL;
15994
Govind Singhe7f2f342016-05-23 12:12:52 +053015995 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15996 ev = param_buf->fixed_param;
15997
15998 qdf_print("%s:%d\n", __func__, ev->status);
15999
16000 return ev->status;
16001}
16002
16003/**
16004 * ready_extract_mac_addr_tlv() - extract mac address from ready event
16005 * @wmi_handle: wmi handle
16006 * @param evt_buf: pointer to event buffer
16007 * @param macaddr: Pointer to hold MAC address
16008 *
16009 * Return: QDF_STATUS_SUCCESS for success or error code
16010 */
16011static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
16012 void *evt_buf, uint8_t *macaddr)
16013{
16014 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
16015 wmi_ready_event_fixed_param *ev = NULL;
16016
16017
16018 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
16019 ev = param_buf->fixed_param;
16020
16021 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
16022
16023 return QDF_STATUS_SUCCESS;
16024}
16025
16026/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070016027 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
16028 * @wmi_handle: wmi handle
16029 * @param evt_buf: pointer to event buffer
16030 * @param macaddr: Pointer to hold number of MAC addresses
16031 *
16032 * Return: Pointer to addr list
16033 */
16034static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
16035 void *evt_buf, uint8_t *num_mac)
16036{
16037 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
16038 wmi_ready_event_fixed_param *ev = NULL;
16039
16040 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
16041 ev = param_buf->fixed_param;
16042
16043 *num_mac = ev->num_extra_mac_addr;
16044
16045 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
16046}
16047
16048/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016049 * extract_dbglog_data_len_tlv() - extract debuglog data length
16050 * @wmi_handle: wmi handle
16051 * @param evt_buf: pointer to event buffer
16052 *
16053 * Return: length
16054 */
16055static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080016056 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053016057{
16058 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
16059
16060 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
16061
16062 *len = param_buf->num_bufp;
16063
16064 return param_buf->bufp;
16065}
16066
16067/**
16068 * extract_vdev_start_resp_tlv() - extract vdev start response
16069 * @wmi_handle: wmi handle
16070 * @param evt_buf: pointer to event buffer
16071 * @param vdev_rsp: Pointer to hold vdev response
16072 *
16073 * Return: QDF_STATUS_SUCCESS for success or error code
16074 */
16075static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
16076 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
16077{
16078 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
16079 wmi_vdev_start_response_event_fixed_param *ev;
16080
16081 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
16082 if (!param_buf) {
16083 qdf_print("Invalid start response event buffer\n");
16084 return QDF_STATUS_E_INVAL;
16085 }
16086
16087 ev = param_buf->fixed_param;
16088 if (!ev) {
16089 qdf_print("Invalid start response event buffer\n");
16090 return QDF_STATUS_E_INVAL;
16091 }
16092
16093 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
16094
16095 vdev_rsp->vdev_id = ev->vdev_id;
16096 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070016097 switch (ev->resp_type) {
16098 case WMI_VDEV_START_RESP_EVENT:
16099 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
16100 break;
16101 case WMI_VDEV_RESTART_RESP_EVENT:
16102 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
16103 break;
16104 default:
16105 qdf_print("Invalid start response event buffer\n");
16106 break;
16107 };
Govind Singhe7f2f342016-05-23 12:12:52 +053016108 vdev_rsp->status = ev->status;
16109 vdev_rsp->chain_mask = ev->chain_mask;
16110 vdev_rsp->smps_mode = ev->smps_mode;
16111 vdev_rsp->mac_id = ev->mac_id;
16112 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
16113 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
16114
16115 return QDF_STATUS_SUCCESS;
16116}
16117
16118/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016119 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053016120 * @wmi_handle: wmi handle
16121 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016122 * @param num_vdevs: Pointer to hold num vdev
16123 *
16124 * Return: QDF_STATUS_SUCCESS for success or error code
16125 */
16126static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
16127 void *evt_buf, uint32_t *num_vdevs)
16128{
16129 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
16130 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
16131 uint32_t vdev_map;
16132
16133 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
16134 if (!param_buf) {
16135 qdf_print("Invalid tbtt update ext event buffer\n");
16136 return QDF_STATUS_E_INVAL;
16137 }
16138 tbtt_offset_event = param_buf->fixed_param;
16139 vdev_map = tbtt_offset_event->vdev_map;
16140 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16141
16142 return QDF_STATUS_SUCCESS;
16143}
16144
16145/**
16146 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
16147 * @wmi_handle: wmi handle
16148 * @param evt_buf: pointer to event buffer
16149 * @param num_vdevs: Pointer to hold num vdev
16150 *
16151 * Return: QDF_STATUS_SUCCESS for success or error code
16152 */
16153static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
16154 void *evt_buf, uint32_t *num_vdevs)
16155{
16156 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
16157 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
16158
16159 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
16160 if (!param_buf) {
16161 qdf_print("Invalid tbtt update ext event buffer\n");
16162 return QDF_STATUS_E_INVAL;
16163 }
16164 tbtt_offset_ext_event = param_buf->fixed_param;
16165
16166 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
16167
16168 return QDF_STATUS_SUCCESS;
16169}
16170
16171/**
16172 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
16173 * @wmi_handle: wmi handle
16174 * @param evt_buf: pointer to event buffer
16175 * @param idx: Index refering to a vdev
16176 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053016177 *
16178 * Return: QDF_STATUS_SUCCESS for success or error code
16179 */
16180static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016181 void *evt_buf, uint8_t idx,
16182 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016183{
16184 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
16185 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016186 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016187
16188 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
16189 if (!param_buf) {
16190 qdf_print("Invalid tbtt update event buffer\n");
16191 return QDF_STATUS_E_INVAL;
16192 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016193
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016194 tbtt_offset_event = param_buf->fixed_param;
16195 vdev_map = tbtt_offset_event->vdev_map;
16196 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
16197 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
16198 return QDF_STATUS_E_INVAL;
16199 tbtt_param->tbttoffset =
16200 param_buf->tbttoffset_list[tbtt_param->vdev_id];
16201
16202 return QDF_STATUS_SUCCESS;
16203}
16204
16205/**
16206 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
16207 * @wmi_handle: wmi handle
16208 * @param evt_buf: pointer to event buffer
16209 * @param idx: Index refering to a vdev
16210 * @param tbtt_param: Pointer to tbttoffset event param
16211 *
16212 * Return: QDF_STATUS_SUCCESS for success or error code
16213 */
16214static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
16215 void *evt_buf, uint8_t idx,
16216 struct tbttoffset_params *tbtt_param)
16217{
16218 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
16219 wmi_tbtt_offset_info *tbtt_offset_info;
16220
16221 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
16222 if (!param_buf) {
16223 qdf_print("Invalid tbtt update event buffer\n");
16224 return QDF_STATUS_E_INVAL;
16225 }
16226 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
16227
16228 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
16229 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053016230
16231 return QDF_STATUS_SUCCESS;
16232}
16233
16234/**
16235 * extract_mgmt_rx_params_tlv() - extract management rx params from event
16236 * @wmi_handle: wmi handle
16237 * @param evt_buf: pointer to event buffer
16238 * @param hdr: Pointer to hold header
16239 * @param bufp: Pointer to hold pointer to rx param buffer
16240 *
16241 * Return: QDF_STATUS_SUCCESS for success or error code
16242 */
16243static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053016244 void *evt_buf, struct mgmt_rx_event_params *hdr,
16245 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053016246{
16247 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
16248 wmi_mgmt_rx_hdr *ev_hdr = NULL;
16249
16250 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
16251 if (!param_tlvs) {
16252 WMI_LOGE("Get NULL point message from FW");
16253 return QDF_STATUS_E_INVAL;
16254 }
16255
16256 ev_hdr = param_tlvs->hdr;
16257 if (!hdr) {
16258 WMI_LOGE("Rx event is NULL");
16259 return QDF_STATUS_E_INVAL;
16260 }
16261
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016262 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16263 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016264
16265 hdr->channel = ev_hdr->channel;
16266 hdr->snr = ev_hdr->snr;
16267 hdr->rate = ev_hdr->rate;
16268 hdr->phy_mode = ev_hdr->phy_mode;
16269 hdr->buf_len = ev_hdr->buf_len;
16270 hdr->status = ev_hdr->status;
16271 hdr->flags = ev_hdr->flags;
16272 hdr->rssi = ev_hdr->rssi;
16273 hdr->tsf_delta = ev_hdr->tsf_delta;
16274 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
16275
16276 *bufp = param_tlvs->bufp;
16277
16278 return QDF_STATUS_SUCCESS;
16279}
16280
16281/**
16282 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
16283 * @wmi_handle: wmi handle
16284 * @param evt_buf: pointer to event buffer
16285 * @param vdev_id: Pointer to hold vdev identifier
16286 *
16287 * Return: QDF_STATUS_SUCCESS for success or error code
16288 */
16289static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
16290 void *evt_buf, uint32_t *vdev_id)
16291{
16292 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
16293 wmi_vdev_stopped_event_fixed_param *resp_event;
16294
16295 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
16296 if (!param_buf) {
16297 WMI_LOGE("Invalid event buffer");
16298 return QDF_STATUS_E_INVAL;
16299 }
16300 resp_event = param_buf->fixed_param;
16301 *vdev_id = resp_event->vdev_id;
16302
16303 return QDF_STATUS_SUCCESS;
16304}
16305
16306/**
16307 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
16308 * @wmi_handle: wmi handle
16309 * @param evt_buf: pointer to event buffer
16310 * @param param: Pointer to hold roam param
16311 *
16312 * Return: QDF_STATUS_SUCCESS for success or error code
16313 */
16314static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
16315 void *evt_buf, wmi_host_roam_event *param)
16316{
16317 WMI_ROAM_EVENTID_param_tlvs *param_buf;
16318 wmi_roam_event_fixed_param *evt;
16319
16320 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
16321 if (!param_buf) {
16322 WMI_LOGE("Invalid roam event buffer");
16323 return QDF_STATUS_E_INVAL;
16324 }
16325
16326 evt = param_buf->fixed_param;
16327 qdf_mem_zero(param, sizeof(*param));
16328
16329 param->vdev_id = evt->vdev_id;
16330 param->reason = evt->reason;
16331 param->rssi = evt->rssi;
16332
16333 return QDF_STATUS_SUCCESS;
16334}
16335
16336/**
16337 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
16338 * @wmi_handle: wmi handle
16339 * @param evt_buf: pointer to event buffer
16340 * @param param: Pointer to hold vdev scan param
16341 *
16342 * Return: QDF_STATUS_SUCCESS for success or error code
16343 */
16344static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016345 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016346{
16347 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
16348 wmi_scan_event_fixed_param *evt = NULL;
16349
16350 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
16351 evt = param_buf->fixed_param;
16352
16353 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016354
Govind Singhe7f2f342016-05-23 12:12:52 +053016355 switch (evt->event) {
16356 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016357 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016358 break;
16359 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016360 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016361 break;
16362 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016363 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016364 break;
16365 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016366 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016367 break;
16368 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016369 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016370 break;
16371 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016372 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016373 break;
16374 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016375 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016376 break;
16377 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016378 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016379 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053016380 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016381 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016382 break;
16383 case WMI_SCAN_EVENT_MAX:
16384 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016385 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016386 break;
16387 };
16388
16389 switch (evt->reason) {
16390 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016391 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016392 break;
16393 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016394 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016395 break;
16396 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016397 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016398 break;
16399 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016400 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016401 break;
16402 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016403 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016404 break;
16405 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016406 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016407 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016408 case WMI_SCAN_REASON_SUSPENDED:
16409 param->reason = SCAN_REASON_SUSPENDED;
16410 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016411 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016412 param->reason = SCAN_REASON_MAX;
16413 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016414 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016415 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016416 break;
16417 };
16418
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016419 param->chan_freq = evt->channel_freq;
16420 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053016421 param->scan_id = evt->scan_id;
16422 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053016423 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053016424
16425 return QDF_STATUS_SUCCESS;
16426}
16427
Frank Liu3d5e9992017-03-15 17:51:43 +080016428#ifdef CONVERGED_TDLS_ENABLE
16429/**
16430 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
16431 * @wmi_handle: wmi handle
16432 * @param evt_buf: pointer to event buffer
16433 * @param param: Pointer to hold vdev tdls param
16434 *
16435 * Return: QDF_STATUS_SUCCESS for success or error code
16436 */
16437static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
16438 void *evt_buf, struct tdls_event_info *param)
16439{
16440 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
16441 wmi_tdls_peer_event_fixed_param *evt;
16442
16443 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
16444 if (!param_buf) {
16445 WMI_LOGE("%s: NULL param_buf", __func__);
16446 return QDF_STATUS_E_NULL_VALUE;
16447 }
16448
16449 evt = param_buf->fixed_param;
16450
16451 qdf_mem_zero(param, sizeof(*param));
16452
16453 param->vdev_id = evt->vdev_id;
16454 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
16455 param->peermac.bytes);
16456 switch (evt->peer_status) {
16457 case WMI_TDLS_SHOULD_DISCOVER:
16458 param->message_type = TDLS_SHOULD_DISCOVER;
16459 break;
16460 case WMI_TDLS_SHOULD_TEARDOWN:
16461 param->message_type = TDLS_SHOULD_TEARDOWN;
16462 break;
16463 case WMI_TDLS_PEER_DISCONNECTED:
16464 param->message_type = TDLS_PEER_DISCONNECTED;
16465 break;
16466 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
16467 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
16468 break;
16469 default:
16470 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
16471 __func__, evt->peer_status);
16472 return QDF_STATUS_E_INVAL;
16473 };
16474
16475 switch (evt->peer_reason) {
16476 case WMI_TDLS_TEARDOWN_REASON_TX:
16477 param->peer_reason = TDLS_TEARDOWN_TX;
16478 break;
16479 case WMI_TDLS_TEARDOWN_REASON_RSSI:
16480 param->peer_reason = TDLS_TEARDOWN_RSSI;
16481 break;
16482 case WMI_TDLS_TEARDOWN_REASON_SCAN:
16483 param->peer_reason = TDLS_TEARDOWN_SCAN;
16484 break;
16485 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
16486 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
16487 break;
16488 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
16489 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
16490 break;
16491 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
16492 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
16493 break;
16494 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
16495 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
16496 break;
16497 case WMI_TDLS_ENTER_BUF_STA:
16498 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
16499 break;
16500 case WMI_TDLS_EXIT_BUF_STA:
16501 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
16502 break;
16503 case WMI_TDLS_ENTER_BT_BUSY_MODE:
16504 param->peer_reason = TDLS_ENTER_BT_BUSY;
16505 break;
16506 case WMI_TDLS_EXIT_BT_BUSY_MODE:
16507 param->peer_reason = TDLS_EXIT_BT_BUSY;
16508 break;
16509 case WMI_TDLS_SCAN_STARTED_EVENT:
16510 param->peer_reason = TDLS_SCAN_STARTED;
16511 break;
16512 case WMI_TDLS_SCAN_COMPLETED_EVENT:
16513 param->peer_reason = TDLS_SCAN_COMPLETED;
16514 break;
16515
16516 default:
16517 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16518 __func__, evt->peer_reason, evt->peer_status);
16519 return QDF_STATUS_E_INVAL;
16520 };
16521
16522 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16523 __func__, param->peermac.bytes, param->message_type,
16524 param->peer_reason, param->vdev_id);
16525
16526 return QDF_STATUS_SUCCESS;
16527}
16528#endif
16529
Govind Singhe7f2f342016-05-23 12:12:52 +053016530/**
16531 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16532 * @wmi_handle: wmi handle
16533 * @param evt_buf: pointer to event buffer
16534 * @param param: Pointer to hold MGMT TX completion params
16535 *
16536 * Return: QDF_STATUS_SUCCESS for success or error code
16537 */
16538static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16539 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16540{
16541 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16542 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16543
16544 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16545 evt_buf;
16546 if (!param_buf) {
16547 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16548 return QDF_STATUS_E_INVAL;
16549 }
16550 cmpl_params = param_buf->fixed_param;
16551
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016552 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16553 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016554 param->desc_id = cmpl_params->desc_id;
16555 param->status = cmpl_params->status;
16556
16557 return QDF_STATUS_SUCCESS;
16558}
16559
16560/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016561 * extract_offchan_data_tx_compl_param_tlv() -
16562 * extract Offchan data tx completion event params
16563 * @wmi_handle: wmi handle
16564 * @param evt_buf: pointer to event buffer
16565 * @param param: Pointer to hold offchan data TX completion params
16566 *
16567 * Return: QDF_STATUS_SUCCESS for success or error code
16568 */
16569static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16570 wmi_unified_t wmi_handle, void *evt_buf,
16571 struct wmi_host_offchan_data_tx_compl_event *param)
16572{
16573 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16574 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16575
16576 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16577 evt_buf;
16578 if (!param_buf) {
16579 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16580 return QDF_STATUS_E_INVAL;
16581 }
16582 cmpl_params = param_buf->fixed_param;
16583
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016584 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16585 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016586 param->desc_id = cmpl_params->desc_id;
16587 param->status = cmpl_params->status;
16588
16589 return QDF_STATUS_SUCCESS;
16590}
16591
16592/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016593 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16594 * status tlv
16595 * @wmi_handle: wmi handle
16596 * @param evt_buf: pointer to event buffer
16597 * @param param: Pointer to hold csa switch count status event param
16598 *
16599 * Return: QDF_STATUS_SUCCESS for success or error code
16600 */
16601static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16602 wmi_unified_t wmi_handle,
16603 void *evt_buf,
16604 struct pdev_csa_switch_count_status *param)
16605{
16606 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16607 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16608
16609 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16610 evt_buf;
16611 if (!param_buf) {
16612 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16613 return QDF_STATUS_E_INVAL;
16614 }
16615
16616 csa_status = param_buf->fixed_param;
16617
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016618 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16619 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016620 param->current_switch_count = csa_status->current_switch_count;
16621 param->num_vdevs = csa_status->num_vdevs;
16622 param->vdev_ids = param_buf->vdev_ids;
16623
16624 return QDF_STATUS_SUCCESS;
16625}
16626
16627/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016628 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016629 * @wmi_handle: wmi handle
16630 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016631 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016632 *
16633 * Return: QDF_STATUS_SUCCESS for success or error code
16634 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016635static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16636 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016637{
16638 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16639 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016640 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016641
16642 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16643 if (!param_buf) {
16644 WMI_LOGE("Invalid swba event buffer");
16645 return QDF_STATUS_E_INVAL;
16646 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016647
Govind Singhe7f2f342016-05-23 12:12:52 +053016648 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016649 *num_vdevs = swba_event->num_vdevs;
16650 if (!(*num_vdevs)) {
16651 vdev_map = swba_event->vdev_map;
16652 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16653 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016654
16655 return QDF_STATUS_SUCCESS;
16656}
16657
16658/**
16659 * extract_swba_tim_info_tlv() - extract swba tim info from event
16660 * @wmi_handle: wmi handle
16661 * @param evt_buf: pointer to event buffer
16662 * @param idx: Index to bcn info
16663 * @param tim_info: Pointer to hold tim info
16664 *
16665 * Return: QDF_STATUS_SUCCESS for success or error code
16666 */
16667static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16668 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16669{
16670 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16671 wmi_tim_info *tim_info_ev;
16672
16673 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16674 if (!param_buf) {
16675 WMI_LOGE("Invalid swba event buffer");
16676 return QDF_STATUS_E_INVAL;
16677 }
16678
16679 tim_info_ev = &param_buf->tim_info[idx];
16680
16681 tim_info->tim_len = tim_info_ev->tim_len;
16682 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16683 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16684 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16685 tim_info->tim_changed = tim_info_ev->tim_changed;
16686 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016687 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016688
16689 return QDF_STATUS_SUCCESS;
16690}
16691
16692/**
16693 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16694 * @wmi_handle: wmi handle
16695 * @param evt_buf: pointer to event buffer
16696 * @param idx: Index to bcn info
16697 * @param p2p_desc: Pointer to hold p2p NoA info
16698 *
16699 * Return: QDF_STATUS_SUCCESS for success or error code
16700 */
16701static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16702 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16703{
16704 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16705 wmi_p2p_noa_info *p2p_noa_info;
16706 uint8_t i = 0;
16707
16708 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16709 if (!param_buf) {
16710 WMI_LOGE("Invalid swba event buffer");
16711 return QDF_STATUS_E_INVAL;
16712 }
16713
16714 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16715
16716 p2p_desc->modified = false;
16717 p2p_desc->num_descriptors = 0;
16718 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16719 p2p_desc->modified = true;
16720 p2p_desc->index =
16721 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16722 p2p_desc->oppPS =
16723 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16724 p2p_desc->ctwindow =
16725 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16726 p2p_desc->num_descriptors =
16727 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16728 (p2p_noa_info);
16729 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16730 p2p_desc->noa_descriptors[i].type_count =
16731 (uint8_t) p2p_noa_info->noa_descriptors[i].
16732 type_count;
16733 p2p_desc->noa_descriptors[i].duration =
16734 p2p_noa_info->noa_descriptors[i].duration;
16735 p2p_desc->noa_descriptors[i].interval =
16736 p2p_noa_info->noa_descriptors[i].interval;
16737 p2p_desc->noa_descriptors[i].start_time =
16738 p2p_noa_info->noa_descriptors[i].start_time;
16739 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016740 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016741 }
16742
16743 return QDF_STATUS_SUCCESS;
16744}
16745
Wu Gaocd3a8512017-03-13 20:17:34 +080016746#ifdef CONVERGED_P2P_ENABLE
16747/**
16748 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16749 * @wmi_handle: wmi handle
16750 * @param evt_buf: pointer to event buffer
16751 * @param param: Pointer to hold p2p noa info
16752 *
16753 * Return: QDF_STATUS_SUCCESS for success or error code
16754 */
16755static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16756 wmi_unified_t wmi_handle, void *evt_buf,
16757 struct p2p_noa_info *param)
16758{
16759 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16760 wmi_p2p_noa_event_fixed_param *fixed_param;
16761 uint8_t i;
16762 wmi_p2p_noa_info *wmi_noa_info;
16763 uint8_t *buf_ptr;
16764 uint32_t descriptors;
16765
16766 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16767 if (!param_tlvs) {
16768 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16769 return QDF_STATUS_E_INVAL;
16770 }
16771
16772 if (!param) {
16773 WMI_LOGE("noa information param is null");
16774 return QDF_STATUS_E_INVAL;
16775 }
16776
16777 fixed_param = param_tlvs->fixed_param;
16778 buf_ptr = (uint8_t *) fixed_param;
16779 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16780 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16781
16782 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16783 WMI_LOGE("%s: noa attr is not modified", __func__);
16784 return QDF_STATUS_E_INVAL;
16785 }
16786
16787 param->vdev_id = fixed_param->vdev_id;
16788 param->index =
16789 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16790 param->opps_ps =
16791 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16792 param->ct_window =
16793 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16794 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16795 param->num_desc = (uint8_t) descriptors;
16796
16797 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16798 param->index, param->opps_ps, param->ct_window,
16799 param->num_desc);
16800 for (i = 0; i < param->num_desc; i++) {
16801 param->noa_desc[i].type_count =
16802 (uint8_t) wmi_noa_info->noa_descriptors[i].
16803 type_count;
16804 param->noa_desc[i].duration =
16805 wmi_noa_info->noa_descriptors[i].duration;
16806 param->noa_desc[i].interval =
16807 wmi_noa_info->noa_descriptors[i].interval;
16808 param->noa_desc[i].start_time =
16809 wmi_noa_info->noa_descriptors[i].start_time;
16810 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16811 __func__, i, param->noa_desc[i].type_count,
16812 param->noa_desc[i].duration,
16813 param->noa_desc[i].interval,
16814 param->noa_desc[i].start_time);
16815 }
16816
16817 return QDF_STATUS_SUCCESS;
16818}
16819
16820/**
16821 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16822 * information from event
16823 * @wmi_handle: wmi handle
16824 * @param evt_buf: pointer to event buffer
16825 * @param param: Pointer to hold p2p lo stop event information
16826 *
16827 * Return: QDF_STATUS_SUCCESS for success or error code
16828 */
16829static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16830 wmi_unified_t wmi_handle, void *evt_buf,
16831 struct p2p_lo_event *param)
16832{
16833 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16834 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16835
16836 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16837 evt_buf;
16838 if (!param_tlvs) {
16839 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16840 return QDF_STATUS_E_INVAL;
16841 }
16842
16843 if (!param) {
16844 WMI_LOGE("lo stop event param is null");
16845 return QDF_STATUS_E_INVAL;
16846 }
16847
16848 lo_param = param_tlvs->fixed_param;
16849 param->vdev_id = lo_param->vdev_id;
16850 param->reason_code = lo_param->reason;
16851 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16852 param->vdev_id, param->reason_code);
16853
16854 return QDF_STATUS_SUCCESS;
16855}
16856#endif /* End of CONVERGED_P2P_ENABLE */
16857
Govind Singhe7f2f342016-05-23 12:12:52 +053016858/**
16859 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16860 * @wmi_handle: wmi handle
16861 * @param evt_buf: pointer to event buffer
16862 * @param ev: Pointer to hold peer param
16863 *
16864 * Return: QDF_STATUS_SUCCESS for success or error code
16865 */
16866static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16867 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16868{
16869 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16870 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16871
16872 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16873 kickout_event = param_buf->fixed_param;
16874
16875 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16876 ev->peer_macaddr);
16877
16878 ev->reason = kickout_event->reason;
16879 ev->rssi = kickout_event->rssi;
16880
16881 return QDF_STATUS_SUCCESS;
16882}
16883
16884/**
16885 * extract_all_stats_counts_tlv() - extract all stats count from event
16886 * @wmi_handle: wmi handle
16887 * @param evt_buf: pointer to event buffer
16888 * @param stats_param: Pointer to hold stats count
16889 *
16890 * Return: QDF_STATUS_SUCCESS for success or error code
16891 */
16892static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16893 void *evt_buf, wmi_host_stats_event *stats_param)
16894{
16895 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16896 wmi_stats_event_fixed_param *ev;
16897
16898 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16899
16900 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16901 if (!ev) {
16902 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16903 return QDF_STATUS_E_FAILURE;
16904 }
16905
16906 switch (ev->stats_id) {
16907 case WMI_REQUEST_PEER_STAT:
16908 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16909 break;
16910
16911 case WMI_REQUEST_AP_STAT:
16912 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16913 break;
16914
16915 case WMI_REQUEST_PDEV_STAT:
16916 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16917 break;
16918
16919 case WMI_REQUEST_VDEV_STAT:
16920 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16921 break;
16922
16923 case WMI_REQUEST_BCNFLT_STAT:
16924 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16925 break;
16926
16927 case WMI_REQUEST_VDEV_RATE_STAT:
16928 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16929 break;
16930
16931 default:
16932 stats_param->stats_id = 0;
16933 break;
16934
16935 }
16936
16937 stats_param->num_pdev_stats = ev->num_pdev_stats;
16938 stats_param->num_pdev_ext_stats = 0;
16939 stats_param->num_vdev_stats = ev->num_vdev_stats;
16940 stats_param->num_peer_stats = ev->num_peer_stats;
16941 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16942 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016943 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016944
16945 return QDF_STATUS_SUCCESS;
16946}
16947
16948/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016949 * extract_pdev_tx_stats() - extract pdev tx stats from event
16950 */
16951static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16952{
16953 /* Tx Stats */
16954 tx->comp_queued = tx_stats->comp_queued;
16955 tx->comp_delivered = tx_stats->comp_delivered;
16956 tx->msdu_enqued = tx_stats->msdu_enqued;
16957 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16958 tx->wmm_drop = tx_stats->wmm_drop;
16959 tx->local_enqued = tx_stats->local_enqued;
16960 tx->local_freed = tx_stats->local_freed;
16961 tx->hw_queued = tx_stats->hw_queued;
16962 tx->hw_reaped = tx_stats->hw_reaped;
16963 tx->underrun = tx_stats->underrun;
16964 tx->tx_abort = tx_stats->tx_abort;
16965 tx->mpdus_requed = tx_stats->mpdus_requed;
16966 tx->data_rc = tx_stats->data_rc;
16967 tx->self_triggers = tx_stats->self_triggers;
16968 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16969 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16970 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16971 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16972 tx->pdev_resets = tx_stats->pdev_resets;
16973 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16974 tx->phy_underrun = tx_stats->phy_underrun;
16975 tx->txop_ovf = tx_stats->txop_ovf;
16976
16977 return;
16978}
16979
16980
16981/**
16982 * extract_pdev_rx_stats() - extract pdev rx stats from event
16983 */
16984static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16985{
16986 /* Rx Stats */
16987 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16988 rx->status_rcvd = rx_stats->status_rcvd;
16989 rx->r0_frags = rx_stats->r0_frags;
16990 rx->r1_frags = rx_stats->r1_frags;
16991 rx->r2_frags = rx_stats->r2_frags;
16992 /* Only TLV */
16993 rx->r3_frags = 0;
16994 rx->htt_msdus = rx_stats->htt_msdus;
16995 rx->htt_mpdus = rx_stats->htt_mpdus;
16996 rx->loc_msdus = rx_stats->loc_msdus;
16997 rx->loc_mpdus = rx_stats->loc_mpdus;
16998 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16999 rx->phy_errs = rx_stats->phy_errs;
17000 rx->phy_err_drop = rx_stats->phy_err_drop;
17001 rx->mpdu_errs = rx_stats->mpdu_errs;
17002
17003 return;
17004}
17005
17006/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017007 * extract_pdev_stats_tlv() - extract pdev stats from event
17008 * @wmi_handle: wmi handle
17009 * @param evt_buf: pointer to event buffer
17010 * @param index: Index into pdev stats
17011 * @param pdev_stats: Pointer to hold pdev stats
17012 *
17013 * Return: QDF_STATUS_SUCCESS for success or error code
17014 */
17015static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
17016 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
17017{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053017018 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17019 wmi_stats_event_fixed_param *ev_param;
17020 uint8_t *data;
17021
17022 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17023 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17024
17025 data = param_buf->data;
17026
17027 if (index < ev_param->num_pdev_stats) {
17028 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
17029 (index * sizeof(wmi_pdev_stats)));
17030
17031 pdev_stats->chan_nf = ev->chan_nf;
17032 pdev_stats->tx_frame_count = ev->tx_frame_count;
17033 pdev_stats->rx_frame_count = ev->rx_frame_count;
17034 pdev_stats->rx_clear_count = ev->rx_clear_count;
17035 pdev_stats->cycle_count = ev->cycle_count;
17036 pdev_stats->phy_err_count = ev->phy_err_count;
17037 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
17038
17039 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
17040 &(ev->pdev_stats.tx));
17041 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
17042 &(ev->pdev_stats.rx));
17043 }
17044
Govind Singhe7f2f342016-05-23 12:12:52 +053017045 return QDF_STATUS_SUCCESS;
17046}
17047
17048/**
17049 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
17050 * @wmi_handle: wmi handle
17051 * @param evt_buf: pointer to event buffer
17052 * @param index: Index into extended pdev stats
17053 * @param pdev_ext_stats: Pointer to hold extended pdev stats
17054 *
17055 * Return: QDF_STATUS_SUCCESS for success or error code
17056 */
17057static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
17058 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
17059{
17060 return QDF_STATUS_SUCCESS;
17061}
17062
17063/**
17064 * extract_vdev_stats_tlv() - extract vdev stats from event
17065 * @wmi_handle: wmi handle
17066 * @param evt_buf: pointer to event buffer
17067 * @param index: Index into vdev stats
17068 * @param vdev_stats: Pointer to hold vdev stats
17069 *
17070 * Return: QDF_STATUS_SUCCESS for success or error code
17071 */
17072static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
17073 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
17074{
17075 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17076 wmi_stats_event_fixed_param *ev_param;
17077 uint8_t *data;
17078
17079 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17080 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17081 data = (uint8_t *) param_buf->data;
17082
17083 if (index < ev_param->num_vdev_stats) {
17084 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
17085 ((ev_param->num_pdev_stats) *
17086 sizeof(wmi_pdev_stats)) +
17087 (index * sizeof(wmi_vdev_stats)));
17088
17089 vdev_stats->vdev_id = ev->vdev_id;
17090 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
17091 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
17092
17093 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
17094 sizeof(ev->tx_frm_cnt));
17095 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
17096 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
17097 ev->multiple_retry_cnt,
17098 sizeof(ev->multiple_retry_cnt));
17099 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
17100 sizeof(ev->fail_cnt));
17101 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
17102 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
17103 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
17104 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
17105 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
17106 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
17107 sizeof(ev->tx_rate_history));
17108 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
17109 sizeof(ev->bcn_rssi_history));
17110
17111 }
17112
17113 return QDF_STATUS_SUCCESS;
17114}
17115
17116/**
17117 * extract_peer_stats_tlv() - extract peer stats from event
17118 * @wmi_handle: wmi handle
17119 * @param evt_buf: pointer to event buffer
17120 * @param index: Index into peer stats
17121 * @param peer_stats: Pointer to hold peer stats
17122 *
17123 * Return: QDF_STATUS_SUCCESS for success or error code
17124 */
17125static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
17126 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
17127{
17128 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17129 wmi_stats_event_fixed_param *ev_param;
17130 uint8_t *data;
17131
17132 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17133 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17134 data = (uint8_t *) param_buf->data;
17135
17136 if (index < ev_param->num_peer_stats) {
17137 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
17138 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
17139 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
17140 (index * sizeof(wmi_peer_stats)));
17141
17142 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
17143
17144 OS_MEMCPY(&(peer_stats->peer_macaddr),
17145 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
17146
17147 peer_stats->peer_rssi = ev->peer_rssi;
17148 peer_stats->peer_tx_rate = ev->peer_tx_rate;
17149 peer_stats->peer_rx_rate = ev->peer_rx_rate;
17150 }
17151
17152 return QDF_STATUS_SUCCESS;
17153}
17154
17155/**
17156 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
17157 * @wmi_handle: wmi handle
17158 * @param evt_buf: pointer to event buffer
17159 * @param index: Index into bcn fault stats
17160 * @param bcnflt_stats: Pointer to hold bcn fault stats
17161 *
17162 * Return: QDF_STATUS_SUCCESS for success or error code
17163 */
17164static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
17165 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
17166{
17167 return QDF_STATUS_SUCCESS;
17168}
17169
17170/**
17171 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
17172 * @wmi_handle: wmi handle
17173 * @param evt_buf: pointer to event buffer
17174 * @param index: Index into extended peer stats
17175 * @param peer_extd_stats: Pointer to hold extended peer stats
17176 *
17177 * Return: QDF_STATUS_SUCCESS for success or error code
17178 */
17179static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
17180 void *evt_buf, uint32_t index,
17181 wmi_host_peer_extd_stats *peer_extd_stats)
17182{
17183 return QDF_STATUS_SUCCESS;
17184}
17185
17186/**
17187 * extract_chan_stats_tlv() - extract chan stats from event
17188 * @wmi_handle: wmi handle
17189 * @param evt_buf: pointer to event buffer
17190 * @param index: Index into chan stats
17191 * @param vdev_extd_stats: Pointer to hold chan stats
17192 *
17193 * Return: QDF_STATUS_SUCCESS for success or error code
17194 */
17195static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
17196 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
17197{
17198 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17199 wmi_stats_event_fixed_param *ev_param;
17200 uint8_t *data;
17201
17202 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
17203 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
17204 data = (uint8_t *) param_buf->data;
17205
17206 if (index < ev_param->num_chan_stats) {
17207 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
17208 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
17209 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
17210 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
17211 (index * sizeof(wmi_chan_stats)));
17212
17213
17214 /* Non-TLV doesnt have num_chan_stats */
17215 chan_stats->chan_mhz = ev->chan_mhz;
17216 chan_stats->sampling_period_us = ev->sampling_period_us;
17217 chan_stats->rx_clear_count = ev->rx_clear_count;
17218 chan_stats->tx_duration_us = ev->tx_duration_us;
17219 chan_stats->rx_duration_us = ev->rx_duration_us;
17220 }
17221
17222 return QDF_STATUS_SUCCESS;
17223}
17224
17225/**
17226 * extract_profile_ctx_tlv() - extract profile context from event
17227 * @wmi_handle: wmi handle
17228 * @param evt_buf: pointer to event buffer
17229 * @idx: profile stats index to extract
17230 * @param profile_ctx: Pointer to hold profile context
17231 *
17232 * Return: QDF_STATUS_SUCCESS for success or error code
17233 */
17234static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
17235 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
17236{
17237 return QDF_STATUS_SUCCESS;
17238}
17239
17240/**
17241 * extract_profile_data_tlv() - extract profile data from event
17242 * @wmi_handle: wmi handle
17243 * @param evt_buf: pointer to event buffer
17244 * @param profile_data: Pointer to hold profile data
17245 *
17246 * Return: QDF_STATUS_SUCCESS for success or error code
17247 */
17248static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
17249 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
17250{
17251
17252 return QDF_STATUS_SUCCESS;
17253}
17254
17255/**
17256 * extract_chan_info_event_tlv() - extract chan information from event
17257 * @wmi_handle: wmi handle
17258 * @param evt_buf: pointer to event buffer
17259 * @param chan_info: Pointer to hold chan information
17260 *
17261 * Return: QDF_STATUS_SUCCESS for success or error code
17262 */
17263static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
17264 void *evt_buf, wmi_host_chan_info_event *chan_info)
17265{
17266 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
17267 wmi_chan_info_event_fixed_param *ev;
17268
17269 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
17270
17271 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
17272 if (!ev) {
17273 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
17274 return QDF_STATUS_E_FAILURE;
17275 }
17276
17277 chan_info->err_code = ev->err_code;
17278 chan_info->freq = ev->freq;
17279 chan_info->cmd_flags = ev->cmd_flags;
17280 chan_info->noise_floor = ev->noise_floor;
17281 chan_info->rx_clear_count = ev->rx_clear_count;
17282 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053017283 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
17284 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
17285 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053017286 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
17287 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
17288 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17289 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
17290 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
17291 chan_info->rx_frame_count = ev->rx_frame_count;
17292 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
17293 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053017294
17295 return QDF_STATUS_SUCCESS;
17296}
17297
17298/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017299 * extract_pdev_utf_event_tlv() - extract UTF data info from event
17300 * @wmi_handle: WMI handle
17301 * @param evt_buf: Pointer to event buffer
17302 * @param param: Pointer to hold data
17303 *
17304 * Return : QDF_STATUS_SUCCESS for success or error code
17305 */
17306static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
17307 uint8_t *evt_buf,
17308 struct wmi_host_pdev_utf_event *event)
17309{
17310 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017311 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017312
17313 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
17314 event->data = param_buf->data;
17315 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017316 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053017317 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017318 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017319 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017320
17321 return QDF_STATUS_SUCCESS;
17322}
Govind Singhe7f2f342016-05-23 12:12:52 +053017323
Kiran Venkatappa06520822016-08-10 23:55:40 +053017324/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017325 * extract_chainmask_tables_tlv() - extract chain mask tables from event
17326 * @wmi_handle: wmi handle
17327 * @param evt_buf: pointer to event buffer
17328 * @param param: Pointer to hold evt buf
17329 *
17330 * Return: QDF_STATUS_SUCCESS for success or error code
17331 */
17332static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
17333 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
17334{
17335 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17336 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
17337 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17338 uint8_t i = 0, j = 0;
17339
17340 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17341 if (!param_buf)
17342 return QDF_STATUS_E_INVAL;
17343
17344 hw_caps = param_buf->soc_hw_mode_caps;
17345 if (!hw_caps)
17346 return QDF_STATUS_E_INVAL;
17347
17348 if (!hw_caps->num_chainmask_tables)
17349 return QDF_STATUS_E_INVAL;
17350
17351 chainmask_caps = param_buf->mac_phy_chainmask_caps;
17352
17353 if (chainmask_caps == NULL)
17354 return QDF_STATUS_E_INVAL;
17355
17356 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
17357
17358 qdf_print("Dumping chain mask combo data for table : %d\n", i);
17359 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
17360
17361 chainmask_table[i].cap_list[j].chainmask =
17362 chainmask_caps->chainmask;
17363
17364 chainmask_table[i].cap_list[j].supports_chan_width_20 =
17365 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
17366
17367 chainmask_table[i].cap_list[j].supports_chan_width_40 =
17368 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
17369
17370 chainmask_table[i].cap_list[j].supports_chan_width_80 =
17371 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
17372
17373 chainmask_table[i].cap_list[j].supports_chan_width_160 =
17374 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
17375
17376 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
17377 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
17378
17379 chainmask_table[i].cap_list[j].chain_mask_2G =
17380 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
17381
17382 chainmask_table[i].cap_list[j].chain_mask_5G =
17383 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
17384
17385 chainmask_table[i].cap_list[j].chain_mask_tx =
17386 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
17387
17388 chainmask_table[i].cap_list[j].chain_mask_rx =
17389 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
17390
17391 chainmask_table[i].cap_list[j].supports_aDFS =
17392 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
17393
17394 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
17395 chainmask_caps->supported_flags,
17396 chainmask_caps->chainmask
17397 );
17398 chainmask_caps++;
17399 }
17400 }
17401
17402 return QDF_STATUS_SUCCESS;
17403}
17404
17405/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053017406 * extract_service_ready_ext_tlv() - extract basic extended service ready params
17407 * from event
17408 * @wmi_handle: wmi handle
17409 * @param evt_buf: pointer to event buffer
17410 * @param param: Pointer to hold evt buf
17411 *
17412 * Return: QDF_STATUS_SUCCESS for success or error code
17413 */
17414static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017415 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017416{
17417 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17418 wmi_service_ready_ext_event_fixed_param *ev;
17419 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17420 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017421 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
17422 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017423
17424 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17425 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017426 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017427
17428 ev = param_buf->fixed_param;
17429 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017430 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017431
17432 /* Move this to host based bitmap */
17433 param->default_conc_scan_config_bits =
17434 ev->default_conc_scan_config_bits;
17435 param->default_fw_config_bits = ev->default_fw_config_bits;
17436 param->he_cap_info = ev->he_cap_info;
17437 param->mpdu_density = ev->mpdu_density;
17438 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
17439 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
17440
17441 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017442 if (hw_caps)
17443 param->num_hw_modes = hw_caps->num_hw_modes;
17444 else
17445 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017446
17447 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017448 if (reg_caps)
17449 param->num_phy = reg_caps->num_phy;
17450 else
17451 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017452
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017453 if (hw_caps) {
17454 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
17455 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
17456 } else
17457 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017458
17459 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
17460
17461 if (chain_mask_combo == NULL)
17462 return QDF_STATUS_SUCCESS;
17463
17464 qdf_print("Dumping chain mask combo data\n");
17465
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017466 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017467
17468 qdf_print("table_id : %d Num valid chainmasks: %d\n",
17469 chain_mask_combo->chainmask_table_id,
17470 chain_mask_combo->num_valid_chainmask
17471 );
17472
17473 param->chainmask_table[i].table_id =
17474 chain_mask_combo->chainmask_table_id;
17475 param->chainmask_table[i].num_valid_chainmasks =
17476 chain_mask_combo->num_valid_chainmask;
17477 chain_mask_combo++;
17478 }
17479 qdf_print("chain mask combo end\n");
17480
Kiran Venkatappa06520822016-08-10 23:55:40 +053017481 return QDF_STATUS_SUCCESS;
17482}
17483
17484/**
17485 * extract_hw_mode_cap_service_ready_ext_tlv() -
17486 * extract HW mode cap from service ready event
17487 * @wmi_handle: wmi handle
17488 * @param evt_buf: pointer to event buffer
17489 * @param param: Pointer to hold evt buf
17490 * @param hw_mode_idx: hw mode idx should be less than num_mode
17491 *
17492 * Return: QDF_STATUS_SUCCESS for success or error code
17493 */
17494static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
17495 wmi_unified_t wmi_handle,
17496 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017497 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017498{
17499 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17500 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17501
17502 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17503 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017504 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017505
17506 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017507 if (!hw_caps)
17508 return QDF_STATUS_E_INVAL;
17509
Kiran Venkatappa06520822016-08-10 23:55:40 +053017510 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017511 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017512
17513 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
17514 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
17515
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017516 param->hw_mode_config_type =
17517 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
17518
Kiran Venkatappa06520822016-08-10 23:55:40 +053017519 return QDF_STATUS_SUCCESS;
17520}
17521
17522/**
17523 * extract_mac_phy_cap_service_ready_ext_tlv() -
17524 * extract MAC phy cap from service ready event
17525 * @wmi_handle: wmi handle
17526 * @param evt_buf: pointer to event buffer
17527 * @param param: Pointer to hold evt buf
17528 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017529 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017530 *
17531 * Return: QDF_STATUS_SUCCESS for success or error code
17532 */
17533static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17534 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017535 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017536 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017537{
17538 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017539 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017540 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17541 uint32_t phy_map;
17542 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017543
17544 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17545 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017546 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017547
17548 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017549 if (!hw_caps)
17550 return QDF_STATUS_E_INVAL;
17551
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017552 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17553 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17554 break;
17555
17556 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17557 while (phy_map) {
17558 phy_map >>= 1;
17559 phy_idx++;
17560 }
17561 }
17562
17563 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017564 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017565
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017566 phy_idx += phy_id;
17567 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017568 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017569
17570 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017571
17572 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017573 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17574 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017575 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017576 param->supports_11b =
17577 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17578 param->supports_11g =
17579 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17580 param->supports_11a =
17581 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17582 param->supports_11n =
17583 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17584 param->supports_11ac =
17585 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17586 param->supports_11ax =
17587 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017588
17589 param->supported_bands = mac_phy_caps->supported_bands;
17590 param->ampdu_density = mac_phy_caps->ampdu_density;
17591 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17592 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17593 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17594 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17595 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17596 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17597 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17598 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17599 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17600 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17601 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17602 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17603 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17604 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17605 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17606 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017607 qdf_mem_copy(&param->he_cap_phy_info_2G,
17608 &mac_phy_caps->he_cap_phy_info_2G,
17609 sizeof(param->he_cap_phy_info_2G));
17610 qdf_mem_copy(&param->he_cap_phy_info_5G,
17611 &mac_phy_caps->he_cap_phy_info_5G,
17612 sizeof(param->he_cap_phy_info_5G));
17613 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17614 sizeof(param->he_ppet2G));
17615 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17616 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017617 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017618
17619 return QDF_STATUS_SUCCESS;
17620}
17621
17622/**
17623 * extract_reg_cap_service_ready_ext_tlv() -
17624 * extract REG cap from service ready event
17625 * @wmi_handle: wmi handle
17626 * @param evt_buf: pointer to event buffer
17627 * @param param: Pointer to hold evt buf
17628 * @param phy_idx: phy idx should be less than num_mode
17629 *
17630 * Return: QDF_STATUS_SUCCESS for success or error code
17631 */
17632static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17633 wmi_unified_t wmi_handle,
17634 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017635 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017636{
17637 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17638 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17639 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17640
17641 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17642 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017643 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017644
17645 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017646 if (!reg_caps)
17647 return QDF_STATUS_E_INVAL;
17648
Kiran Venkatappa06520822016-08-10 23:55:40 +053017649 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017650 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017651
17652 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17653
17654 param->phy_id = ext_reg_cap->phy_id;
17655 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17656 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17657 param->regcap1 = ext_reg_cap->regcap1;
17658 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017659 param->wireless_modes = convert_wireless_modes_tlv(
17660 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017661 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17662 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17663 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17664 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17665
17666 return QDF_STATUS_SUCCESS;
17667}
17668
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017669/**
17670 * extract_dcs_interference_type_tlv() - extract dcs interference type
17671 * from event
17672 * @wmi_handle: wmi handle
17673 * @param evt_buf: pointer to event buffer
17674 * @param param: Pointer to hold dcs interference param
17675 *
17676 * Return: 0 for success or error code
17677 */
17678static QDF_STATUS extract_dcs_interference_type_tlv(
17679 wmi_unified_t wmi_handle,
17680 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17681{
17682 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17683
17684 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17685 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017686 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017687
17688 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017689 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17690 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017691
17692 return QDF_STATUS_SUCCESS;
17693}
17694
17695/*
17696 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17697 * @wmi_handle: wmi handle
17698 * @param evt_buf: pointer to event buffer
17699 * @param cw_int: Pointer to hold cw interference
17700 *
17701 * Return: 0 for success or error code
17702 */
17703static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17704 void *evt_buf,
17705 wmi_host_ath_dcs_cw_int *cw_int)
17706{
17707 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17708 wlan_dcs_cw_int *ev;
17709
17710 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17711 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017712 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017713
17714 ev = param_buf->cw_int;
17715
17716 cw_int->channel = ev->channel;
17717
17718 return QDF_STATUS_SUCCESS;
17719}
17720
17721/**
17722 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17723 * @wmi_handle: wmi handle
17724 * @param evt_buf: pointer to event buffer
17725 * @param wlan_stat: Pointer to hold wlan stats
17726 *
17727 * Return: 0 for success or error code
17728 */
17729static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17730 void *evt_buf,
17731 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17732{
17733 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17734 wlan_dcs_im_tgt_stats_t *ev;
17735
17736 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17737 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017738 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017739
17740 ev = param_buf->wlan_stat;
17741 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17742 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17743 wlan_stat->tx_waste_time = ev->tx_waste_time;
17744 wlan_stat->rx_time = ev->rx_time;
17745 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17746 wlan_stat->mib_stats.listen_time = ev->listen_time;
17747 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17748 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17749 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17750 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17751 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17752 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17753 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17754 wlan_stat->chan_nf = ev->chan_nf;
17755 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17756
17757 return QDF_STATUS_SUCCESS;
17758}
17759
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017760/**
17761 * extract_thermal_stats_tlv() - extract thermal stats from event
17762 * @wmi_handle: wmi handle
17763 * @param evt_buf: Pointer to event buffer
17764 * @param temp: Pointer to hold extracted temperature
17765 * @param level: Pointer to hold extracted level
17766 *
17767 * Return: 0 for success or error code
17768 */
17769static QDF_STATUS
17770extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17771 void *evt_buf, uint32_t *temp,
17772 uint32_t *level, uint32_t *pdev_id)
17773{
17774 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17775 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17776
17777 param_buf =
17778 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17779 if (!param_buf)
17780 return QDF_STATUS_E_INVAL;
17781
17782 tt_stats_event = param_buf->fixed_param;
17783
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017784 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17785 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017786 *temp = tt_stats_event->temp;
17787 *level = tt_stats_event->level;
17788
17789 return QDF_STATUS_SUCCESS;
17790}
17791
17792/**
17793 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17794 * @wmi_handle: wmi handle
17795 * @param evt_buf: pointer to event buffer
17796 * @param idx: Index to level stats
17797 * @param levelcount: Pointer to hold levelcount
17798 * @param dccount: Pointer to hold dccount
17799 *
17800 * Return: 0 for success or error code
17801 */
17802static QDF_STATUS
17803extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17804 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17805 uint32_t *dccount)
17806{
17807 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17808 wmi_therm_throt_level_stats_info *tt_level_info;
17809
17810 param_buf =
17811 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17812 if (!param_buf)
17813 return QDF_STATUS_E_INVAL;
17814
17815 tt_level_info = param_buf->therm_throt_level_stats_info;
17816
17817 if (idx < THERMAL_LEVELS) {
17818 *levelcount = tt_level_info[idx].level_count;
17819 *dccount = tt_level_info[idx].dc_count;
17820 return QDF_STATUS_SUCCESS;
17821 }
17822
17823 return QDF_STATUS_E_FAILURE;
17824}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017825#ifdef BIG_ENDIAN_HOST
17826/**
17827 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17828 * @param data_len - data length
17829 * @param data - pointer to data
17830 *
17831 * Return: QDF_STATUS - success or error status
17832 */
17833static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17834{
17835 uint8_t *data_aligned = NULL;
17836 int c;
17837 unsigned char *data_unaligned;
17838
17839 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17840 FIPS_ALIGN));
17841 /* Assigning unaligned space to copy the data */
17842 /* Checking if kmalloc does succesful allocation */
17843 if (data_unaligned == NULL)
17844 return QDF_STATUS_E_FAILURE;
17845
17846 /* Checking if space is alligned */
17847 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17848 /* align the data space */
17849 data_aligned =
17850 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17851 } else {
17852 data_aligned = (u_int8_t *)data_unaligned;
17853 }
17854
17855 /* memset and copy content from data to data aligned */
17856 OS_MEMSET(data_aligned, 0, data_len);
17857 OS_MEMCPY(data_aligned, data, data_len);
17858 /* Endianness to LE */
17859 for (c = 0; c < data_len/4; c++) {
17860 *((u_int32_t *)data_aligned + c) =
17861 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17862 }
17863
17864 /* Copy content to event->data */
17865 OS_MEMCPY(data, data_aligned, data_len);
17866
17867 /* clean up allocated space */
17868 qdf_mem_free(data_unaligned);
17869 data_aligned = NULL;
17870 data_unaligned = NULL;
17871
17872 /*************************************************************/
17873
17874 return QDF_STATUS_SUCCESS;
17875}
17876#else
17877/**
17878 * fips_conv_data_be() - DUMMY for LE platform
17879 *
17880 * Return: QDF_STATUS - success
17881 */
17882static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17883{
17884 return QDF_STATUS_SUCCESS;
17885}
17886#endif
17887
17888/**
17889 * extract_fips_event_data_tlv() - extract fips event data
17890 * @wmi_handle: wmi handle
17891 * @param evt_buf: pointer to event buffer
17892 * @param param: pointer FIPS event params
17893 *
17894 * Return: 0 for success or error code
17895 */
17896static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17897 void *evt_buf, struct wmi_host_fips_event_param *param)
17898{
17899 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17900 wmi_pdev_fips_event_fixed_param *event;
17901
17902 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17903 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17904
17905 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17906 QDF_STATUS_SUCCESS)
17907 return QDF_STATUS_E_FAILURE;
17908
17909 param->data = (uint32_t *)param_buf->data;
17910 param->data_len = event->data_len;
17911 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017912 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17913 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017914
17915 return QDF_STATUS_SUCCESS;
17916}
17917
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017918/*
17919 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17920 * @wmi_handle: wmi handle
17921 * @param evt_buf: pointer to event buffer
17922 * @param vdev_id: Pointer to hold vdev_id
17923 * @param mac_addr: Pointer to hold peer mac address
17924 *
17925 * Return: QDF_STATUS_SUCCESS for success or error code
17926 */
17927static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17928 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17929{
17930 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17931 wmi_peer_delete_resp_event_fixed_param *ev;
17932
17933 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17934
17935 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17936 if (!ev) {
17937 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17938 return QDF_STATUS_E_FAILURE;
17939 }
17940
17941 param->vdev_id = ev->vdev_id;
17942 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17943 &param->mac_address.bytes[0]);
17944
17945 return QDF_STATUS_SUCCESS;
17946}
17947
Govind Singhecf03cd2016-05-12 12:45:51 +053017948static bool is_management_record_tlv(uint32_t cmd_id)
17949{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017950 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017951 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017952
Govind Singhecf03cd2016-05-12 12:45:51 +053017953 return false;
17954}
17955
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017956static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17957{
17958 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17959
17960 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17961
17962 switch (set_cmd->param_id) {
17963 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17964 case WMI_VDEV_PARAM_DTIM_POLICY:
17965 return HTC_TX_PACKET_TAG_AUTO_PM;
17966 default:
17967 break;
17968 }
17969
17970 return 0;
17971}
17972
17973static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17974{
17975 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17976
17977 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17978
17979 switch (ps_cmd->param) {
17980 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17981 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17982 case WMI_STA_PS_ENABLE_QPOWER:
17983 return HTC_TX_PACKET_TAG_AUTO_PM;
17984 default:
17985 break;
17986 }
17987
17988 return 0;
17989}
17990
17991static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17992 uint32_t cmd_id)
17993{
17994 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17995 return 0;
17996
17997 switch (cmd_id) {
17998 case WMI_VDEV_SET_PARAM_CMDID:
17999 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
18000 case WMI_STA_POWERSAVE_PARAM_CMDID:
18001 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
18002 default:
18003 break;
18004 }
18005
18006 return 0;
18007}
18008
18009static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
18010{
18011 uint16_t tag = 0;
18012
18013 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
18014 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
18015 __func__);
18016 return tag;
18017 }
18018
18019 if (wmi_handle->tag_crash_inject)
18020 tag = HTC_TX_PACKET_TAG_AUTO_PM;
18021
18022 wmi_handle->tag_crash_inject = false;
18023 return tag;
18024}
18025
18026/**
18027 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
18028 * @wmi_handle: WMI handle
18029 * @buf: WMI buffer
18030 * @cmd_id: WMI command Id
18031 *
18032 * Return htc_tx_tag
18033 */
18034static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
18035 wmi_buf_t buf,
18036 uint32_t cmd_id)
18037{
18038 uint16_t htc_tx_tag = 0;
18039
18040 switch (cmd_id) {
18041 case WMI_WOW_ENABLE_CMDID:
18042 case WMI_PDEV_SUSPEND_CMDID:
18043 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
18044 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
18045 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
18046 case WMI_PDEV_RESUME_CMDID:
18047 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
18048 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
18049#ifdef FEATURE_WLAN_D0WOW
18050 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
18051#endif
18052 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
18053 break;
18054 case WMI_FORCE_FW_HANG_CMDID:
18055 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
18056 break;
18057 case WMI_VDEV_SET_PARAM_CMDID:
18058 case WMI_STA_POWERSAVE_PARAM_CMDID:
18059 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
18060 default:
18061 break;
18062 }
18063
18064 return htc_tx_tag;
18065}
18066
Sathish Kumard3ab1002017-02-07 17:10:59 +053018067/**
18068 * extract_channel_hopping_event_tlv() - extract channel hopping param
18069 * from event
18070 * @wmi_handle: wmi handle
18071 * @param evt_buf: pointer to event buffer
18072 * @param ch_hopping: Pointer to hold channel hopping param
18073 *
18074 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18075 */
18076static QDF_STATUS extract_channel_hopping_event_tlv(
18077 wmi_unified_t wmi_handle, void *evt_buf,
18078 wmi_host_pdev_channel_hopping_event *ch_hopping)
18079{
18080 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
18081 wmi_pdev_channel_hopping_event_fixed_param *event;
18082
18083 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
18084 event = (wmi_pdev_channel_hopping_event_fixed_param *)
18085 param_buf->fixed_param;
18086
18087 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
18088 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018089 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18090 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053018091
18092 return QDF_STATUS_SUCCESS;
18093}
18094
18095/**
18096 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
18097 * @wmi_handle: wmi handle
18098 * @param evt_buf: pointer to event buffer
18099 * @param param: Pointer to hold tpc param
18100 *
18101 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18102 */
18103static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
18104 void *evt_buf,
18105 wmi_host_pdev_tpc_event *param)
18106{
18107 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
18108 wmi_pdev_tpc_event_fixed_param *event;
18109
18110 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
18111 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
18112
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018113 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18114 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053018115 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
18116
18117 return QDF_STATUS_SUCCESS;
18118}
18119
18120
18121#ifdef BIG_ENDIAN_HOST
18122/**
18123 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
18124 * @param data_len - data length
18125 * @param data - pointer to data
18126 *
18127 * Return: QDF_STATUS - success or error status
18128 */
18129static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
18130{
18131 uint8_t *datap = (uint8_t *)ev;
18132 /* Skip swapping the first word */
18133 datap += sizeof(uint32_t);
18134 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
18135 i++, datap += sizeof(uint32_t)) {
18136 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
18137 }
18138
18139 return QDF_STATUS_SUCCESS;
18140}
18141#else
18142/**
18143 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
18144 * @param data_len - data length
18145 * @param data - pointer to data
18146 *
18147 * Return: QDF_STATUS - success or error status
18148 */
18149static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
18150{
18151 return QDF_STATUS_SUCCESS;
18152}
18153#endif
18154
18155/**
18156 * extract_wds_addr_event_tlv() - extract wds address from event
18157 * @wmi_handle: wmi handle
18158 * @param evt_buf: pointer to event buffer
18159 * @param wds_ev: Pointer to hold wds address
18160 *
18161 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18162 */
18163static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
18164 void *evt_buf,
18165 uint16_t len, wds_addr_event_t *wds_ev)
18166{
18167 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
18168 wmi_wds_addr_event_fixed_param *ev;
18169 int i;
18170
18171 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
18172 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
18173
18174 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
18175 return QDF_STATUS_E_FAILURE;
18176
18177 qdf_mem_copy(wds_ev->event_type, ev->event_type,
18178 sizeof(wds_ev->event_type));
18179 for (i = 0; i < 4; i++) {
18180 wds_ev->peer_mac[i] =
18181 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
18182 wds_ev->dest_mac[i] =
18183 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
18184 }
18185 for (i = 0; i < 2; i++) {
18186 wds_ev->peer_mac[4+i] =
18187 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
18188 wds_ev->dest_mac[4+i] =
18189 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
18190 }
18191 return QDF_STATUS_SUCCESS;
18192}
18193
18194/**
18195 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
18196 * from event
18197 * @wmi_handle: wmi handle
18198 * @param evt_buf: pointer to event buffer
18199 * @param ev: Pointer to hold peer param and ps state
18200 *
18201 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18202 */
18203static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
18204 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
18205{
18206 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
18207 wmi_peer_sta_ps_statechange_event_fixed_param *event;
18208
18209 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
18210 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
18211 param_buf->fixed_param;
18212
18213 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
18214 ev->peer_ps_state = event->peer_ps_state;
18215
18216 return QDF_STATUS_SUCCESS;
18217}
18218
18219/**
18220 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
18221 * @wmi_handle: wmi handle
18222 * @param evt_buf: pointer to event buffer
18223 * @param inst_rssi_resp: Pointer to hold inst rssi response
18224 *
18225 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
18226 */
18227static QDF_STATUS extract_inst_rssi_stats_event_tlv(
18228 wmi_unified_t wmi_handle, void *evt_buf,
18229 wmi_host_inst_stats_resp *inst_rssi_resp)
18230{
18231 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
18232 wmi_inst_rssi_stats_resp_fixed_param *event;
18233
18234 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
18235 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
18236
18237 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
18238 &(event->peer_macaddr), sizeof(wmi_mac_addr));
18239 inst_rssi_resp->iRSSI = event->iRSSI;
18240
18241 return QDF_STATUS_SUCCESS;
18242}
18243
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018244static struct cur_reg_rule
18245*create_reg_rules_from_wmi(uint32_t num_reg_rules,
18246 wmi_regulatory_rule_struct *wmi_reg_rule)
18247{
18248 struct cur_reg_rule *reg_rule_ptr;
18249 uint32_t count;
18250
18251 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
18252
18253 if (NULL == reg_rule_ptr) {
18254 WMI_LOGE("memory allocation failure");
18255 return NULL;
18256 }
18257
18258 for (count = 0; count < num_reg_rules; count++) {
18259 reg_rule_ptr[count].start_freq =
18260 WMI_REG_RULE_START_FREQ_GET(
18261 wmi_reg_rule[count].freq_info);
18262 reg_rule_ptr[count].end_freq =
18263 WMI_REG_RULE_END_FREQ_GET(
18264 wmi_reg_rule[count].freq_info);
18265 reg_rule_ptr[count].max_bw =
18266 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018267 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018268 reg_rule_ptr[count].reg_power =
18269 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018270 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053018271 reg_rule_ptr[count].ant_gain =
18272 WMI_REG_RULE_ANTENNA_GAIN_GET(
18273 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018274 reg_rule_ptr[count].flags =
18275 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070018276 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018277 }
18278
18279 return reg_rule_ptr;
18280}
18281
18282static QDF_STATUS extract_reg_chan_list_update_event_tlv(
18283 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18284 struct cur_regulatory_info *reg_info, uint32_t len)
18285{
18286 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
18287 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
18288 wmi_regulatory_rule_struct *wmi_reg_rule;
18289 uint32_t num_2g_reg_rules, num_5g_reg_rules;
18290
18291 WMI_LOGD("processing regulatory channel list");
18292
18293 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
18294 if (!param_buf) {
18295 WMI_LOGE("invalid channel list event buf");
18296 return QDF_STATUS_E_FAILURE;
18297 }
18298
18299 chan_list_event_hdr = param_buf->fixed_param;
18300
18301 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
18302 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
18303 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053018304 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018305 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
18306 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070018307 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070018308 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053018309 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070018310 reg_info->ctry_code = chan_list_event_hdr->country_id;
18311 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
18312 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
18313 reg_info->status_code = REG_SET_CC_STATUS_PASS;
18314 else if (chan_list_event_hdr->status_code ==
18315 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
18316 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
18317 else if (chan_list_event_hdr->status_code ==
18318 WMI_REG_INIT_ALPHA2_NOT_FOUND)
18319 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
18320 else if (chan_list_event_hdr->status_code ==
18321 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
18322 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
18323 else if (chan_list_event_hdr->status_code ==
18324 WMI_REG_SET_CC_STATUS_NO_MEMORY)
18325 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
18326 else if (chan_list_event_hdr->status_code ==
18327 WMI_REG_SET_CC_STATUS_FAIL)
18328 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
18329
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018330 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
18331 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
18332 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
18333 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
18334
18335 num_2g_reg_rules = reg_info->num_2g_reg_rules;
18336 num_5g_reg_rules = reg_info->num_5g_reg_rules;
18337
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018338 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
18339 __func__, reg_info->alpha2, reg_info->dfs_region,
18340 reg_info->min_bw_2g, reg_info->max_bw_2g,
18341 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018342
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018343 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
18344 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070018345 wmi_reg_rule =
18346 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
18347 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
18348 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018349 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
18350 wmi_reg_rule);
18351 wmi_reg_rule += num_2g_reg_rules;
18352
18353 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
18354 wmi_reg_rule);
18355
18356 WMI_LOGD("processed regulatory channel list");
18357
18358 return QDF_STATUS_SUCCESS;
18359}
18360
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018361static QDF_STATUS extract_reg_11d_new_country_event_tlv(
18362 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18363 struct reg_11d_new_country *reg_11d_country, uint32_t len)
18364{
18365 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
18366 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
18367
18368 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
18369 if (!param_buf) {
18370 WMI_LOGE("invalid 11d country event buf");
18371 return QDF_STATUS_E_FAILURE;
18372 }
18373
18374 reg_11d_country_event = param_buf->fixed_param;
18375
18376 qdf_mem_copy(reg_11d_country->alpha2,
18377 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
18378
18379 WMI_LOGD("processed 11d country event, new cc %s",
18380 reg_11d_country->alpha2);
18381
18382 return QDF_STATUS_SUCCESS;
18383}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070018384
18385static QDF_STATUS extract_reg_ch_avoid_event_tlv(
18386 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18387 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
18388{
18389 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
18390 wmi_avoid_freq_range_desc *afr_desc;
18391 uint32_t num_freq_ranges, freq_range_idx;
18392 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
18393 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
18394
18395 if (!param_buf) {
18396 WMI_LOGE("Invalid channel avoid event buffer");
18397 return QDF_STATUS_E_INVAL;
18398 }
18399
18400 afr_fixed_param = param_buf->fixed_param;
18401 if (!afr_fixed_param) {
18402 WMI_LOGE("Invalid channel avoid event fixed param buffer");
18403 return QDF_STATUS_E_INVAL;
18404 }
18405
18406 if (!ch_avoid_ind) {
18407 WMI_LOGE("Invalid channel avoid indication buffer");
18408 return QDF_STATUS_E_INVAL;
18409 }
18410 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
18411 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
18412 afr_fixed_param->num_freq_ranges;
18413
18414 WMI_LOGD("Channel avoid event received with %d ranges",
18415 num_freq_ranges);
18416
18417 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
18418 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
18419 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
18420 freq_range_idx++) {
18421 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
18422 afr_desc->start_freq;
18423 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
18424 afr_desc->end_freq;
18425 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
18426 freq_range_idx, afr_desc->tlv_header,
18427 afr_desc->start_freq, afr_desc->end_freq);
18428 afr_desc++;
18429 }
18430
18431 return QDF_STATUS_SUCCESS;
18432}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018433#ifdef DFS_COMPONENT_ENABLE
18434/**
18435 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
18436 * @wmi_handle: wma handle
18437 * @evt_buf: event buffer
18438 * @vdev_id: vdev id
18439 * @len: length of buffer
18440 *
18441 * Return: 0 for success or error code
18442 */
18443static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
18444 uint8_t *evt_buf,
18445 uint32_t *vdev_id,
18446 uint32_t len)
18447{
18448 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
18449 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
18450
18451 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
18452 if (!param_tlvs) {
18453 WMI_LOGE("invalid cac complete event buf");
18454 return QDF_STATUS_E_FAILURE;
18455 }
18456
18457 cac_event = param_tlvs->fixed_param;
18458 *vdev_id = cac_event->vdev_id;
18459 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
18460
18461 return QDF_STATUS_SUCCESS;
18462}
18463
18464/**
18465 * extract_dfs_radar_detection_event_tlv() - extract radar found event
18466 * @wmi_handle: wma handle
18467 * @evt_buf: event buffer
18468 * @radar_found: radar found event info
18469 * @len: length of buffer
18470 *
18471 * Return: 0 for success or error code
18472 */
18473static QDF_STATUS extract_dfs_radar_detection_event_tlv(
18474 wmi_unified_t wmi_handle,
18475 uint8_t *evt_buf,
18476 struct radar_found_info *radar_found,
18477 uint32_t len)
18478{
18479 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
18480 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
18481
18482 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
18483 if (!param_tlv) {
18484 WMI_LOGE("invalid radar detection event buf");
18485 return QDF_STATUS_E_FAILURE;
18486 }
18487
18488 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018489 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18490 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018491 radar_found->detection_mode = radar_event->detection_mode;
18492 radar_found->freq_offset = radar_event->chan_freq;
18493 radar_found->chan_width = radar_event->chan_width;
18494 radar_found->detector_id = radar_event->detector_id;
18495 radar_found->segment_id = radar_event->segment_id;
18496 radar_found->timestamp = radar_event->timestamp;
18497 radar_found->is_chirp = radar_event->is_chirp;
18498
18499 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
18500
18501 return QDF_STATUS_SUCCESS;
18502}
18503#endif
18504
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018505/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018506 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
18507 * host to target defines. For legacy there is not conversion
18508 * required. Just return pdev_id as it is.
18509 * @param pdev_id: host pdev_id to be converted.
18510 * Return: target pdev_id after conversion.
18511 */
18512static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
18513 uint32_t pdev_id)
18514{
18515 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
18516 return WMI_PDEV_ID_SOC;
18517
18518 /*No conversion required*/
18519 return pdev_id;
18520}
18521
18522/**
18523 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
18524 * target to host defines. For legacy there is not conversion
18525 * required. Just return pdev_id as it is.
18526 * @param pdev_id: target pdev_id to be converted.
18527 * Return: host pdev_id after conversion.
18528 */
18529static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
18530 uint32_t pdev_id)
18531{
18532 /*No conversion required*/
18533 return pdev_id;
18534}
18535
18536/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018537 * send_set_country_cmd_tlv() - WMI scan channel list function
18538 * @param wmi_handle : handle to WMI.
18539 * @param param : pointer to hold scan channel list parameter
18540 *
18541 * Return: 0 on success and -ve on failure.
18542 */
18543static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
18544 struct set_country *params)
18545{
18546 wmi_buf_t buf;
18547 QDF_STATUS qdf_status;
18548 wmi_set_current_country_cmd_fixed_param *cmd;
18549 uint16_t len = sizeof(*cmd);
18550
18551 buf = wmi_buf_alloc(wmi_handle, len);
18552 if (!buf) {
18553 WMI_LOGE("Failed to allocate memory");
18554 qdf_status = QDF_STATUS_E_NOMEM;
18555 goto end;
18556 }
18557
18558 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
18559 WMITLV_SET_HDR(&cmd->tlv_header,
18560 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
18561 WMITLV_GET_STRUCT_TLVLEN
18562 (wmi_set_current_country_cmd_fixed_param));
18563
18564 WMI_LOGD("setting cuurnet country to %s", params->country);
18565
18566 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
18567
18568 cmd->pdev_id = params->pdev_id;
18569
18570 qdf_status = wmi_unified_cmd_send(wmi_handle,
18571 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18572
18573 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18574 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18575 wmi_buf_free(buf);
18576 }
18577
18578end:
18579 return qdf_status;
18580}
18581
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018582#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
18583 WMI_SET_BITS(alpha, 0, 8, val0); \
18584 WMI_SET_BITS(alpha, 8, 8, val1); \
18585 WMI_SET_BITS(alpha, 16, 8, val2); \
18586 } while (0)
18587
18588static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
18589 uint8_t pdev_id, struct cc_regdmn_s *rd)
18590{
18591 wmi_set_init_country_cmd_fixed_param *cmd;
18592 uint16_t len;
18593 wmi_buf_t buf;
18594 int ret;
18595
18596 len = sizeof(wmi_set_init_country_cmd_fixed_param);
18597 buf = wmi_buf_alloc(wmi_handle, len);
18598 if (!buf) {
18599 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
18600 return QDF_STATUS_E_NOMEM;
18601 }
18602 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
18603 WMITLV_SET_HDR(&cmd->tlv_header,
18604 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
18605 WMITLV_GET_STRUCT_TLVLEN
18606 (wmi_set_init_country_cmd_fixed_param));
18607
18608 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
18609
18610 if (rd->flags == CC_IS_SET) {
18611 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
18612 cmd->country_code.country_id = rd->cc.country_code;
18613 } else if (rd->flags == ALPHA_IS_SET) {
18614 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
18615 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
18616 rd->cc.alpha[0],
18617 rd->cc.alpha[1],
18618 rd->cc.alpha[2]);
18619 } else if (rd->flags == REGDMN_IS_SET) {
18620 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
18621 cmd->country_code.domain_code = rd->cc.regdmn_id;
18622 }
18623
18624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
18625 WMI_SET_INIT_COUNTRY_CMDID);
18626 if (ret) {
18627 WMI_LOGE("Failed to config wow wakeup event");
18628 wmi_buf_free(buf);
18629 return QDF_STATUS_E_FAILURE;
18630 }
18631
18632 return QDF_STATUS_SUCCESS;
18633}
18634
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053018635/**
18636 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
18637 * configuration params
18638 * @wmi_handle: wmi handler
18639 * @limit_off_chan_param: pointer to wmi_off_chan_param
18640 *
18641 * Return: 0 for success and non zero for failure
18642 */
18643static
18644QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
18645 struct wmi_limit_off_chan_param *limit_off_chan_param)
18646{
18647 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
18648 wmi_buf_t buf;
18649 uint32_t len = sizeof(*cmd);
18650 int err;
18651
18652 buf = wmi_buf_alloc(wmi_handle, len);
18653 if (!buf) {
18654 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
18655 __func__);
18656 return QDF_STATUS_E_NOMEM;
18657 }
18658
18659 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
18660
18661 WMITLV_SET_HDR(&cmd->tlv_header,
18662 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
18663 WMITLV_GET_STRUCT_TLVLEN(
18664 wmi_vdev_limit_offchan_cmd_fixed_param));
18665
18666 cmd->vdev_id = limit_off_chan_param->vdev_id;
18667
18668 cmd->flags &= 0;
18669 if (limit_off_chan_param->status)
18670 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
18671 if (limit_off_chan_param->skip_dfs_chans)
18672 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
18673
18674 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
18675 cmd->rest_time = limit_off_chan_param->rest_time;
18676
18677 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
18678 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
18679 cmd->rest_time);
18680
18681 err = wmi_unified_cmd_send(wmi_handle, buf,
18682 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
18683 if (QDF_IS_STATUS_ERROR(err)) {
18684 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
18685 wmi_buf_free(buf);
18686 return QDF_STATUS_E_FAILURE;
18687 }
18688
18689 return QDF_STATUS_SUCCESS;
18690}
18691
Govind Singh5eb51532016-03-09 11:34:12 +053018692struct wmi_ops tlv_ops = {
18693 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18694 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18695 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018696 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18697 .send_hidden_ssid_vdev_restart_cmd =
18698 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018699 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18700 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18701 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018702 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018703 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018704 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018705 .send_peer_rx_reorder_queue_setup_cmd =
18706 send_peer_rx_reorder_queue_setup_cmd_tlv,
18707 .send_peer_rx_reorder_queue_remove_cmd =
18708 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018709 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18710 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18711 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018712 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18713 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18714 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18715 .send_suspend_cmd = send_suspend_cmd_tlv,
18716 .send_resume_cmd = send_resume_cmd_tlv,
18717 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18718 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18719 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18720 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18721 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18722 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18723 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18724 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070018725 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018726 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018727 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018728 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18729 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18730 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18731 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018732 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018733 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018734 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18735 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018736 .send_set_sta_uapsd_auto_trig_cmd =
18737 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018738 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18739 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18740 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018741#ifdef CONVERGED_P2P_ENABLE
18742 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18743 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18744#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018745 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18746 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018747 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18748 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18749 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18750 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18751 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18752 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18753 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018754 .send_ocb_start_timing_advert_cmd =
18755 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018756 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18757 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18758 .send_set_mcc_channel_time_latency_cmd =
18759 send_set_mcc_channel_time_latency_cmd_tlv,
18760 .send_set_mcc_channel_time_quota_cmd =
18761 send_set_mcc_channel_time_quota_cmd_tlv,
18762 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18763 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018764 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018765 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18766 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18767 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018768 .send_probe_rsp_tmpl_send_cmd =
18769 send_probe_rsp_tmpl_send_cmd_tlv,
18770 .send_p2p_go_set_beacon_ie_cmd =
18771 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018772 .send_setup_install_key_cmd =
18773 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018774 .send_set_gateway_params_cmd =
18775 send_set_gateway_params_cmd_tlv,
18776 .send_set_rssi_monitoring_cmd =
18777 send_set_rssi_monitoring_cmd_tlv,
18778 .send_scan_probe_setoui_cmd =
18779 send_scan_probe_setoui_cmd_tlv,
18780 .send_reset_passpoint_network_list_cmd =
18781 send_reset_passpoint_network_list_cmd_tlv,
18782 .send_set_passpoint_network_list_cmd =
18783 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018784 .send_roam_scan_offload_rssi_thresh_cmd =
18785 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070018786 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018787 .send_roam_scan_filter_cmd =
18788 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018789 .send_set_epno_network_list_cmd =
18790 send_set_epno_network_list_cmd_tlv,
18791 .send_ipa_offload_control_cmd =
18792 send_ipa_offload_control_cmd_tlv,
18793 .send_extscan_get_capabilities_cmd =
18794 send_extscan_get_capabilities_cmd_tlv,
18795 .send_extscan_get_cached_results_cmd =
18796 send_extscan_get_cached_results_cmd_tlv,
18797 .send_extscan_stop_change_monitor_cmd =
18798 send_extscan_stop_change_monitor_cmd_tlv,
18799 .send_extscan_start_change_monitor_cmd =
18800 send_extscan_start_change_monitor_cmd_tlv,
18801 .send_extscan_stop_hotlist_monitor_cmd =
18802 send_extscan_stop_hotlist_monitor_cmd_tlv,
18803 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18804 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18805 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18806 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18807 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18808 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070018809 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018810 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18811 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18812 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18813 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18814 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018815 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018816 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18817 .send_snr_cmd = send_snr_cmd_tlv,
18818 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018819#ifdef WLAN_PMO_ENABLE
18820 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18821 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18822 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18823 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018824 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018825 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18826 .send_process_gtk_offload_getinfo_cmd =
18827 send_process_gtk_offload_getinfo_cmd_tlv,
18828 .send_enable_enhance_multicast_offload_cmd =
18829 send_enable_enhance_multicast_offload_tlv,
18830 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18831#ifdef FEATURE_WLAN_RA_FILTERING
18832 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18833#endif
18834 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018835 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18836 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018837 .send_lphb_config_tcp_pkt_filter_cmd =
18838 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018839 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18840 .send_lphb_config_udp_pkt_filter_cmd =
18841 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018842 .send_enable_disable_packet_filter_cmd =
18843 send_enable_disable_packet_filter_cmd_tlv,
18844 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018845#endif /* End of WLAN_PMO_ENABLE */
18846#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018847 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18848 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18849 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018850 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018851 .send_roam_scan_offload_mode_cmd =
18852 send_roam_scan_offload_mode_cmd_tlv,
18853 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18854 .send_roam_scan_offload_ap_profile_cmd =
18855 send_roam_scan_offload_ap_profile_cmd_tlv,
18856#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018857 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18858 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018859 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18860 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018861#ifdef WLAN_FEATURE_CIF_CFR
18862 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18863#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018864 .send_dfs_phyerr_filter_offload_en_cmd =
18865 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018866 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18867 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18868 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18869 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18870 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018871 .send_process_add_periodic_tx_ptrn_cmd =
18872 send_process_add_periodic_tx_ptrn_cmd_tlv,
18873 .send_process_del_periodic_tx_ptrn_cmd =
18874 send_process_del_periodic_tx_ptrn_cmd_tlv,
18875 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18876 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18877 .send_set_app_type2_params_in_fw_cmd =
18878 send_set_app_type2_params_in_fw_cmd_tlv,
18879 .send_set_auto_shutdown_timer_cmd =
18880 send_set_auto_shutdown_timer_cmd_tlv,
18881 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18882 .send_process_dhcpserver_offload_cmd =
18883 send_process_dhcpserver_offload_cmd_tlv,
18884 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18885 .send_process_ch_avoid_update_cmd =
18886 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018887 .send_pdev_set_regdomain_cmd =
18888 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018889 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18890 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18891 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18892 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18893 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18894 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018895#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018896 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018897#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018898 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018899 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018900 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018901 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018902 .send_set_base_macaddr_indicate_cmd =
18903 send_set_base_macaddr_indicate_cmd_tlv,
18904 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18905 .send_enable_specific_fw_logs_cmd =
18906 send_enable_specific_fw_logs_cmd_tlv,
18907 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018908 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018909 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018910 .send_pdev_set_dual_mac_config_cmd =
18911 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018912 .send_app_type1_params_in_fw_cmd =
18913 send_app_type1_params_in_fw_cmd_tlv,
18914 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18915 .send_process_roam_synch_complete_cmd =
18916 send_process_roam_synch_complete_cmd_tlv,
18917 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18918 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18919 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018920 .send_roam_scan_offload_scan_period_cmd =
18921 send_roam_scan_offload_scan_period_cmd_tlv,
18922 .send_roam_scan_offload_chan_list_cmd =
18923 send_roam_scan_offload_chan_list_cmd_tlv,
18924 .send_roam_scan_offload_rssi_change_cmd =
18925 send_roam_scan_offload_rssi_change_cmd_tlv,
18926 .send_get_buf_extscan_hotlist_cmd =
18927 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018928 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018929 .send_adapt_dwelltime_params_cmd =
18930 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018931 .send_dbs_scan_sel_params_cmd =
18932 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018933 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018934 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18935 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18936 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18937 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18938 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18939 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18940 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18941 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18942 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018943 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18944 .send_smart_ant_set_training_info_cmd =
18945 send_smart_ant_set_training_info_cmd_tlv,
18946 .send_smart_ant_set_node_config_cmd =
18947 send_smart_ant_set_node_config_cmd_tlv,
18948 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18949 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18950 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018951 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18952 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18953 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18954 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18955 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18956 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18957 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018958 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18959 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18960 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18961 .send_vdev_spectral_configure_cmd =
18962 send_vdev_spectral_configure_cmd_tlv,
18963 .send_vdev_spectral_enable_cmd =
18964 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018965 .send_thermal_mitigation_param_cmd =
18966 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018967 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18968 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053018969 .send_process_update_edca_param_cmd =
18970 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018971 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018972 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018973 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18974 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18975 .extract_host_mem_req = extract_host_mem_req_tlv,
18976 .save_service_bitmap = save_service_bitmap_tlv,
18977 .is_service_enabled = is_service_enabled_tlv,
18978 .save_fw_version = save_fw_version_in_service_ready_tlv,
18979 .ready_extract_init_status = ready_extract_init_status_tlv,
18980 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070018981 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018982 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18983 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18984 .extract_tbttoffset_update_params =
18985 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018986 .extract_ext_tbttoffset_update_params =
18987 extract_ext_tbttoffset_update_params_tlv,
18988 .extract_tbttoffset_num_vdevs =
18989 extract_tbttoffset_num_vdevs_tlv,
18990 .extract_ext_tbttoffset_num_vdevs =
18991 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018992 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18993 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18994 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18995 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018996#ifdef CONVERGED_TDLS_ENABLE
18997 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18998#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018999 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019000 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053019001 .extract_swba_tim_info = extract_swba_tim_info_tlv,
19002 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080019003#ifdef CONVERGED_P2P_ENABLE
19004 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
19005 .extract_p2p_lo_stop_ev_param =
19006 extract_p2p_lo_stop_ev_param_tlv,
19007#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053019008 .extract_offchan_data_tx_compl_param =
19009 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053019010 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
19011 .extract_all_stats_count = extract_all_stats_counts_tlv,
19012 .extract_pdev_stats = extract_pdev_stats_tlv,
19013 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
19014 .extract_vdev_stats = extract_vdev_stats_tlv,
19015 .extract_peer_stats = extract_peer_stats_tlv,
19016 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
19017 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
19018 .extract_chan_stats = extract_chan_stats_tlv,
19019 .extract_profile_ctx = extract_profile_ctx_tlv,
19020 .extract_profile_data = extract_profile_data_tlv,
19021 .extract_chan_info_event = extract_chan_info_event_tlv,
19022 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053019023 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053019024 .send_encrypt_decrypt_send_cmd =
19025 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080019026 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053019027 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053019028 .send_multiple_vdev_restart_req_cmd =
19029 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053019030 .extract_service_ready_ext = extract_service_ready_ext_tlv,
19031 .extract_hw_mode_cap_service_ready_ext =
19032 extract_hw_mode_cap_service_ready_ext_tlv,
19033 .extract_mac_phy_cap_service_ready_ext =
19034 extract_mac_phy_cap_service_ready_ext_tlv,
19035 .extract_reg_cap_service_ready_ext =
19036 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019037 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019038 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019039 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
19040 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
19041 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019042 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053019043 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019044 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053019045 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019046 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053019047 .extract_pdev_csa_switch_count_status =
19048 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053019049 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
19050 .extract_wds_addr_event = extract_wds_addr_event_tlv,
19051 .extract_peer_sta_ps_statechange_ev =
19052 extract_peer_sta_ps_statechange_ev_tlv,
19053 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053019054 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080019055 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
19056 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019057 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019058 extract_reg_chan_list_update_event_tlv,
19059 .extract_chainmask_tables =
19060 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019061 .extract_thermal_stats = extract_thermal_stats_tlv,
19062 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019063#ifdef DFS_COMPONENT_ENABLE
19064 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
19065 .extract_dfs_radar_detection_event =
19066 extract_dfs_radar_detection_event_tlv,
19067#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019068 .convert_pdev_id_host_to_target =
19069 convert_host_pdev_id_to_target_pdev_id_legacy,
19070 .convert_pdev_id_target_to_host =
19071 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070019072
19073 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
19074 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
19075 .extract_reg_11d_new_country_event =
19076 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053019077 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053019078 .send_limit_off_chan_cmd =
19079 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070019080 .extract_reg_ch_avoid_event =
19081 extract_reg_ch_avoid_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053019082};
19083
Govind Singhe7f2f342016-05-23 12:12:52 +053019084/**
19085 * populate_tlv_event_id() - populates wmi event ids
19086 *
19087 * @param event_ids: Pointer to hold event ids
19088 * Return: None
19089 */
19090static void populate_tlv_events_id(uint32_t *event_ids)
19091{
19092 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
19093 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
19094 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
19095 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
19096 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
19097 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
19098 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
19099 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
19100 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
19101 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
19102 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
19103 event_ids[wmi_service_ready_ext_event_id] =
19104 WMI_SERVICE_READY_EXT_EVENTID;
19105 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
19106 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
19107 event_ids[wmi_vdev_install_key_complete_event_id] =
19108 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
19109 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
19110 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
19111
19112 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
19113 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
19114 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
19115 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
19116 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
19117 event_ids[wmi_peer_estimated_linkspeed_event_id] =
19118 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
19119 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019120 event_ids[wmi_peer_delete_response_event_id] =
19121 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019122 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
19123 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
19124 event_ids[wmi_tbttoffset_update_event_id] =
19125 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019126 event_ids[wmi_ext_tbttoffset_update_event_id] =
19127 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019128 event_ids[wmi_offload_bcn_tx_status_event_id] =
19129 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
19130 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
19131 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
19132 event_ids[wmi_mgmt_tx_completion_event_id] =
19133 WMI_MGMT_TX_COMPLETION_EVENTID;
19134
19135 event_ids[wmi_tx_delba_complete_event_id] =
19136 WMI_TX_DELBA_COMPLETE_EVENTID;
19137 event_ids[wmi_tx_addba_complete_event_id] =
19138 WMI_TX_ADDBA_COMPLETE_EVENTID;
19139 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
19140
19141 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
19142
19143 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
19144 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
19145
19146 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
19147
19148 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
19149
19150 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080019151 event_ids[wmi_p2p_lo_stop_event_id] =
19152 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019153 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
19154 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
19155 event_ids[wmi_do_wow_disable_ack_event_id] =
19156 WMI_D0_WOW_DISABLE_ACK_EVENTID;
19157 event_ids[wmi_wow_initial_wakeup_event_id] =
19158 WMI_WOW_INITIAL_WAKEUP_EVENTID;
19159
19160 event_ids[wmi_rtt_meas_report_event_id] =
19161 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
19162 event_ids[wmi_tsf_meas_report_event_id] =
19163 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
19164 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
19165 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
19166 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
19167 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
19168 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
19169 event_ids[wmi_update_fw_mem_dump_event_id] =
19170 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
19171 event_ids[wmi_diag_event_id_log_supported_event_id] =
19172 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
19173 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
19174 event_ids[wmi_nlo_scan_complete_event_id] =
19175 WMI_NLO_SCAN_COMPLETE_EVENTID;
19176 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
19177 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
19178
19179 event_ids[wmi_gtk_offload_status_event_id] =
19180 WMI_GTK_OFFLOAD_STATUS_EVENTID;
19181 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
19182 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
19183 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
19184
19185 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
19186
19187 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
19188
19189 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
19190 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
19191 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
19192 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
19193 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
19194 event_ids[wmi_wlan_profile_data_event_id] =
19195 WMI_WLAN_PROFILE_DATA_EVENTID;
19196 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
19197 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
19198 event_ids[wmi_vdev_get_keepalive_event_id] =
19199 WMI_VDEV_GET_KEEPALIVE_EVENTID;
19200 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
19201
19202 event_ids[wmi_diag_container_event_id] =
19203 WMI_DIAG_DATA_CONTAINER_EVENTID;
19204
19205 event_ids[wmi_host_auto_shutdown_event_id] =
19206 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
19207
19208 event_ids[wmi_update_whal_mib_stats_event_id] =
19209 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
19210
19211 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
19212 event_ids[wmi_update_vdev_rate_stats_event_id] =
19213 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
19214
19215 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
19216
19217 /** Set OCB Sched Response, deprecated */
19218 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
19219
19220 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
19221 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
19222 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
19223
19224 /* GPIO Event */
19225 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
19226 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
19227
19228 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
19229 event_ids[wmi_rfkill_state_change_event_id] =
19230 WMI_RFKILL_STATE_CHANGE_EVENTID;
19231
19232 /* TDLS Event */
19233 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
19234
19235 event_ids[wmi_batch_scan_enabled_event_id] =
19236 WMI_BATCH_SCAN_ENABLED_EVENTID;
19237 event_ids[wmi_batch_scan_result_event_id] =
19238 WMI_BATCH_SCAN_RESULT_EVENTID;
19239 /* OEM Event */
19240 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
19241 event_ids[wmi_oem_meas_report_event_id] =
19242 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
19243 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
19244
19245 /* NAN Event */
19246 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
19247
19248 /* LPI Event */
19249 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
19250 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
19251 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
19252
19253 /* ExtScan events */
19254 event_ids[wmi_extscan_start_stop_event_id] =
19255 WMI_EXTSCAN_START_STOP_EVENTID;
19256 event_ids[wmi_extscan_operation_event_id] =
19257 WMI_EXTSCAN_OPERATION_EVENTID;
19258 event_ids[wmi_extscan_table_usage_event_id] =
19259 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
19260 event_ids[wmi_extscan_cached_results_event_id] =
19261 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
19262 event_ids[wmi_extscan_wlan_change_results_event_id] =
19263 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
19264 event_ids[wmi_extscan_hotlist_match_event_id] =
19265 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
19266 event_ids[wmi_extscan_capabilities_event_id] =
19267 WMI_EXTSCAN_CAPABILITIES_EVENTID;
19268 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
19269 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
19270
19271 /* mDNS offload events */
19272 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
19273
19274 /* SAP Authentication offload events */
19275 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
19276 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
19277
19278 /** Out-of-context-of-bss (OCB) events */
19279 event_ids[wmi_ocb_set_config_resp_event_id] =
19280 WMI_OCB_SET_CONFIG_RESP_EVENTID;
19281 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
19282 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
19283 event_ids[wmi_dcc_get_stats_resp_event_id] =
19284 WMI_DCC_GET_STATS_RESP_EVENTID;
19285 event_ids[wmi_dcc_update_ndl_resp_event_id] =
19286 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
19287 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
19288 /* System-On-Chip events */
19289 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
19290 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
19291 event_ids[wmi_soc_hw_mode_transition_event_id] =
19292 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
19293 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
19294 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053019295 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053019296 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
19297 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053019298 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053019299 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
19300 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
19301 event_ids[wmi_peer_sta_ps_statechg_event_id] =
19302 WMI_PEER_STA_PS_STATECHG_EVENTID;
19303 event_ids[wmi_pdev_channel_hopping_event_id] =
19304 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053019305 event_ids[wmi_offchan_data_tx_completion_event] =
19306 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070019307 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
19308 event_ids[wmi_dfs_radar_detection_event_id] =
19309 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019310 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070019311 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019312}
19313
Soumya Bhat488092d2017-03-22 14:41:01 +053019314#ifndef CONFIG_MCL
19315/**
19316 * populate_tlv_service() - populates wmi services
19317 *
19318 * @param wmi_service: Pointer to hold wmi_service
19319 * Return: None
19320 */
19321static void populate_tlv_service(uint32_t *wmi_service)
19322{
19323 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
19324 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
19325 wmi_service[wmi_service_roam_scan_offload] =
19326 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
19327 wmi_service[wmi_service_bcn_miss_offload] =
19328 WMI_SERVICE_BCN_MISS_OFFLOAD;
19329 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
19330 wmi_service[wmi_service_sta_advanced_pwrsave] =
19331 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
19332 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
19333 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
19334 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
19335 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
19336 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
19337 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
19338 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
19339 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
19340 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
19341 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
19342 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
19343 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
19344 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
19345 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
19346 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
19347 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
19348 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
19349 wmi_service[wmi_service_packet_power_save] =
19350 WMI_SERVICE_PACKET_POWER_SAVE;
19351 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
19352 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
19353 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
19354 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
19355 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
19356 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
19357 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
19358 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
19359 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
19360 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
19361 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
19362 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
19363 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
19364 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
19365 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
19366 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
19367 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
19368 wmi_service[wmi_service_mcc_bcn_interval_change] =
19369 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
19370 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
19371 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
19372 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
19373 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
19374 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
19375 wmi_service[wmi_service_lte_ant_share_support] =
19376 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
19377 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
19378 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
19379 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
19380 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
19381 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
19382 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
19383 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
19384 wmi_service[wmi_service_bcn_txrate_override] =
19385 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
19386 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
19387 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
19388 wmi_service[wmi_service_estimate_linkspeed] =
19389 WMI_SERVICE_ESTIMATE_LINKSPEED;
19390 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
19391 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
19392 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
19393 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
19394 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
19395 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
19396 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
19397 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
19398 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
19399 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
19400 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
19401 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
19402 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
19403 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
19404 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
19405 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
19406 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
19407 wmi_service[wmi_service_sap_auth_offload] =
19408 WMI_SERVICE_SAP_AUTH_OFFLOAD;
19409 wmi_service[wmi_service_dual_band_simultaneous_support] =
19410 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
19411 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
19412 wmi_service[wmi_service_ap_arpns_offload] =
19413 WMI_SERVICE_AP_ARPNS_OFFLOAD;
19414 wmi_service[wmi_service_per_band_chainmask_support] =
19415 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
19416 wmi_service[wmi_service_packet_filter_offload] =
19417 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
19418 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
19419 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
19420 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
19421 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
19422 wmi_service[wmi_service_multiple_vdev_restart] =
19423 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
19424
19425 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
19426 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
19427 wmi_service[wmi_service_smart_antenna_sw_support] =
19428 WMI_SERVICE_UNAVAILABLE;
19429 wmi_service[wmi_service_smart_antenna_hw_support] =
19430 WMI_SERVICE_UNAVAILABLE;
19431 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
19432 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019433 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053019434 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
19435 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
19436 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
19437 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
19438 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
19439 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
19440 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
19441 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053019442 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
19443 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
19444 wmi_service[wmi_service_periodic_chan_stat_support] =
19445 WMI_SERVICE_UNAVAILABLE;
19446 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
19447 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
19448 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
19449 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
19450 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
19451 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053019452 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
19453 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
19454 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
19455 wmi_service[wmi_service_unified_wow_capability] =
19456 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
19457 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
19458 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
19459 wmi_service[wmi_service_sync_delete_cmds] =
19460 WMI_SERVICE_SYNC_DELETE_CMDS;
19461 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
19462 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
19463 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
19464 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
19465 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
19466 wmi_service[wmi_service_deprecated_replace] =
19467 WMI_SERVICE_DEPRECATED_REPLACE;
19468 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
19469 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
19470 wmi_service[wmi_service_enhanced_mcast_filter] =
19471 WMI_SERVICE_ENHANCED_MCAST_FILTER;
19472 wmi_service[wmi_service_half_rate_quarter_rate_support] =
19473 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
19474 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
19475 wmi_service[wmi_service_p2p_listen_offload_support] =
19476 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
19477 wmi_service[wmi_service_mark_first_wakeup_packet] =
19478 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
19479 wmi_service[wmi_service_multiple_mcast_filter_set] =
19480 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
19481 wmi_service[wmi_service_host_managed_rx_reorder] =
19482 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
19483 wmi_service[wmi_service_flash_rdwr_support] =
19484 WMI_SERVICE_FLASH_RDWR_SUPPORT;
19485 wmi_service[wmi_service_wlan_stats_report] =
19486 WMI_SERVICE_WLAN_STATS_REPORT;
19487 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
19488 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
19489 wmi_service[wmi_service_dfs_phyerr_offload] =
19490 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
19491 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
19492 wmi_service[wmi_service_fw_mem_dump_support] =
19493 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
19494 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
19495 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
19496 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
19497 wmi_service[wmi_service_hw_data_filtering] =
19498 WMI_SERVICE_HW_DATA_FILTERING;
19499 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
19500 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053019501 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053019502 wmi_service[wmi_service_extended_nss_support] =
19503 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053019504}
19505
Govind Singhe7f2f342016-05-23 12:12:52 +053019506/**
19507 * populate_pdev_param_tlv() - populates pdev params
19508 *
19509 * @param pdev_param: Pointer to hold pdev params
19510 * Return: None
19511 */
19512static void populate_pdev_param_tlv(uint32_t *pdev_param)
19513{
19514 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
19515 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
19516 pdev_param[wmi_pdev_param_txpower_limit2g] =
19517 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
19518 pdev_param[wmi_pdev_param_txpower_limit5g] =
19519 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
19520 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
19521 pdev_param[wmi_pdev_param_beacon_gen_mode] =
19522 WMI_PDEV_PARAM_BEACON_GEN_MODE;
19523 pdev_param[wmi_pdev_param_beacon_tx_mode] =
19524 WMI_PDEV_PARAM_BEACON_TX_MODE;
19525 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
19526 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
19527 pdev_param[wmi_pdev_param_protection_mode] =
19528 WMI_PDEV_PARAM_PROTECTION_MODE;
19529 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
19530 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
19531 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
19532 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
19533 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
19534 pdev_param[wmi_pdev_param_sta_kickout_th] =
19535 WMI_PDEV_PARAM_STA_KICKOUT_TH;
19536 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
19537 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
19538 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
19539 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
19540 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
19541 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
19542 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
19543 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
19544 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
19545 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
19546 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
19547 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
19548 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
19549 pdev_param[wmi_pdev_param_ltr_sleep_override] =
19550 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
19551 pdev_param[wmi_pdev_param_ltr_rx_override] =
19552 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
19553 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
19554 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
19555 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
19556 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
19557 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
19558 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
19559 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
19560 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
19561 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
19562 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
19563 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
19564 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
19565 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
19566 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
19567 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
19568 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
19569 pdev_param[wmi_pdev_param_peer_stats_update_period] =
19570 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
19571 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
19572 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
19573 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
19574 pdev_param[wmi_pdev_param_arp_ac_override] =
19575 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
19576 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
19577 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
19578 pdev_param[wmi_pdev_param_ani_poll_period] =
19579 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
19580 pdev_param[wmi_pdev_param_ani_listen_period] =
19581 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
19582 pdev_param[wmi_pdev_param_ani_ofdm_level] =
19583 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
19584 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
19585 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
19586 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
19587 pdev_param[wmi_pdev_param_idle_ps_config] =
19588 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
19589 pdev_param[wmi_pdev_param_power_gating_sleep] =
19590 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
19591 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
19592 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
19593 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
19594 pdev_param[wmi_pdev_param_hw_rfkill_config] =
19595 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
19596 pdev_param[wmi_pdev_param_low_power_rf_enable] =
19597 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
19598 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
19599 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
19600 pdev_param[wmi_pdev_param_power_collapse_enable] =
19601 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
19602 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
19603 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
19604 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
19605 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
19606 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
19607 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
19608 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
19609 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
19610 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
19611 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
19612 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
19613 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
19614 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
19615 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
19616 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
19617 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
19618 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
19619 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
19620 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
19621 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
19622 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
19623 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
19624 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
19625 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
19626 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
19627 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
19628 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
19629 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
19630 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
19631 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
19632 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
19633 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
19634 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
19635 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
19636 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
19637 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
19638 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
19639 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
19640 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
19641 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
19642 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
19643 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
19644 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
19645 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019646 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
19647 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
19648 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053019649 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
19650 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019651 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053019652 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053019653 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
19654 pdev_param[wmi_pdev_param_proxy_sta_mode] =
19655 WMI_PDEV_PARAM_PROXY_STA_MODE;
19656 pdev_param[wmi_pdev_param_mu_group_policy] =
19657 WMI_PDEV_PARAM_MU_GROUP_POLICY;
19658 pdev_param[wmi_pdev_param_noise_detection] =
19659 WMI_PDEV_PARAM_NOISE_DETECTION;
19660 pdev_param[wmi_pdev_param_noise_threshold] =
19661 WMI_PDEV_PARAM_NOISE_THRESHOLD;
19662 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
19663 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
19664 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019665 pdev_param[wmi_pdev_param_atf_strict_sch] =
19666 WMI_PDEV_PARAM_ATF_STRICT_SCH;
19667 pdev_param[wmi_pdev_param_atf_sched_duration] =
19668 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019669 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
19670 pdev_param[wmi_pdev_param_sensitivity_level] =
19671 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
19672 pdev_param[wmi_pdev_param_signed_txpower_2g] =
19673 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
19674 pdev_param[wmi_pdev_param_signed_txpower_5g] =
19675 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070019676 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
19677 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
19678 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
19679 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019680 pdev_param[wmi_pdev_param_cca_threshold] =
19681 WMI_PDEV_PARAM_CCA_THRESHOLD;
19682 pdev_param[wmi_pdev_param_rts_fixed_rate] =
19683 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019684 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019685 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
19686 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
19687 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
19688 pdev_param[wmi_pdev_param_arp_srcaddr] =
19689 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
19690 pdev_param[wmi_pdev_param_arp_dstaddr] =
19691 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
19692 pdev_param[wmi_pdev_param_txpower_decr_db] =
19693 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053019694 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
19695 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019696 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
19697 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053019698 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019699 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019700 pdev_param[wmi_pdev_param_cust_txpower_scale] =
19701 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019702 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
19703 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019704 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
19705 WMI_UNAVAILABLE_PARAM;
19706 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
19707 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019708 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
19709 pdev_param[wmi_pdev_param_block_interbss] =
19710 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053019711 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053019712 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
19713 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
19714 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019715 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053019716 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019717 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19718 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053019719 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019720 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19721 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019722 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19723 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19724 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19725 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19726 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19727 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19728 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19729 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19730 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19731 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19732 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19733 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19734 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19735 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19736 pdev_param[wmi_pdev_param_fast_channel_reset] =
19737 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19738 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019739}
19740
19741/**
19742 * populate_vdev_param_tlv() - populates vdev params
19743 *
19744 * @param vdev_param: Pointer to hold vdev params
19745 * Return: None
19746 */
19747static void populate_vdev_param_tlv(uint32_t *vdev_param)
19748{
19749 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19750 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19751 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19752 vdev_param[wmi_vdev_param_beacon_interval] =
19753 WMI_VDEV_PARAM_BEACON_INTERVAL;
19754 vdev_param[wmi_vdev_param_listen_interval] =
19755 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19756 vdev_param[wmi_vdev_param_multicast_rate] =
19757 WMI_VDEV_PARAM_MULTICAST_RATE;
19758 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19759 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19760 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19761 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19762 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19763 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19764 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19765 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19766 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19767 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19768 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19769 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19770 vdev_param[wmi_vdev_param_bmiss_count_max] =
19771 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19772 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19773 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19774 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19775 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19776 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19777 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19778 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19779 vdev_param[wmi_vdev_param_disable_htprotection] =
19780 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19781 vdev_param[wmi_vdev_param_sta_quickkickout] =
19782 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19783 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19784 vdev_param[wmi_vdev_param_protection_mode] =
19785 WMI_VDEV_PARAM_PROTECTION_MODE;
19786 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19787 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19788 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19789 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19790 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19791 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19792 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19793 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19794 vdev_param[wmi_vdev_param_bcast_data_rate] =
19795 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19796 vdev_param[wmi_vdev_param_mcast_data_rate] =
19797 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19798 vdev_param[wmi_vdev_param_mcast_indicate] =
19799 WMI_VDEV_PARAM_MCAST_INDICATE;
19800 vdev_param[wmi_vdev_param_dhcp_indicate] =
19801 WMI_VDEV_PARAM_DHCP_INDICATE;
19802 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19803 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19804 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19805 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19806 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19807 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19808 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19809 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19810 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19811 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19812 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19813 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19814 vdev_param[wmi_vdev_param_packet_powersave] =
19815 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19816 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19817 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19818 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19819 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19820 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19821 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19822 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19823 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19824 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19825 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19826 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19827 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19828 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19829 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19830 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19831 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19832 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19833 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19834 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19835 vdev_param[wmi_vdev_param_roam_fw_offload] =
19836 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19837 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19838 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19839 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19840 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19841 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19842 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19843 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19844 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19845 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19846 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19847 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19848 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19849 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19850 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19851 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19852 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19853 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19854 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19855 vdev_param[wmi_vdev_param_inactivity_cnt] =
19856 WMI_VDEV_PARAM_INACTIVITY_CNT;
19857 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19858 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19859 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19860 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19861 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19862 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19863 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19864 vdev_param[wmi_vdev_param_rx_leak_window] =
19865 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19866 vdev_param[wmi_vdev_param_stats_avg_factor] =
19867 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19868 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19869 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19870 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19871 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19872 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19873 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019874 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19875 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019876 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019877 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19878 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19879 WMI_VDEV_PARAM_HE_RANGE_EXT;
19880 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19881 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019882 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19883 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19884 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19885 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19886 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19887 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19888 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019889 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19890 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19891 vdev_param[wmi_vdev_param_rc_num_retries] =
19892 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19893 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19894 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19895 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19896 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19897 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19898 vdev_param[wmi_vdev_param_vht80_ratemask] =
19899 WMI_VDEV_PARAM_VHT80_RATEMASK;
19900 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19901 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19902 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019903}
19904#endif
19905
Govind Singh5eb51532016-03-09 11:34:12 +053019906/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019907 * populate_target_defines_tlv() - Populate target defines and params
19908 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019909 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019910 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019911 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019912#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019913static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019914{
Govind Singhe7f2f342016-05-23 12:12:52 +053019915 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019916 populate_pdev_param_tlv(wmi_handle->pdev_param);
19917 populate_vdev_param_tlv(wmi_handle->vdev_param);
19918}
19919#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019920static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19921{ }
19922#endif
19923
19924/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019925 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19926 * host to target defines.
19927 * @param pdev_id: host pdev_id to be converted.
19928 * Return: target pdev_id after conversion.
19929 */
19930static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19931{
19932 switch (pdev_id) {
19933 case WMI_HOST_PDEV_ID_SOC:
19934 return WMI_PDEV_ID_SOC;
19935 case WMI_HOST_PDEV_ID_0:
19936 return WMI_PDEV_ID_1ST;
19937 case WMI_HOST_PDEV_ID_1:
19938 return WMI_PDEV_ID_2ND;
19939 case WMI_HOST_PDEV_ID_2:
19940 return WMI_PDEV_ID_3RD;
19941 }
19942
19943 QDF_ASSERT(0);
19944
19945 return WMI_PDEV_ID_SOC;
19946}
19947
19948/**
19949 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19950 * target to host defines.
19951 * @param pdev_id: target pdev_id to be converted.
19952 * Return: host pdev_id after conversion.
19953 */
19954static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19955{
19956 switch (pdev_id) {
19957 case WMI_PDEV_ID_SOC:
19958 return WMI_HOST_PDEV_ID_SOC;
19959 case WMI_PDEV_ID_1ST:
19960 return WMI_HOST_PDEV_ID_0;
19961 case WMI_PDEV_ID_2ND:
19962 return WMI_HOST_PDEV_ID_1;
19963 case WMI_PDEV_ID_3RD:
19964 return WMI_HOST_PDEV_ID_2;
19965 }
19966
19967 QDF_ASSERT(0);
19968
19969 return WMI_HOST_PDEV_ID_SOC;
19970}
19971
19972/**
19973 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19974 *
19975 * Return None.
19976 */
19977void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19978{
19979 wmi_handle->ops->convert_pdev_id_host_to_target =
19980 convert_host_pdev_id_to_target_pdev_id;
19981 wmi_handle->ops->convert_pdev_id_target_to_host =
19982 convert_target_pdev_id_to_host_pdev_id;
19983}
19984/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019985 * wmi_tlv_attach() - Attach TLV APIs
19986 *
19987 * Return: None
19988 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019989void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019990{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019991 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019992#ifdef WMI_INTERFACE_EVENT_LOGGING
19993 wmi_handle->log_info.buf_offset_command = 2;
19994 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019995#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019996 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019997 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019998}