blob: 82090a452144d06c6883c52740e480c496f87ed4 [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
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530367 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 cmd->preferred_rx_streams = req->preferred_rx_streams;
369 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700370 cmd->cac_duration_ms = req->cac_duration_ms;
371 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700372 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530373
374 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
375 sizeof(wmi_channel));
376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
377 cmd->num_noa_descriptors *
378 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800379 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
381 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700382 "Tx SS %d, Rx SS %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800383 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530384 req->is_dfs, req->beacon_intval, cmd->dtim_period,
385 chan->band_center_freq1, chan->band_center_freq2,
386 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700387 req->preferred_tx_streams, req->preferred_rx_streams,
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700388 req->cac_duration_ms, req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530390 if (req->is_restart)
391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
392 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530393 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
395 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530396 if (ret) {
397 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530398 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530399 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530400 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401
402 return QDF_STATUS_SUCCESS;
403}
404
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530405/**
406 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
407 * @wmi_handle: wmi handle
408 * @restart_params: vdev restart params
409 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530410 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530411 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530412static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 struct hidden_ssid_vdev_restart_params *restart_params)
414{
415 wmi_vdev_start_request_cmd_fixed_param *cmd;
416 wmi_buf_t buf;
417 wmi_channel *chan;
418 int32_t len;
419 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530420 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421
422 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
423 buf = wmi_buf_alloc(wmi_handle, len);
424 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530425 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 return QDF_STATUS_E_NOMEM;
427 }
428 buf_ptr = (uint8_t *) wmi_buf_data(buf);
429 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
430 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
431
432 WMITLV_SET_HDR(&cmd->tlv_header,
433 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
434 WMITLV_GET_STRUCT_TLVLEN
435 (wmi_vdev_start_request_cmd_fixed_param));
436
437 WMITLV_SET_HDR(&chan->tlv_header,
438 WMITLV_TAG_STRUC_wmi_channel,
439 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
440
441 cmd->vdev_id = restart_params->session_id;
442 cmd->ssid.ssid_len = restart_params->ssid_len;
443 qdf_mem_copy(cmd->ssid.ssid,
444 restart_params->ssid,
445 cmd->ssid.ssid_len);
446 cmd->flags = restart_params->flags;
447 cmd->requestor_id = restart_params->requestor_id;
448 cmd->disable_hw_ack = restart_params->disable_hw_ack;
449
450 chan->mhz = restart_params->mhz;
451 chan->band_center_freq1 =
452 restart_params->band_center_freq1;
453 chan->band_center_freq2 =
454 restart_params->band_center_freq2;
455 chan->info = restart_params->info;
456 chan->reg_info_1 = restart_params->reg_info_1;
457 chan->reg_info_2 = restart_params->reg_info_2;
458
459 cmd->num_noa_descriptors = 0;
460 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
461 sizeof(wmi_channel));
462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
463 cmd->num_noa_descriptors *
464 sizeof(wmi_p2p_noa_descriptor));
465
466 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
467 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530468 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530469 wmi_buf_free(buf);
470 return QDF_STATUS_E_FAILURE;
471 }
472 return QDF_STATUS_SUCCESS;
473}
474
475
476/**
Govind Singh5eb51532016-03-09 11:34:12 +0530477 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
478 * @wmi: wmi handle
479 * @peer_addr: peer mac address
480 * @param: pointer to hold peer flush tid parameter
481 *
482 * Return: 0 for sucess or error code
483 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530484static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530485 uint8_t peer_addr[IEEE80211_ADDR_LEN],
486 struct peer_flush_params *param)
487{
488 wmi_peer_flush_tids_cmd_fixed_param *cmd;
489 wmi_buf_t buf;
490 int32_t len = sizeof(*cmd);
491
492 buf = wmi_buf_alloc(wmi, len);
493 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530494 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530495 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530496 }
497 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
498 WMITLV_SET_HDR(&cmd->tlv_header,
499 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
500 WMITLV_GET_STRUCT_TLVLEN
501 (wmi_peer_flush_tids_cmd_fixed_param));
502 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
503 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
504 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530505 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530506 peer_addr, param->vdev_id,
507 param->peer_tid_bitmap);
508 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530509 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530510 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530511 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530512 }
513
514 return 0;
515}
516
517/**
518 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
519 * @wmi: wmi handle
520 * @peer_addr: peer mac addr
521 * @vdev_id: vdev id
522 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530523 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530524 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530525static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530526 uint8_t peer_addr[IEEE80211_ADDR_LEN],
527 uint8_t vdev_id)
528{
529 wmi_peer_delete_cmd_fixed_param *cmd;
530 wmi_buf_t buf;
531 int32_t len = sizeof(*cmd);
532 buf = wmi_buf_alloc(wmi, len);
533 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530534 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530535 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530536 }
537 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
538 WMITLV_SET_HDR(&cmd->tlv_header,
539 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
540 WMITLV_GET_STRUCT_TLVLEN
541 (wmi_peer_delete_cmd_fixed_param));
542 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
543 cmd->vdev_id = vdev_id;
544
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800545 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530546 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530547 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530548 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530549 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530550 }
Govind Singh5eb51532016-03-09 11:34:12 +0530551
552 return 0;
553}
554
555/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530556 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
557 * to target id.
558 * @targ_paramid: Target parameter id to hold the result.
559 * @peer_param_id: host param id.
560 *
561 * Return: QDF_STATUS_SUCCESS for success
562 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
563 */
564#ifdef CONFIG_MCL
565static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
566 uint32_t *targ_paramid,
567 uint32_t peer_param_id)
568{
569 *targ_paramid = peer_param_id;
570 return QDF_STATUS_SUCCESS;
571}
572#else
573static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
574 uint32_t *targ_paramid,
575 uint32_t peer_param_id)
576{
577 switch (peer_param_id) {
578 case WMI_HOST_PEER_MIMO_PS_STATE:
579 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
580 break;
581 case WMI_HOST_PEER_AMPDU:
582 *targ_paramid = WMI_PEER_AMPDU;
583 break;
584 case WMI_HOST_PEER_AUTHORIZE:
585 *targ_paramid = WMI_PEER_AUTHORIZE;
586 break;
587 case WMI_HOST_PEER_CHWIDTH:
588 *targ_paramid = WMI_PEER_CHWIDTH;
589 break;
590 case WMI_HOST_PEER_NSS:
591 *targ_paramid = WMI_PEER_NSS;
592 break;
593 case WMI_HOST_PEER_USE_4ADDR:
594 *targ_paramid = WMI_PEER_USE_4ADDR;
595 break;
596 case WMI_HOST_PEER_MEMBERSHIP:
597 *targ_paramid = WMI_PEER_MEMBERSHIP;
598 break;
599 case WMI_HOST_PEER_USERPOS:
600 *targ_paramid = WMI_PEER_USERPOS;
601 break;
602 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
603 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
604 break;
605 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
606 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
607 break;
608 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
609 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
610 break;
611 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
612 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
613 break;
614 case WMI_HOST_PEER_PHYMODE:
615 *targ_paramid = WMI_PEER_PHYMODE;
616 break;
617 case WMI_HOST_PEER_USE_FIXED_PWR:
618 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
619 break;
620 case WMI_HOST_PEER_PARAM_FIXED_RATE:
621 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
622 break;
623 case WMI_HOST_PEER_SET_MU_WHITELIST:
624 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
625 break;
626 case WMI_HOST_PEER_SET_MAC_TX_RATE:
627 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
628 break;
629 case WMI_HOST_PEER_SET_MIN_TX_RATE:
630 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
631 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530632 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
633 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
634 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530635 default:
636 return QDF_STATUS_E_NOSUPPORT;
637 }
638
639 return QDF_STATUS_SUCCESS;
640}
641#endif
642/**
Govind Singh5eb51532016-03-09 11:34:12 +0530643 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530644 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530645 * @peer_addr: peer mac address
646 * @param : pointer to hold peer set parameter
647 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530648 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530649 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530650static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530651 uint8_t peer_addr[IEEE80211_ADDR_LEN],
652 struct peer_set_params *param)
653{
654 wmi_peer_set_param_cmd_fixed_param *cmd;
655 wmi_buf_t buf;
656 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530657 uint32_t param_id;
658
659 if (convert_host_peer_id_to_target_id_tlv(&param_id,
660 param->param_id) != QDF_STATUS_SUCCESS)
661 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530662
663 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530665 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530666 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530667 }
668 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
669 WMITLV_SET_HDR(&cmd->tlv_header,
670 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
671 WMITLV_GET_STRUCT_TLVLEN
672 (wmi_peer_set_param_cmd_fixed_param));
673 cmd->vdev_id = param->vdev_id;
674 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530675 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530676 cmd->param_value = param->param_value;
677 err = wmi_unified_cmd_send(wmi, buf,
678 sizeof(wmi_peer_set_param_cmd_fixed_param),
679 WMI_PEER_SET_PARAM_CMDID);
680 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530681 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530682 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530683 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530684 }
685
686 return 0;
687}
688
689/**
690 * send_vdev_up_cmd_tlv() - send vdev up command in fw
691 * @wmi: wmi handle
692 * @bssid: bssid
693 * @vdev_up_params: pointer to hold vdev up parameter
694 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530695 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530696 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530697static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530698 uint8_t bssid[IEEE80211_ADDR_LEN],
699 struct vdev_up_params *params)
700{
701 wmi_vdev_up_cmd_fixed_param *cmd;
702 wmi_buf_t buf;
703 int32_t len = sizeof(*cmd);
704
Govind Singhb53420c2016-03-09 14:32:57 +0530705 WMI_LOGD("%s: VDEV_UP", __func__);
706 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530707 params->vdev_id, params->assoc_id, bssid);
708 buf = wmi_buf_alloc(wmi, len);
709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530710 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530711 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530712 }
713 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
714 WMITLV_SET_HDR(&cmd->tlv_header,
715 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
716 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
717 cmd->vdev_id = params->vdev_id;
718 cmd->vdev_assoc_id = params->assoc_id;
719 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
720 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530721 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530722 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530723 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530724 }
725
726 return 0;
727}
728
729/**
730 * send_peer_create_cmd_tlv() - send peer create command to fw
731 * @wmi: wmi handle
732 * @peer_addr: peer mac address
733 * @peer_type: peer type
734 * @vdev_id: vdev id
735 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530736 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530737 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530738static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530739 struct peer_create_params *param)
740{
741 wmi_peer_create_cmd_fixed_param *cmd;
742 wmi_buf_t buf;
743 int32_t len = sizeof(*cmd);
744
745 buf = wmi_buf_alloc(wmi, len);
746 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530747 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530748 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530749 }
750 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
751 WMITLV_SET_HDR(&cmd->tlv_header,
752 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
753 WMITLV_GET_STRUCT_TLVLEN
754 (wmi_peer_create_cmd_fixed_param));
755 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
756 cmd->peer_type = param->peer_type;
757 cmd->vdev_id = param->vdev_id;
758
759 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530760 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530761 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530762 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530763 }
Govind Singhb53420c2016-03-09 14:32:57 +0530764 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530765 param->vdev_id);
766
767 return 0;
768}
769
770/**
Leo Changeee40872016-09-28 13:43:36 -0700771 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
772 * command to fw
773 * @wmi: wmi handle
774 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
775 *
776 * Return: 0 for success or error code
777 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700778static
Leo Changeee40872016-09-28 13:43:36 -0700779QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
780 struct rx_reorder_queue_setup_params *param)
781{
782 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
783 wmi_buf_t buf;
784 int32_t len = sizeof(*cmd);
785
786 buf = wmi_buf_alloc(wmi, len);
787 if (!buf) {
788 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
789 return QDF_STATUS_E_NOMEM;
790 }
791 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
792 WMITLV_SET_HDR(&cmd->tlv_header,
793 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
794 WMITLV_GET_STRUCT_TLVLEN
795 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
796 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
797 cmd->vdev_id = param->vdev_id;
798 cmd->tid = param->tid;
799 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
800 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
801 cmd->queue_no = param->queue_no;
802
803 if (wmi_unified_cmd_send(wmi, buf, len,
804 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
805 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
806 __func__);
807 qdf_nbuf_free(buf);
808 return QDF_STATUS_E_FAILURE;
809 }
810 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
811 param->peer_macaddr, param->vdev_id, param->tid);
812
813 return QDF_STATUS_SUCCESS;
814}
815
816/**
817 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
818 * command to fw
819 * @wmi: wmi handle
820 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
821 *
822 * Return: 0 for success or error code
823 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700824static
Leo Changeee40872016-09-28 13:43:36 -0700825QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
826 struct rx_reorder_queue_remove_params *param)
827{
828 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
829 wmi_buf_t buf;
830 int32_t len = sizeof(*cmd);
831
832 buf = wmi_buf_alloc(wmi, len);
833 if (!buf) {
834 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
835 return QDF_STATUS_E_NOMEM;
836 }
837 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
838 wmi_buf_data(buf);
839 WMITLV_SET_HDR(&cmd->tlv_header,
840 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
841 WMITLV_GET_STRUCT_TLVLEN
842 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
843 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
844 cmd->vdev_id = param->vdev_id;
845 cmd->tid_mask = param->peer_tid_bitmap;
846
847 if (wmi_unified_cmd_send(wmi, buf, len,
848 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
849 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
850 __func__);
851 qdf_nbuf_free(buf);
852 return QDF_STATUS_E_FAILURE;
853 }
854 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
855 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
856
857 return QDF_STATUS_SUCCESS;
858}
859
860/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530861 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
862 * @wmi_handle: wmi handle
863 * @param: pointer holding peer details
864 *
865 * Return: 0 for success or error code
866 */
867static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
868 struct peer_add_wds_entry_params *param)
869{
870 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
871 wmi_buf_t buf;
872 int len = sizeof(*cmd);
873
874 buf = wmi_buf_alloc(wmi_handle, len);
875 if (!buf) {
876 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
877 return QDF_STATUS_E_FAILURE;
878 }
879 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
880 WMITLV_SET_HDR(&cmd->tlv_header,
881 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
882 WMITLV_GET_STRUCT_TLVLEN
883 (wmi_peer_add_wds_entry_cmd_fixed_param));
884 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
885 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
886 cmd->flags = param->flags;
887
888 return wmi_unified_cmd_send(wmi_handle, buf, len,
889 WMI_PEER_ADD_WDS_ENTRY_CMDID);
890}
891
892/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530893 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530894 * @wmi_handle: wmi handle
895 * @param: pointer holding peer details
896 *
897 * Return: 0 for success or error code
898 */
899static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
900 struct peer_del_wds_entry_params *param)
901{
902 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
903 wmi_buf_t buf;
904 int len = sizeof(*cmd);
905
906 buf = wmi_buf_alloc(wmi_handle, len);
907 if (!buf) {
908 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
909 return QDF_STATUS_E_NOMEM;
910 }
911 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
912 WMITLV_SET_HDR(&cmd->tlv_header,
913 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
914 WMITLV_GET_STRUCT_TLVLEN
915 (wmi_peer_remove_wds_entry_cmd_fixed_param));
916 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
917 return wmi_unified_cmd_send(wmi_handle, buf, len,
918 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
919}
920
921/**
922 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
923 * @wmi_handle: wmi handle
924 * @param: pointer holding peer details
925 *
926 * Return: 0 for success or error code
927 */
928static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
929 struct peer_update_wds_entry_params *param)
930{
931 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
932 wmi_buf_t buf;
933 int len = sizeof(*cmd);
934
935 buf = wmi_buf_alloc(wmi_handle, len);
936 if (!buf) {
937 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
938 return QDF_STATUS_E_NOMEM;
939 }
940
941 /* wmi_buf_alloc returns zeroed command buffer */
942 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
943 WMITLV_SET_HDR(&cmd->tlv_header,
944 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
945 WMITLV_GET_STRUCT_TLVLEN
946 (wmi_peer_update_wds_entry_cmd_fixed_param));
947 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
948 if (param->wds_macaddr)
949 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
950 &cmd->wds_macaddr);
951 if (param->peer_macaddr)
952 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
953 &cmd->peer_macaddr);
954 return wmi_unified_cmd_send(wmi_handle, buf, len,
955 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
956}
957
958
959
960/**
Govind Singh5eb51532016-03-09 11:34:12 +0530961 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
962 * @wmi_handle: wmi handle
963 * @value: value
964 * @mac_id: mac id to have radio context
965 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530966 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530967 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530968static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530969 uint32_t value, uint8_t mac_id)
970{
971 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
972 wmi_buf_t buf;
973 int32_t len = sizeof(*cmd);
974
Govind Singhb53420c2016-03-09 14:32:57 +0530975 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530976
977 buf = wmi_buf_alloc(wmi_handle, len);
978 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530979 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530980 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530981 }
982
983 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
984 WMITLV_SET_HDR(&cmd->tlv_header,
985 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
986 WMITLV_GET_STRUCT_TLVLEN
987 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530988 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530989 cmd->enable = value;
990
991 if (wmi_unified_cmd_send(wmi_handle, buf, len,
992 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530993 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530994 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530995 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530996 }
997
998 return 0;
999}
1000
1001/**
1002 * send_pdev_utf_cmd_tlv() - send utf command to fw
1003 * @wmi_handle: wmi handle
1004 * @param: pointer to pdev_utf_params
1005 * @mac_id: mac id to have radio context
1006 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301007 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301008 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301009static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301010send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1011 struct pdev_utf_params *param,
1012 uint8_t mac_id)
1013{
1014 wmi_buf_t buf;
1015 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001016 /* if param->len is 0 no data is sent, return error */
1017 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301018 static uint8_t msgref = 1;
1019 uint8_t segNumber = 0, segInfo, numSegments;
1020 uint16_t chunk_len, total_bytes;
1021 uint8_t *bufpos;
1022 struct seg_hdr_info segHdrInfo;
1023
1024 bufpos = param->utf_payload;
1025 total_bytes = param->len;
1026 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1027 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1028 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1029
1030 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1031 numSegments++;
1032
1033 while (param->len) {
1034 if (param->len > MAX_WMI_UTF_LEN)
1035 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1036 else
1037 chunk_len = param->len;
1038
1039 buf = wmi_buf_alloc(wmi_handle,
1040 (chunk_len + sizeof(segHdrInfo) +
1041 WMI_TLV_HDR_SIZE));
1042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301043 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301044 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301045 }
1046
1047 cmd = (uint8_t *) wmi_buf_data(buf);
1048
1049 segHdrInfo.len = total_bytes;
1050 segHdrInfo.msgref = msgref;
1051 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1052 segHdrInfo.segmentInfo = segInfo;
1053 segHdrInfo.pad = 0;
1054
Govind Singhb53420c2016-03-09 14:32:57 +05301055 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301056 " segHdrInfo.segmentInfo = %d",
1057 __func__, segHdrInfo.len, segHdrInfo.msgref,
1058 segHdrInfo.segmentInfo);
1059
Govind Singhb53420c2016-03-09 14:32:57 +05301060 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301061 "chunk len %d", __func__, total_bytes, segNumber,
1062 numSegments, chunk_len);
1063
1064 segNumber++;
1065
1066 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1067 (chunk_len + sizeof(segHdrInfo)));
1068 cmd += WMI_TLV_HDR_SIZE;
1069 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1070 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1071
1072 ret = wmi_unified_cmd_send(wmi_handle, buf,
1073 (chunk_len + sizeof(segHdrInfo) +
1074 WMI_TLV_HDR_SIZE),
1075 WMI_PDEV_UTF_CMDID);
1076
Govind Singh67922e82016-04-01 16:48:57 +05301077 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301078 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301079 wmi_buf_free(buf);
1080 break;
1081 }
1082
1083 param->len -= chunk_len;
1084 bufpos += chunk_len;
1085 }
1086
1087 msgref++;
1088
1089 return ret;
1090}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301091#ifdef CONFIG_MCL
1092static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1093 uint32_t host_param)
1094{
1095 return host_param;
1096}
1097#else
1098static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1099 uint32_t host_param)
1100{
1101 if (host_param < wmi_pdev_param_max)
1102 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301103
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301104 return WMI_UNAVAILABLE_PARAM;
1105}
1106#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301107/**
1108 * send_pdev_param_cmd_tlv() - set pdev parameters
1109 * @wmi_handle: wmi handle
1110 * @param: pointer to pdev parameter
1111 * @mac_id: radio context
1112 *
1113 * Return: 0 on success, errno on failure
1114 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301115static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301116send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1117 struct pdev_params *param,
1118 uint8_t mac_id)
1119{
Govind Singh67922e82016-04-01 16:48:57 +05301120 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301121 wmi_pdev_set_param_cmd_fixed_param *cmd;
1122 wmi_buf_t buf;
1123 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301124 uint32_t pdev_param;
1125
1126 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1127 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1128 WMI_LOGW("%s: Unavailable param %d\n",
1129 __func__, param->param_id);
1130 return QDF_STATUS_E_INVAL;
1131 }
Govind Singh5eb51532016-03-09 11:34:12 +05301132
1133 buf = wmi_buf_alloc(wmi_handle, len);
1134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301135 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301136 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301137 }
1138 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1139 WMITLV_SET_HDR(&cmd->tlv_header,
1140 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1141 WMITLV_GET_STRUCT_TLVLEN
1142 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301143 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301144 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301145 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301146 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301147 param->param_value);
1148 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1149 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301150 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301151 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301152 wmi_buf_free(buf);
1153 }
1154 return ret;
1155}
1156
1157/**
1158 * send_suspend_cmd_tlv() - WMI suspend function
1159 * @param wmi_handle : handle to WMI.
1160 * @param param : pointer to hold suspend parameter
1161 * @mac_id: radio context
1162 *
1163 * Return 0 on success and -ve on failure.
1164 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301165static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301166 struct suspend_params *param,
1167 uint8_t mac_id)
1168{
1169 wmi_pdev_suspend_cmd_fixed_param *cmd;
1170 wmi_buf_t wmibuf;
1171 uint32_t len = sizeof(*cmd);
1172 int32_t ret;
1173
1174 /*
1175 * send the comand to Target to ignore the
1176 * PCIE reset so as to ensure that Host and target
1177 * states are in sync
1178 */
1179 wmibuf = wmi_buf_alloc(wmi_handle, len);
1180 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301181 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301182
1183 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1184 WMITLV_SET_HDR(&cmd->tlv_header,
1185 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1186 WMITLV_GET_STRUCT_TLVLEN
1187 (wmi_pdev_suspend_cmd_fixed_param));
1188 if (param->disable_target_intr)
1189 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1190 else
1191 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301192
1193 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1194
Govind Singh5eb51532016-03-09 11:34:12 +05301195 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1196 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301197 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301198 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301199 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301200 }
1201
1202 return ret;
1203}
1204
1205/**
1206 * send_resume_cmd_tlv() - WMI resume function
1207 * @param wmi_handle : handle to WMI.
1208 * @mac_id: radio context
1209 *
1210 * Return: 0 on success and -ve on failure.
1211 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301212static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301213 uint8_t mac_id)
1214{
1215 wmi_buf_t wmibuf;
1216 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301217 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301218
1219 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1220 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301221 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301222 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1223 WMITLV_SET_HDR(&cmd->tlv_header,
1224 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1225 WMITLV_GET_STRUCT_TLVLEN
1226 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301227 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301228 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1229 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301231 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301232 wmi_buf_free(wmibuf);
1233 }
1234
1235 return ret;
1236}
1237
1238/**
1239 * send_wow_enable_cmd_tlv() - WMI wow enable function
1240 * @param wmi_handle : handle to WMI.
1241 * @param param : pointer to hold wow enable parameter
1242 * @mac_id: radio context
1243 *
1244 * Return: 0 on success and -ve on failure.
1245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301246static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301247 struct wow_cmd_params *param,
1248 uint8_t mac_id)
1249{
1250 wmi_wow_enable_cmd_fixed_param *cmd;
1251 wmi_buf_t buf;
1252 int32_t len;
1253 int32_t ret;
1254
1255 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1256
1257 buf = wmi_buf_alloc(wmi_handle, len);
1258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301259 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1260 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301261 }
1262 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1263 WMITLV_SET_HDR(&cmd->tlv_header,
1264 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1265 WMITLV_GET_STRUCT_TLVLEN
1266 (wmi_wow_enable_cmd_fixed_param));
1267 cmd->enable = param->enable;
1268 if (param->can_suspend_link)
1269 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1270 else
1271 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001272 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301273
Govind Singhb53420c2016-03-09 14:32:57 +05301274 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301275 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1276 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1277
1278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1279 WMI_WOW_ENABLE_CMDID);
1280 if (ret)
1281 wmi_buf_free(buf);
1282
1283 return ret;
1284}
1285
1286/**
1287 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301288 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301289 * @peer_addr: peer mac address
1290 * @param: pointer to ap_ps parameter structure
1291 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301292 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301293 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301294static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301295 uint8_t *peer_addr,
1296 struct ap_ps_params *param)
1297{
1298 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1299 wmi_buf_t buf;
1300 int32_t err;
1301
1302 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301304 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301305 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301306 }
1307 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1308 WMITLV_SET_HDR(&cmd->tlv_header,
1309 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1310 WMITLV_GET_STRUCT_TLVLEN
1311 (wmi_ap_ps_peer_cmd_fixed_param));
1312 cmd->vdev_id = param->vdev_id;
1313 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1314 cmd->param = param->param;
1315 cmd->value = param->value;
1316 err = wmi_unified_cmd_send(wmi_handle, buf,
1317 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1318 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301319 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301320 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301321 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301322 }
1323
1324 return 0;
1325}
1326
1327/**
1328 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301329 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301330 * @peer_addr: peer mac address
1331 * @param: pointer to sta_ps parameter structure
1332 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301333 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301334 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301335static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301336 struct sta_ps_params *param)
1337{
1338 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1339 wmi_buf_t buf;
1340 int32_t len = sizeof(*cmd);
1341
1342 buf = wmi_buf_alloc(wmi_handle, len);
1343 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301344 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301345 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301346 }
1347
1348 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1349 WMITLV_SET_HDR(&cmd->tlv_header,
1350 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1351 WMITLV_GET_STRUCT_TLVLEN
1352 (wmi_sta_powersave_param_cmd_fixed_param));
1353 cmd->vdev_id = param->vdev_id;
1354 cmd->param = param->param;
1355 cmd->value = param->value;
1356
1357 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1358 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301359 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301360 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301361 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301362 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301363 }
1364
1365 return 0;
1366}
1367
1368/**
1369 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301370 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301371 * @param: ponirt to crash inject paramter structure
1372 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301373 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301375static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301376 struct crash_inject *param)
1377{
1378 int32_t ret = 0;
1379 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1380 uint16_t len = sizeof(*cmd);
1381 wmi_buf_t buf;
1382
1383 buf = wmi_buf_alloc(wmi_handle, len);
1384 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301385 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301386 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301387 }
1388
1389 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1390 WMITLV_SET_HDR(&cmd->tlv_header,
1391 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1392 WMITLV_GET_STRUCT_TLVLEN
1393 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1394 cmd->type = param->type;
1395 cmd->delay_time_ms = param->delay_time_ms;
1396
1397 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1398 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301399 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301400 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301401 __func__, ret);
1402 wmi_buf_free(buf);
1403 }
1404
1405 return ret;
1406}
1407
1408/**
1409 * send_dbglog_cmd_tlv() - set debug log level
1410 * @param wmi_handle : handle to WMI.
1411 * @param param : pointer to hold dbglog level parameter
1412 *
1413 * Return: 0 on success and -ve on failure.
1414 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301415 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301416send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1417 struct dbglog_params *dbglog_param)
1418{
1419 wmi_buf_t buf;
1420 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001421 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301422 int32_t i;
1423 int32_t len;
1424 int8_t *buf_ptr;
1425 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1426
1427 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1428
1429 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1430 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1431 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1432 buf = wmi_buf_alloc(wmi_handle, len);
1433 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001434 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301435
1436 configmsg =
1437 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1438 buf_ptr = (int8_t *) configmsg;
1439 WMITLV_SET_HDR(&configmsg->tlv_header,
1440 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1441 WMITLV_GET_STRUCT_TLVLEN
1442 (wmi_debug_log_config_cmd_fixed_param));
1443 configmsg->dbg_log_param = dbglog_param->param;
1444 configmsg->value = dbglog_param->val;
1445 /* Filling in the data part of second tlv -- should
1446 * follow first tlv _ WMI_TLV_HDR_SIZE */
1447 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1448 sizeof
1449 (wmi_debug_log_config_cmd_fixed_param)
1450 + WMI_TLV_HDR_SIZE);
1451 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1452 WMITLV_TAG_ARRAY_UINT32,
1453 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1454 if (dbglog_param->module_id_bitmap) {
1455 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1456 module_id_bitmap_array[i] =
1457 dbglog_param->module_id_bitmap[i];
1458 }
1459 }
1460
1461 status = wmi_unified_cmd_send(wmi_handle, buf,
1462 len, WMI_DBGLOG_CFG_CMDID);
1463
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001464 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301465 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301466
1467 return status;
1468}
1469
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301470#ifdef CONFIG_MCL
1471static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1472 uint32_t host_param)
1473{
1474 return host_param;
1475}
1476#else
1477static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1478 uint32_t host_param)
1479{
1480 if (host_param < wmi_vdev_param_max)
1481 return wmi_handle->vdev_param[host_param];
1482
1483 return WMI_UNAVAILABLE_PARAM;
1484}
1485#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301486/**
1487 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1488 * @param wmi_handle : handle to WMI.
1489 * @param macaddr : MAC address
1490 * @param param : pointer to hold vdev set parameter
1491 *
1492 * Return: 0 on success and -ve on failure.
1493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301494static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301495 struct vdev_set_params *param)
1496{
Govind Singh67922e82016-04-01 16:48:57 +05301497 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301498 wmi_vdev_set_param_cmd_fixed_param *cmd;
1499 wmi_buf_t buf;
1500 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301501 uint32_t vdev_param;
1502
1503 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1504 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1505 WMI_LOGW("%s:Vdev param %d not available", __func__,
1506 param->param_id);
1507 return QDF_STATUS_E_INVAL;
1508
1509 }
Govind Singh5eb51532016-03-09 11:34:12 +05301510
1511 buf = wmi_buf_alloc(wmi_handle, len);
1512 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301513 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301514 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301515 }
1516 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1517 WMITLV_SET_HDR(&cmd->tlv_header,
1518 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1519 WMITLV_GET_STRUCT_TLVLEN
1520 (wmi_vdev_set_param_cmd_fixed_param));
1521 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301522 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301523 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301524 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301525 param->if_id, param->param_id, param->param_value);
1526 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1527 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301528 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301529 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301530 wmi_buf_free(buf);
1531 }
1532
1533 return ret;
1534}
1535
1536/**
1537 * send_stats_request_cmd_tlv() - WMI request stats function
1538 * @param wmi_handle : handle to WMI.
1539 * @param macaddr : MAC address
1540 * @param param : pointer to hold stats request parameter
1541 *
1542 * Return: 0 on success and -ve on failure.
1543 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301544static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301545 uint8_t macaddr[IEEE80211_ADDR_LEN],
1546 struct stats_request_params *param)
1547{
Govind Singhd3156eb2016-02-26 17:50:39 +05301548 int32_t ret;
1549 wmi_request_stats_cmd_fixed_param *cmd;
1550 wmi_buf_t buf;
1551 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1552
1553 buf = wmi_buf_alloc(wmi_handle, len);
1554 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301555 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1556 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301557 }
1558
1559 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1560 WMITLV_SET_HDR(&cmd->tlv_header,
1561 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1562 WMITLV_GET_STRUCT_TLVLEN
1563 (wmi_request_stats_cmd_fixed_param));
1564 cmd->stats_id = param->stats_id;
1565 cmd->vdev_id = param->vdev_id;
1566 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1567 WMI_REQUEST_STATS_CMDID);
1568 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301569 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301570 wmi_buf_free(buf);
1571 }
1572
1573 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301574}
1575
Govind Singh87542482016-06-08 19:40:11 +05301576#ifdef CONFIG_WIN
1577/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001578 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301579 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001580 * @param PKTLOG_EVENT : packet log event
1581 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301582 *
1583 * Return: 0 on success and -ve on failure.
1584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301585static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001586 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301587{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001588 int32_t ret;
1589 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1590 wmi_buf_t buf;
1591 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1592
1593 buf = wmi_buf_alloc(wmi_handle, len);
1594 if (!buf) {
1595 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1596 return -QDF_STATUS_E_NOMEM;
1597 }
1598
1599 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1600 WMITLV_SET_HDR(&cmd->tlv_header,
1601 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1602 WMITLV_GET_STRUCT_TLVLEN
1603 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1604 cmd->evlist = PKTLOG_EVENT;
1605 cmd->pdev_id = mac_id;
1606 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1607 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1608 if (ret) {
1609 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1610 wmi_buf_free(buf);
1611 }
1612
1613 return ret;
1614}
1615
1616/**
1617 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1618 * @param wmi_handle : handle to WMI.
1619 * @mac_id: mac id to have radio context
1620 *
1621 * Return: 0 on success and -ve on failure.
1622 */
1623static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1624 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
1625{
1626 int32_t ret;
1627 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1628 wmi_buf_t buf;
1629 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1630
1631 buf = wmi_buf_alloc(wmi_handle, len);
1632 if (!buf) {
1633 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1634 return -QDF_STATUS_E_NOMEM;
1635 }
1636
1637 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1638 WMITLV_SET_HDR(&cmd->tlv_header,
1639 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1640 WMITLV_GET_STRUCT_TLVLEN
1641 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1642 cmd->pdev_id = mac_id;
1643 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1644 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1645 if (ret) {
1646 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1647 wmi_buf_free(buf);
1648 }
1649
1650 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301651}
1652#else
Govind Singh5eb51532016-03-09 11:34:12 +05301653/**
1654 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1655 * @param wmi_handle : handle to WMI.
1656 * @param macaddr : MAC address
1657 * @param param : pointer to hold stats request parameter
1658 *
1659 * Return: 0 on success and -ve on failure.
1660 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301661static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301662 uint8_t macaddr[IEEE80211_ADDR_LEN],
1663 struct packet_enable_params *param)
1664{
1665 return 0;
1666}
Govind Singh87542482016-06-08 19:40:11 +05301667#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301668
Sathish Kumarfd347372017-02-13 12:29:09 +05301669static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301670 struct beacon_params *param)
1671{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301672 QDF_STATUS ret;
1673 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1674 wmi_buf_t wmi_buf;
1675 qdf_dma_addr_t dma_addr;
1676 uint32_t dtim_flag = 0;
1677
1678 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1679 if (!wmi_buf) {
1680 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1681 return QDF_STATUS_E_NOMEM;
1682 }
1683 if (param->is_dtim_count_zero) {
1684 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1685 if (param->is_bitctl_reqd) {
1686 /* deliver CAB traffic in next DTIM beacon */
1687 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1688 }
1689 }
1690 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1691 WMITLV_SET_HDR(&cmd->tlv_header,
1692 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1693 WMITLV_GET_STRUCT_TLVLEN
1694 (wmi_bcn_send_from_host_cmd_fixed_param));
1695 cmd->vdev_id = param->vdev_id;
1696 cmd->data_len = qdf_nbuf_len(param->wbuf);
1697 cmd->frame_ctrl = param->frame_ctrl;
1698 cmd->dtim_flag = dtim_flag;
1699 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1700 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1701#if defined(HTT_PADDR64)
1702 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1703#endif
1704 cmd->bcn_antenna = param->bcn_txant;
1705
1706 ret = wmi_unified_cmd_send(wmi_handle,
1707 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1708 if (ret != QDF_STATUS_SUCCESS) {
1709 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1710 wmi_buf_free(wmi_buf);
1711 }
1712
1713 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301714}
1715
1716/**
1717 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1718 * @param wmi_handle : handle to WMI.
1719 * @param param : pointer to hold beacon send cmd parameter
1720 *
1721 * Return: 0 on success and -ve on failure.
1722 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301723static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301724 struct beacon_tmpl_params *param)
1725{
1726 int32_t ret;
1727 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1728 wmi_bcn_prb_info *bcn_prb_info;
1729 wmi_buf_t wmi_buf;
1730 uint8_t *buf_ptr;
1731 uint32_t wmi_buf_len;
1732
Sathish Kumar45e991b2017-02-27 10:35:40 +05301733 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301734 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1735 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1736 param->tmpl_len_aligned;
1737 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1738 if (!wmi_buf) {
1739 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1740 return QDF_STATUS_E_NOMEM;
1741 }
1742 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1743 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1744 WMITLV_SET_HDR(&cmd->tlv_header,
1745 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1746 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1747 cmd->vdev_id = param->vdev_id;
1748 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301749 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1750 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301751 cmd->buf_len = param->tmpl_len;
1752 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1753
1754 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1755 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1756 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1757 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1758 bcn_prb_info->caps = 0;
1759 bcn_prb_info->erp = 0;
1760 buf_ptr += sizeof(wmi_bcn_prb_info);
1761
1762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1763 buf_ptr += WMI_TLV_HDR_SIZE;
1764 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1765
1766 ret = wmi_unified_cmd_send(wmi_handle,
1767 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1768 if (ret) {
1769 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1770 wmi_buf_free(wmi_buf);
1771 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301772
Govind Singh87542482016-06-08 19:40:11 +05301773 return 0;
1774}
Govind Singh5eb51532016-03-09 11:34:12 +05301775
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301776#ifdef CONFIG_MCL
1777static inline void copy_peer_flags_tlv(
1778 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1779 struct peer_assoc_params *param)
1780{
1781 cmd->peer_flags = param->peer_flags;
1782}
1783#else
1784static inline void copy_peer_flags_tlv(
1785 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1786 struct peer_assoc_params *param)
1787{
1788 /*
1789 * The target only needs a subset of the flags maintained in the host.
1790 * Just populate those flags and send it down
1791 */
1792 cmd->peer_flags = 0;
1793
1794 /*
1795 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1796 */
1797 if (param->is_wme_set) {
1798
1799 if (param->qos_flag)
1800 cmd->peer_flags |= WMI_PEER_QOS;
1801 if (param->apsd_flag)
1802 cmd->peer_flags |= WMI_PEER_APSD;
1803 if (param->ht_flag)
1804 cmd->peer_flags |= WMI_PEER_HT;
1805 if (param->bw_40)
1806 cmd->peer_flags |= WMI_PEER_40MHZ;
1807 if (param->bw_80)
1808 cmd->peer_flags |= WMI_PEER_80MHZ;
1809 if (param->bw_160)
1810 cmd->peer_flags |= WMI_PEER_160MHZ;
1811
1812 /* Typically if STBC is enabled for VHT it should be enabled
1813 * for HT as well
1814 **/
1815 if (param->stbc_flag)
1816 cmd->peer_flags |= WMI_PEER_STBC;
1817
1818 /* Typically if LDPC is enabled for VHT it should be enabled
1819 * for HT as well
1820 **/
1821 if (param->ldpc_flag)
1822 cmd->peer_flags |= WMI_PEER_LDPC;
1823
1824 if (param->static_mimops_flag)
1825 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1826 if (param->dynamic_mimops_flag)
1827 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1828 if (param->spatial_mux_flag)
1829 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1830 if (param->vht_flag)
1831 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001832 if (param->he_flag)
1833 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301834 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001835
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301836 if (param->is_pmf_enabled)
1837 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301838 /*
1839 * Suppress authorization for all AUTH modes that need 4-way handshake
1840 * (during re-association).
1841 * Authorization will be done for these modes on key installation.
1842 */
1843 if (param->auth_flag)
1844 cmd->peer_flags |= WMI_PEER_AUTH;
1845 if (param->need_ptk_4_way)
1846 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1847 else
1848 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1849 if (param->need_gtk_2_way)
1850 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1851 /* safe mode bypass the 4-way handshake */
1852 if (param->safe_mode_enabled)
1853 cmd->peer_flags &=
1854 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1855 /* Disable AMSDU for station transmit, if user configures it */
1856 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1857 * it
1858 * if (param->amsdu_disable) Add after FW support
1859 **/
1860
1861 /* Target asserts if node is marked HT and all MCS is set to 0.
1862 * Mark the node as non-HT if all the mcs rates are disabled through
1863 * iwpriv
1864 **/
1865 if (param->peer_ht_rates.num_rates == 0)
1866 cmd->peer_flags &= ~WMI_PEER_HT;
1867}
1868#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301869
1870#ifdef CONFIG_MCL
1871static inline void copy_peer_mac_addr_tlv(
1872 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1873 struct peer_assoc_params *param)
1874{
1875 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1876 sizeof(param->peer_macaddr));
1877}
1878#else
1879static inline void copy_peer_mac_addr_tlv(
1880 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1881 struct peer_assoc_params *param)
1882{
1883 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1884}
1885#endif
1886
Govind Singh5eb51532016-03-09 11:34:12 +05301887/**
1888 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1889 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301890 * @param param : pointer to peer assoc parameter
1891 *
1892 * Return: 0 on success and -ve on failure.
1893 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301894static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301895 struct peer_assoc_params *param)
1896{
Govind Singhd3156eb2016-02-26 17:50:39 +05301897 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1898 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001899 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 wmi_buf_t buf;
1901 int32_t len;
1902 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301903 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301904 uint32_t peer_legacy_rates_align;
1905 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001906 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301907
1908
1909 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1910 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301911
1912 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001913 (peer_legacy_rates_align * sizeof(uint8_t)) +
1914 WMI_TLV_HDR_SIZE +
1915 (peer_ht_rates_align * sizeof(uint8_t)) +
1916 sizeof(wmi_vht_rate_set) +
1917 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1918 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301919
1920 buf = wmi_buf_alloc(wmi_handle, len);
1921 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301922 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301923 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301924 }
1925
1926 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1927 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1928 WMITLV_SET_HDR(&cmd->tlv_header,
1929 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1930 WMITLV_GET_STRUCT_TLVLEN
1931 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301932
Govind Singhd3156eb2016-02-26 17:50:39 +05301933 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301934
Govind Singhd3156eb2016-02-26 17:50:39 +05301935 cmd->peer_new_assoc = param->peer_new_assoc;
1936 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301937
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301938 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301939 copy_peer_mac_addr_tlv(cmd, param);
1940
Govind Singhd3156eb2016-02-26 17:50:39 +05301941 cmd->peer_rate_caps = param->peer_rate_caps;
1942 cmd->peer_caps = param->peer_caps;
1943 cmd->peer_listen_intval = param->peer_listen_intval;
1944 cmd->peer_ht_caps = param->peer_ht_caps;
1945 cmd->peer_max_mpdu = param->peer_max_mpdu;
1946 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301947 cmd->peer_vht_caps = param->peer_vht_caps;
1948 cmd->peer_phymode = param->peer_phymode;
1949
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001950 /* Update 11ax capabilities */
1951 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1952 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001953 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1954 sizeof(param->peer_he_cap_phyinfo));
1955 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1956 sizeof(param->peer_ppet));
1957
Govind Singhd3156eb2016-02-26 17:50:39 +05301958 /* Update peer legacy rate information */
1959 buf_ptr += sizeof(*cmd);
1960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301961 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301962 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301963 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301964 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301965 param->peer_legacy_rates.num_rates);
1966
1967 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001968 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301970 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301971 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301972 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301973 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301974 param->peer_ht_rates.num_rates);
1975
1976 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001977 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301978 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1979 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1980
1981 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301982
1983 /* Update bandwidth-NSS mapping */
1984 cmd->peer_bw_rxnss_override = 0;
1985 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1986
Govind Singhd3156eb2016-02-26 17:50:39 +05301987 mcs = (wmi_vht_rate_set *) buf_ptr;
1988 if (param->vht_capable) {
1989 mcs->rx_max_rate = param->rx_max_rate;
1990 mcs->rx_mcs_set = param->rx_mcs_set;
1991 mcs->tx_max_rate = param->tx_max_rate;
1992 mcs->tx_mcs_set = param->tx_mcs_set;
1993 }
1994
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001995 /* HE Rates */
1996 cmd->peer_he_mcs = param->peer_he_mcs_count;
1997 buf_ptr += sizeof(wmi_vht_rate_set);
1998 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1999 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2000 buf_ptr += WMI_TLV_HDR_SIZE;
2001
2002 /* Loop through the HE rate set */
2003 for (i = 0; i < param->peer_he_mcs_count; i++) {
2004 he_mcs = (wmi_he_rate_set *) buf_ptr;
2005 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2006 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2007
2008 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2009 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2010 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2011 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2012 buf_ptr += sizeof(wmi_he_rate_set);
2013 }
2014
2015
Govind Singhb53420c2016-03-09 14:32:57 +05302016 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302017 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2018 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002019 "cmd->peer_vht_caps %x "
2020 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302021 "HE phy %x %x %x "
2022 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302023 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2024 cmd->peer_rate_caps, cmd->peer_caps,
2025 cmd->peer_listen_intval, cmd->peer_ht_caps,
2026 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2027 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002028 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2029 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302030 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2031 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302032
2033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2034 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302035 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302036 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302038 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302039 }
2040
2041 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302042}
2043
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302044/* copy_scan_notify_events() - Helper routine to copy scan notify events
2045 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302046static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302047 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302048 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302049{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302050
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302051 /* Scan events subscription */
2052 if (param->scan_ev_started)
2053 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2054 if (param->scan_ev_completed)
2055 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2056 if (param->scan_ev_bss_chan)
2057 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2058 if (param->scan_ev_foreign_chan)
2059 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2060 if (param->scan_ev_dequeued)
2061 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2062 if (param->scan_ev_preempted)
2063 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2064 if (param->scan_ev_start_failed)
2065 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2066 if (param->scan_ev_restarted)
2067 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2068 if (param->scan_ev_foreign_chn_exit)
2069 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2070 if (param->scan_ev_suspended)
2071 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2072 if (param->scan_ev_resumed)
2073 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302074
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302075 /** Set scan control flags */
2076 cmd->scan_ctrl_flags = 0;
2077 if (param->scan_f_passive)
2078 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2079 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302080 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302081 if (param->scan_f_promisc_mode)
2082 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2083 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302084 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302085 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302086 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302087 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302088 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302089 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302090 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302091 if (param->scan_f_ofdm_rates)
2092 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2093 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302094 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302095 if (param->scan_f_filter_prb_req)
2096 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2097 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302098 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302099 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302100 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302101 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302102 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302103 if (param->scan_f_force_active_dfs_chn)
2104 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2105 if (param->scan_f_add_tpc_ie_in_probe)
2106 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2107 if (param->scan_f_add_ds_ie_in_probe)
2108 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2109 if (param->scan_f_add_spoofed_mac_in_probe)
2110 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2111 if (param->scan_f_add_rand_seq_in_probe)
2112 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2113 if (param->scan_f_en_ie_whitelist_in_probe)
2114 cmd->scan_ctrl_flags |=
2115 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302116
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302117 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2118 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2119 param->adaptive_dwell_time_mode);
2120}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302121
2122/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302123static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302124 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302125{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302126 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302127}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302128
Anish Natarajdd855152017-03-20 12:49:08 +05302129/*
2130 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2131 * @param wmi_handle : Handle to WMI
2132 * @param vdev_id : vdev identifier
2133 *
2134 * Return : void *
2135 */
2136static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2137{
2138 struct wlan_objmgr_vdev *vdev = NULL;
2139 struct wlan_objmgr_pdev *pdev = NULL;
2140 uint8_t pdev_id = 0;
2141
2142 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2143 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2144 vdev_id, WLAN_SCAN_ID);
2145 if (vdev) {
2146 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2147 pdev = wlan_vdev_get_pdev(vdev);
2148 if (pdev)
2149 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2150 else {
2151 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2152 }
2153 } else {
2154 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2155 }
2156
2157 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2158}
2159
Govind Singh5eb51532016-03-09 11:34:12 +05302160/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302161 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2162 * @mac: random mac addr
2163 * @mask: random mac mask
2164 * @mac_addr: wmi random mac
2165 * @mac_mask: wmi random mac mask
2166 *
2167 * Return None.
2168 */
2169static inline
2170void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2171 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2172{
2173 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2174 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2175}
2176
2177/**
Govind Singh5eb51532016-03-09 11:34:12 +05302178 * send_scan_start_cmd_tlv() - WMI scan start function
2179 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302180 * @param param : pointer to hold scan start cmd parameter
2181 *
2182 * Return: 0 on success and -ve on failure.
2183 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302184static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302185 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302186{
Govind Singhd3156eb2016-02-26 17:50:39 +05302187 int32_t ret = 0;
2188 int32_t i;
2189 wmi_buf_t wmi_buf;
2190 wmi_start_scan_cmd_fixed_param *cmd;
2191 uint8_t *buf_ptr;
2192 uint32_t *tmp_ptr;
2193 wmi_ssid *ssid = NULL;
2194 wmi_mac_addr *bssid;
2195 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302196 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302197
2198 /* Length TLV placeholder for array of uint32_t */
2199 len += WMI_TLV_HDR_SIZE;
2200 /* calculate the length of buffer required */
2201 if (params->num_chan)
2202 len += params->num_chan * sizeof(uint32_t);
2203
2204 /* Length TLV placeholder for array of wmi_ssid structures */
2205 len += WMI_TLV_HDR_SIZE;
2206 if (params->num_ssids)
2207 len += params->num_ssids * sizeof(wmi_ssid);
2208
2209 /* Length TLV placeholder for array of wmi_mac_addr structures */
2210 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302211 if (params->num_bssid)
2212 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302213
2214 /* Length TLV placeholder for array of bytes */
2215 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302216 if (params->extraie.len)
2217 extraie_len_with_pad =
2218 roundup(params->extraie.len, sizeof(uint32_t));
2219 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302220
2221 /* Allocate the memory */
2222 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2223 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302224 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302225 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302226 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302227 }
2228 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2229 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2230 WMITLV_SET_HDR(&cmd->tlv_header,
2231 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2232 WMITLV_GET_STRUCT_TLVLEN
2233 (wmi_start_scan_cmd_fixed_param));
2234
2235 cmd->scan_id = params->scan_id;
2236 cmd->scan_req_id = params->scan_req_id;
2237 cmd->vdev_id = params->vdev_id;
2238 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302239
2240 copy_scan_event_cntrl_flags(cmd, params);
2241
Govind Singhd3156eb2016-02-26 17:50:39 +05302242 cmd->dwell_time_active = params->dwell_time_active;
2243 cmd->dwell_time_passive = params->dwell_time_passive;
2244 cmd->min_rest_time = params->min_rest_time;
2245 cmd->max_rest_time = params->max_rest_time;
2246 cmd->repeat_probe_time = params->repeat_probe_time;
2247 cmd->probe_spacing_time = params->probe_spacing_time;
2248 cmd->idle_time = params->idle_time;
2249 cmd->max_scan_time = params->max_scan_time;
2250 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302251 cmd->burst_duration = params->burst_duration;
2252 cmd->num_chan = params->num_chan;
2253 cmd->num_bssid = params->num_bssid;
2254 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302255 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302256 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302257 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2258
2259 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2260
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302261 if (params->scan_random.randomize)
2262 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2263 params->scan_random.mac_mask,
2264 &cmd->mac_addr,
2265 &cmd->mac_mask);
2266
Govind Singhd3156eb2016-02-26 17:50:39 +05302267 buf_ptr += sizeof(*cmd);
2268 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2269 for (i = 0; i < params->num_chan; ++i)
2270 tmp_ptr[i] = params->chan_list[i];
2271
2272 WMITLV_SET_HDR(buf_ptr,
2273 WMITLV_TAG_ARRAY_UINT32,
2274 (params->num_chan * sizeof(uint32_t)));
2275 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302276 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302277 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302278 goto error;
2279 }
2280
2281 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2282 (params->num_ssids * sizeof(wmi_ssid)));
2283
2284 if (params->num_ssids) {
2285 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2286 for (i = 0; i < params->num_ssids; ++i) {
2287 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302288 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302289 params->ssid[i].length);
2290 ssid++;
2291 }
2292 }
2293 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2294
2295 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2296 (params->num_bssid * sizeof(wmi_mac_addr)));
2297 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302298
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302299 if (params->num_bssid) {
2300 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302301 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2302 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302303 bssid++;
2304 }
2305 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302306
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302307 buf_ptr += WMI_TLV_HDR_SIZE +
2308 (params->num_bssid * sizeof(wmi_mac_addr));
2309
2310 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2311 if (params->extraie.len)
2312 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2313 params);
2314
2315 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302316
Anish Natarajdd855152017-03-20 12:49:08 +05302317 ret = wmi_unified_cmd_send(
2318 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302319 len, WMI_START_SCAN_CMDID);
2320 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302321 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302322 wmi_buf_free(wmi_buf);
2323 }
2324 return ret;
2325error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302326 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302327 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302328}
2329
2330/**
2331 * send_scan_stop_cmd_tlv() - WMI scan start function
2332 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302333 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302334 *
2335 * Return: 0 on success and -ve on failure.
2336 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302337static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302338 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302339{
Govind Singhd3156eb2016-02-26 17:50:39 +05302340 wmi_stop_scan_cmd_fixed_param *cmd;
2341 int ret;
2342 int len = sizeof(*cmd);
2343 wmi_buf_t wmi_buf;
2344
2345 /* Allocate the memory */
2346 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2347 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302348 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302349 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302350 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302351 goto error;
2352 }
2353
2354 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2355 WMITLV_SET_HDR(&cmd->tlv_header,
2356 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2357 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2358 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302359 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302360 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302361 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2362 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302363 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302364 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2365 /* Cancelling all scans */
2366 cmd->req_type = WMI_SCAN_STOP_ALL;
2367 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2368 /* Cancelling VAP scans */
2369 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2370 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2371 /* Cancelling specific scan */
2372 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302373 } else {
2374 WMI_LOGE("%s: Invalid Command : ", __func__);
2375 wmi_buf_free(wmi_buf);
2376 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302377 }
2378
Anish Natarajdd855152017-03-20 12:49:08 +05302379 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 len, WMI_STOP_SCAN_CMDID);
2381 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302382 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302383 wmi_buf_free(wmi_buf);
2384 }
2385
2386error:
2387 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302388}
2389
Govind Singh87542482016-06-08 19:40:11 +05302390#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302391/**
2392 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2393 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302394 * @param param : pointer to hold scan channel list parameter
2395 *
2396 * Return: 0 on success and -ve on failure.
2397 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302398static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302399 struct scan_chan_list_params *chan_list)
2400{
2401 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302402 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302403 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302404 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302405 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302406 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2408
2409 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2410 buf = wmi_buf_alloc(wmi_handle, len);
2411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302412 WMI_LOGE("Failed to allocate memory");
2413 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302414 goto end;
2415 }
2416
2417 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2418 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2419 WMITLV_SET_HDR(&cmd->tlv_header,
2420 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2421 WMITLV_GET_STRUCT_TLVLEN
2422 (wmi_scan_chan_list_cmd_fixed_param));
2423
Govind Singhb53420c2016-03-09 14:32:57 +05302424 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302425
2426 cmd->num_scan_chans = chan_list->num_scan_chans;
2427 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2428 WMITLV_TAG_ARRAY_STRUC,
2429 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302430 chan_info = (wmi_channel_param *)
2431 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302432 tchan_info = chan_list->chan_info;
2433
2434 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2435 WMITLV_SET_HDR(&chan_info->tlv_header,
2436 WMITLV_TAG_STRUC_wmi_channel,
2437 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2438 chan_info->mhz = tchan_info->mhz;
2439 chan_info->band_center_freq1 =
2440 tchan_info->band_center_freq1;
2441 chan_info->band_center_freq2 =
2442 tchan_info->band_center_freq2;
2443 chan_info->info = tchan_info->info;
2444 chan_info->reg_info_1 = tchan_info->reg_info_1;
2445 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302446 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302447
2448 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2449 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2450 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2451 tchan_info++;
2452 chan_info++;
2453 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302454 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2455 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302456
Anish Natarajdd855152017-03-20 12:49:08 +05302457 qdf_status = wmi_unified_cmd_send(wmi_handle,
2458 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302459
Govind Singh67922e82016-04-01 16:48:57 +05302460 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302461 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302462 wmi_buf_free(buf);
2463 }
Govind Singh67922e82016-04-01 16:48:57 +05302464
Govind Singhd3156eb2016-02-26 17:50:39 +05302465end:
Govind Singhb53420c2016-03-09 14:32:57 +05302466 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302467}
Govind Singh87542482016-06-08 19:40:11 +05302468#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302469static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302470 struct scan_chan_list_params *chan_list)
2471{
2472 wmi_buf_t buf;
2473 QDF_STATUS qdf_status;
2474 wmi_scan_chan_list_cmd_fixed_param *cmd;
2475 int i;
2476 uint8_t *buf_ptr;
2477 wmi_channel *chan_info;
2478 struct channel_param *tchan_info;
2479 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302480
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302481 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302482 buf = wmi_buf_alloc(wmi_handle, len);
2483 if (!buf) {
2484 WMI_LOGE("Failed to allocate memory");
2485 qdf_status = QDF_STATUS_E_NOMEM;
2486 goto end;
2487 }
2488
2489 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2490 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2491 WMITLV_SET_HDR(&cmd->tlv_header,
2492 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2493 WMITLV_GET_STRUCT_TLVLEN
2494 (wmi_scan_chan_list_cmd_fixed_param));
2495
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302496 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302497
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302498 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2499 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302500 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302501 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2502 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302503 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302504 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2505 tchan_info = &(chan_list->ch_param[0]);
2506
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302507 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302508 WMITLV_SET_HDR(&chan_info->tlv_header,
2509 WMITLV_TAG_STRUC_wmi_channel,
2510 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2511 chan_info->mhz = tchan_info->mhz;
2512 chan_info->band_center_freq1 =
2513 tchan_info->cfreq1;
2514 chan_info->band_center_freq2 =
2515 tchan_info->cfreq2;
2516
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302517 if (tchan_info->is_chan_passive)
2518 WMI_SET_CHANNEL_FLAG(chan_info,
2519 WMI_CHAN_FLAG_PASSIVE);
2520
2521 if (tchan_info->allow_vht)
2522 WMI_SET_CHANNEL_FLAG(chan_info,
2523 WMI_CHAN_FLAG_ALLOW_VHT);
2524 else if (tchan_info->allow_ht)
2525 WMI_SET_CHANNEL_FLAG(chan_info,
2526 WMI_CHAN_FLAG_ALLOW_HT);
2527 WMI_SET_CHANNEL_MODE(chan_info,
2528 tchan_info->phy_mode);
2529
2530 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2531 * after FW support
2532 */
2533
2534 /* also fill in power information */
2535 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2536 tchan_info->minpower);
2537 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2538 tchan_info->maxpower);
2539 WMI_SET_CHANNEL_REG_POWER(chan_info,
2540 tchan_info->maxregpower);
2541 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2542 tchan_info->antennamax);
2543 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2544 tchan_info->reg_class_id);
2545
Govind Singh87542482016-06-08 19:40:11 +05302546 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2547
Govind Singh87542482016-06-08 19:40:11 +05302548 tchan_info++;
2549 chan_info++;
2550 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302551 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2552 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302553
Anish Natarajdd855152017-03-20 12:49:08 +05302554 qdf_status = wmi_unified_cmd_send(
2555 wmi_handle,
2556 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302557
2558 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2559 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2560 wmi_buf_free(buf);
2561 }
2562
2563end:
2564 return qdf_status;
2565}
2566#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302567
2568/**
2569 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2570 *
2571 * @bufp: Pointer to buffer
2572 * @param: Pointer to tx param
2573 *
2574 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2575 */
2576static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
2577 struct tx_send_params param)
2578{
2579 wmi_tx_send_params *tx_param;
2580 QDF_STATUS status = QDF_STATUS_SUCCESS;
2581
2582 if (!bufp) {
2583 status = QDF_STATUS_E_FAILURE;
2584 return status;
2585 }
2586 tx_param = (wmi_tx_send_params *)bufp;
2587 WMITLV_SET_HDR(&tx_param->tlv_header,
2588 WMITLV_TAG_STRUC_wmi_tx_send_params,
2589 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2590 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2591 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2592 param.mcs_mask);
2593 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2594 param.nss_mask);
2595 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2596 param.retry_limit);
2597 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2598 param.chain_mask);
2599 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2600 param.bw_mask);
2601 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2602 param.preamble_type);
2603 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2604 param.frame_type);
2605
2606 return status;
2607}
2608
Govind Singhd3156eb2016-02-26 17:50:39 +05302609/**
2610 * send_mgmt_cmd_tlv() - WMI scan start function
2611 * @wmi_handle : handle to WMI.
2612 * @param : pointer to hold mgmt cmd parameter
2613 *
2614 * Return: 0 on success and -ve on failure.
2615 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302616static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302617 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302618{
Govind Singh427ee5a2016-02-26 18:09:36 +05302619 wmi_buf_t buf;
2620 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2621 int32_t cmd_len;
2622 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302623 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302624 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302625 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302626 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2627 mgmt_tx_dl_frm_len;
2628
2629 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302630 WMI_TLV_HDR_SIZE +
2631 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302632
Sathish Kumar5b636932017-06-28 14:40:32 +05302633 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302634 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302635 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2636 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302637 }
2638
2639 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2640 bufp = (uint8_t *) cmd;
2641 WMITLV_SET_HDR(&cmd->tlv_header,
2642 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2643 WMITLV_GET_STRUCT_TLVLEN
2644 (wmi_mgmt_tx_send_cmd_fixed_param));
2645
2646 cmd->vdev_id = param->vdev_id;
2647
Govind Singh224a7312016-06-21 14:33:26 +05302648 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302649 cmd->chanfreq = param->chanfreq;
2650 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2651 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2652 sizeof(uint32_t)));
2653 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302654 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302655
2656 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2657 QDF_DMA_TO_DEVICE);
2658 if (status != QDF_STATUS_SUCCESS) {
2659 WMI_LOGE("%s: wmi buf map failed", __func__);
2660 goto err1;
2661 }
2662
Govind Singhb53420c2016-03-09 14:32:57 +05302663 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302664 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002665#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302666 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2667#endif
2668 cmd->frame_len = param->frm_len;
2669 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302670 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302671
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002672 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002673 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002674
Sathish Kumar5b636932017-06-28 14:40:32 +05302675 bufp += roundup(bufp_len, sizeof(uint32_t));
2676 if (param->tx_params_valid) {
2677 status = populate_tx_send_params(bufp, param->tx_param);
2678 if (status != QDF_STATUS_SUCCESS) {
2679 WMI_LOGE("%s: Populate TX send params failed",
2680 __func__);
2681 goto err1;
2682 }
2683 cmd_len += sizeof(wmi_tx_send_params);
2684 }
2685
Govind Singh427ee5a2016-02-26 18:09:36 +05302686 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2687 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302688 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302689 goto err1;
2690 }
Govind Singhb53420c2016-03-09 14:32:57 +05302691 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302692
2693err1:
2694 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302695 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302696}
2697
2698/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302699 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2700 * @wmi_handle : handle to WMI.
2701 * @param : pointer to offchan data tx cmd parameter
2702 *
2703 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2704 */
2705static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2706 struct wmi_offchan_data_tx_params *param)
2707{
2708 wmi_buf_t buf;
2709 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2710 int32_t cmd_len;
2711 uint64_t dma_addr;
2712 void *qdf_ctx = param->qdf_ctx;
2713 uint8_t *bufp;
2714 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2715 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302716 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302717
2718 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302719 WMI_TLV_HDR_SIZE +
2720 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302721
Sathish Kumar5b636932017-06-28 14:40:32 +05302722 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302723 if (!buf) {
2724 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2725 return QDF_STATUS_E_NOMEM;
2726 }
2727
2728 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2729 bufp = (uint8_t *) cmd;
2730 WMITLV_SET_HDR(&cmd->tlv_header,
2731 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2732 WMITLV_GET_STRUCT_TLVLEN
2733 (wmi_offchan_data_tx_send_cmd_fixed_param));
2734
2735 cmd->vdev_id = param->vdev_id;
2736
2737 cmd->desc_id = param->desc_id;
2738 cmd->chanfreq = param->chanfreq;
2739 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2740 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2741 sizeof(uint32_t)));
2742 bufp += WMI_TLV_HDR_SIZE;
2743 qdf_mem_copy(bufp, param->pdata, bufp_len);
2744 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2745 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2746 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2747#if defined(HTT_PADDR64)
2748 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2749#endif
2750 cmd->frame_len = param->frm_len;
2751 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302752 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302753
2754 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2755 bufp, cmd->vdev_id, cmd->chanfreq);
2756
Sathish Kumar5b636932017-06-28 14:40:32 +05302757 bufp += roundup(bufp_len, sizeof(uint32_t));
2758 if (param->tx_params_valid) {
2759 status = populate_tx_send_params(bufp, param->tx_param);
2760 if (status != QDF_STATUS_SUCCESS) {
2761 WMI_LOGE("%s: Populate TX send params failed",
2762 __func__);
2763 goto err1;
2764 }
2765 cmd_len += sizeof(wmi_tx_send_params);
2766 }
2767
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302768 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2769 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2770 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05302771 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302772 }
2773
2774 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05302775
2776err1:
2777 wmi_buf_free(buf);
2778 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302779}
2780
2781/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302782 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2783 * @wmi_handle: wmi handle
2784 * @param_value: parameter value
2785 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302786 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302787 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302788static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302789 uint32_t param_value)
2790{
Govind Singh67922e82016-04-01 16:48:57 +05302791 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302792 wmi_modem_power_state_cmd_param *cmd;
2793 wmi_buf_t buf;
2794 uint16_t len = sizeof(*cmd);
2795
2796 buf = wmi_buf_alloc(wmi_handle, len);
2797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302798 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302799 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302800 }
2801 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2802 WMITLV_SET_HDR(&cmd->tlv_header,
2803 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2804 WMITLV_GET_STRUCT_TLVLEN
2805 (wmi_modem_power_state_cmd_param));
2806 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302807 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302808 param_value);
2809 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2810 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302811 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302812 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302813 wmi_buf_free(buf);
2814 }
Govind Singh67922e82016-04-01 16:48:57 +05302815
Govind Singh427ee5a2016-02-26 18:09:36 +05302816 return ret;
2817}
2818
2819/**
2820 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2821 * @wmi_handle: wmi handle
2822 * @vdev_id: vdev id
2823 * @val: value
2824 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302825 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302826 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302827static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302828 uint32_t vdev_id, uint8_t val)
2829{
2830 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2831 wmi_buf_t buf;
2832 int32_t len = sizeof(*cmd);
2833
Govind Singhb53420c2016-03-09 14:32:57 +05302834 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302835
2836 buf = wmi_buf_alloc(wmi_handle, len);
2837 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302838 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302839 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302840 }
2841 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2842 WMITLV_SET_HDR(&cmd->tlv_header,
2843 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2844 WMITLV_GET_STRUCT_TLVLEN
2845 (wmi_sta_powersave_mode_cmd_fixed_param));
2846 cmd->vdev_id = vdev_id;
2847 if (val)
2848 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2849 else
2850 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2851
2852 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2853 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302854 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302855 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302856 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302857 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302858 }
Govind Singh5eb51532016-03-09 11:34:12 +05302859 return 0;
2860}
2861
Govind Singh427ee5a2016-02-26 18:09:36 +05302862/**
2863 * send_set_mimops_cmd_tlv() - set MIMO powersave
2864 * @wmi_handle: wmi handle
2865 * @vdev_id: vdev id
2866 * @value: value
2867 *
Govind Singhb53420c2016-03-09 14:32:57 +05302868 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302869 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302870static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302871 uint8_t vdev_id, int value)
2872{
Govind Singh67922e82016-04-01 16:48:57 +05302873 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302874 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2875 wmi_buf_t buf;
2876 uint16_t len = sizeof(*cmd);
2877
2878 buf = wmi_buf_alloc(wmi_handle, len);
2879 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302880 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302881 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302882 }
2883 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2884 WMITLV_SET_HDR(&cmd->tlv_header,
2885 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2886 WMITLV_GET_STRUCT_TLVLEN
2887 (wmi_sta_smps_force_mode_cmd_fixed_param));
2888
2889 cmd->vdev_id = vdev_id;
2890
Houston Hoffmanb5168052016-04-14 02:18:01 -07002891 /* WMI_SMPS_FORCED_MODE values do not directly map
2892 * to SM power save values defined in the specification.
2893 * Make sure to send the right mapping.
2894 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302895 switch (value) {
2896 case 0:
2897 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2898 break;
2899 case 1:
2900 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2901 break;
2902 case 2:
2903 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2904 break;
2905 case 3:
2906 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2907 break;
2908 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302909 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2910 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302911 }
2912
Govind Singhb53420c2016-03-09 14:32:57 +05302913 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302914
2915 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2916 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302917 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302918 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302919 wmi_buf_free(buf);
2920 }
2921
2922 return ret;
2923}
2924
2925/**
2926 * send_set_smps_params_cmd_tlv() - set smps params
2927 * @wmi_handle: wmi handle
2928 * @vdev_id: vdev id
2929 * @value: value
2930 *
Govind Singhb53420c2016-03-09 14:32:57 +05302931 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302933static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302934 int value)
2935{
Govind Singh67922e82016-04-01 16:48:57 +05302936 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302937 wmi_sta_smps_param_cmd_fixed_param *cmd;
2938 wmi_buf_t buf;
2939 uint16_t len = sizeof(*cmd);
2940
2941 buf = wmi_buf_alloc(wmi_handle, len);
2942 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302943 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302944 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302945 }
2946 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2947 WMITLV_SET_HDR(&cmd->tlv_header,
2948 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2949 WMITLV_GET_STRUCT_TLVLEN
2950 (wmi_sta_smps_param_cmd_fixed_param));
2951
2952 cmd->vdev_id = vdev_id;
2953 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2954 cmd->param =
2955 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2956
Govind Singhb53420c2016-03-09 14:32:57 +05302957 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302958 cmd->param);
2959
2960 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2961 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302962 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302963 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302964 wmi_buf_free(buf);
2965 }
2966
2967 return ret;
2968}
2969
2970/**
2971 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2972 * @wmi_handle: wmi handle
2973 * @noa: p2p power save parameters
2974 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302975 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302976 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302977static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302978 struct p2p_ps_params *noa)
2979{
2980 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2981 wmi_p2p_noa_descriptor *noa_discriptor;
2982 wmi_buf_t buf;
2983 uint8_t *buf_ptr;
2984 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302985 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302986 uint32_t duration;
2987
Govind Singhb53420c2016-03-09 14:32:57 +05302988 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302989 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2990 buf = wmi_buf_alloc(wmi_handle, len);
2991 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302992 WMI_LOGE("Failed to allocate memory");
2993 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302994 goto end;
2995 }
2996
2997 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2998 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2999 WMITLV_SET_HDR(&cmd->tlv_header,
3000 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3001 WMITLV_GET_STRUCT_TLVLEN
3002 (wmi_p2p_set_noa_cmd_fixed_param));
3003 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3004 cmd->vdev_id = noa->session_id;
3005 cmd->enable = (duration) ? true : false;
3006 cmd->num_noa = 1;
3007
3008 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3009 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3010 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3011 sizeof
3012 (wmi_p2p_set_noa_cmd_fixed_param)
3013 + WMI_TLV_HDR_SIZE);
3014 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3015 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3016 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3017 noa_discriptor->type_count = noa->count;
3018 noa_discriptor->duration = duration;
3019 noa_discriptor->interval = noa->interval;
3020 noa_discriptor->start_time = 0;
3021
Govind Singhb53420c2016-03-09 14:32:57 +05303022 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303023 cmd->vdev_id, noa->count, noa_discriptor->duration,
3024 noa->interval);
3025 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3026 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303027 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303028 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303029 wmi_buf_free(buf);
3030 }
3031
3032end:
Govind Singhb53420c2016-03-09 14:32:57 +05303033 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303034 return status;
3035}
3036
3037
3038/**
3039 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3040 * @wmi_handle: wmi handle
3041 * @noa: p2p opp power save parameters
3042 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303043 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303044 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303045static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303046 struct p2p_ps_params *oppps)
3047{
3048 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3049 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303050 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303051
Govind Singhb53420c2016-03-09 14:32:57 +05303052 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303053 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303055 WMI_LOGE("Failed to allocate memory");
3056 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303057 goto end;
3058 }
3059
3060 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3061 WMITLV_SET_HDR(&cmd->tlv_header,
3062 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3063 WMITLV_GET_STRUCT_TLVLEN
3064 (wmi_p2p_set_oppps_cmd_fixed_param));
3065 cmd->vdev_id = oppps->session_id;
3066 if (oppps->ctwindow)
3067 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3068
3069 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303070 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303071 cmd->vdev_id, oppps->ctwindow);
3072 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3073 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303074 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303075 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303076 wmi_buf_free(buf);
3077 }
3078
3079end:
Govind Singhb53420c2016-03-09 14:32:57 +05303080 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303081 return status;
3082}
3083
Wu Gaocd3a8512017-03-13 20:17:34 +08003084#ifdef CONVERGED_P2P_ENABLE
3085/**
3086 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3087 * @wmi_handle: wmi handle
3088 * @param: p2p listen offload start parameters
3089 *
3090 * Return: QDF status
3091 */
3092static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3093 struct p2p_lo_start *param)
3094{
3095 wmi_buf_t buf;
3096 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3097 int32_t len = sizeof(*cmd);
3098 uint8_t *buf_ptr;
3099 QDF_STATUS status;
3100 int device_types_len_aligned;
3101 int probe_resp_len_aligned;
3102
3103 if (!param) {
3104 WMI_LOGE("lo start param is null");
3105 return QDF_STATUS_E_INVAL;
3106 }
3107
3108 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3109
3110 device_types_len_aligned =
3111 qdf_roundup(param->dev_types_len,
3112 sizeof(A_UINT32));
3113 probe_resp_len_aligned =
3114 qdf_roundup(param->probe_resp_len,
3115 sizeof(A_UINT32));
3116
3117 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3118 probe_resp_len_aligned;
3119
3120 buf = wmi_buf_alloc(wmi_handle, len);
3121 if (!buf) {
3122 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3123 __func__);
3124 return QDF_STATUS_E_NOMEM;
3125 }
3126
3127 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3128 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3129
3130 WMITLV_SET_HDR(&cmd->tlv_header,
3131 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3132 WMITLV_GET_STRUCT_TLVLEN(
3133 wmi_p2p_lo_start_cmd_fixed_param));
3134
3135 cmd->vdev_id = param->vdev_id;
3136 cmd->ctl_flags = param->ctl_flags;
3137 cmd->channel = param->freq;
3138 cmd->period = param->period;
3139 cmd->interval = param->interval;
3140 cmd->count = param->count;
3141 cmd->device_types_len = param->dev_types_len;
3142 cmd->prob_resp_len = param->probe_resp_len;
3143
3144 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3145 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3146 device_types_len_aligned);
3147 buf_ptr += WMI_TLV_HDR_SIZE;
3148 qdf_mem_copy(buf_ptr, param->device_types,
3149 param->dev_types_len);
3150
3151 buf_ptr += device_types_len_aligned;
3152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3153 probe_resp_len_aligned);
3154 buf_ptr += WMI_TLV_HDR_SIZE;
3155 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3156 param->probe_resp_len);
3157
3158 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3159 cmd->channel, cmd->period, cmd->interval, cmd->count);
3160
3161 status = wmi_unified_cmd_send(wmi_handle,
3162 buf, len,
3163 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3164 if (status != QDF_STATUS_SUCCESS) {
3165 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3166 __func__, status);
3167 wmi_buf_free(buf);
3168 return status;
3169 }
3170
3171 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3172
3173 return QDF_STATUS_SUCCESS;
3174}
3175
3176/**
3177 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3178 * @wmi_handle: wmi handle
3179 * @param: p2p listen offload stop parameters
3180 *
3181 * Return: QDF status
3182 */
3183static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3184 uint8_t vdev_id)
3185{
3186 wmi_buf_t buf;
3187 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3188 int32_t len;
3189 QDF_STATUS status;
3190
3191 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3192
3193 len = sizeof(*cmd);
3194 buf = wmi_buf_alloc(wmi_handle, len);
3195 if (!buf) {
3196 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3197 __func__);
3198 return QDF_STATUS_E_NOMEM;
3199 }
3200 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3201
3202 WMITLV_SET_HDR(&cmd->tlv_header,
3203 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3204 WMITLV_GET_STRUCT_TLVLEN(
3205 wmi_p2p_lo_stop_cmd_fixed_param));
3206
3207 cmd->vdev_id = vdev_id;
3208
3209 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3210
3211 status = wmi_unified_cmd_send(wmi_handle,
3212 buf, len,
3213 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3214 if (status != QDF_STATUS_SUCCESS) {
3215 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3216 __func__, status);
3217 wmi_buf_free(buf);
3218 return status;
3219 }
3220
3221 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3222
3223 return QDF_STATUS_SUCCESS;
3224}
3225#endif /* End of CONVERGED_P2P_ENABLE */
3226
Govind Singh427ee5a2016-02-26 18:09:36 +05303227/**
3228 * send_get_temperature_cmd_tlv() - get pdev temperature req
3229 * @wmi_handle: wmi handle
3230 *
Govind Singhb53420c2016-03-09 14:32:57 +05303231 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303233static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303234{
3235 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3236 wmi_buf_t wmi_buf;
3237 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3238 uint8_t *buf_ptr;
3239
3240 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303241 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3242 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303243 }
3244
3245 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3246 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303247 WMI_LOGE(FL("wmi_buf_alloc failed"));
3248 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303249 }
3250
3251 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3252
3253 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3254 WMITLV_SET_HDR(&cmd->tlv_header,
3255 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3256 WMITLV_GET_STRUCT_TLVLEN
3257 (wmi_pdev_get_temperature_cmd_fixed_param));
3258
3259 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3260 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303261 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303263 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303264 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303265
Govind Singhb53420c2016-03-09 14:32:57 +05303266 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303267}
3268
3269/**
3270 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3271 * @wmi_handle: wmi handle
3272 * @vdevid: vdev id
3273 * @peer_addr: peer mac address
3274 * @auto_triggerparam: auto trigger parameters
3275 * @num_ac: number of access category
3276 *
3277 * This function sets the trigger
3278 * uapsd params such as service interval, delay interval
3279 * and suspend interval which will be used by the firmware
3280 * to send trigger frames periodically when there is no
3281 * traffic on the transmit side.
3282 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303283 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303284 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303285static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303286 struct sta_uapsd_trig_params *param)
3287{
3288 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303289 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303290 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3291 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3292 uint32_t i;
3293 wmi_buf_t buf;
3294 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003295 struct sta_uapsd_params *uapsd_param;
3296 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303297
3298 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3299 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303300 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303301 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303302 }
3303
3304 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3305 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3306 WMITLV_SET_HDR(&cmd->tlv_header,
3307 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3308 WMITLV_GET_STRUCT_TLVLEN
3309 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3310 cmd->vdev_id = param->vdevid;
3311 cmd->num_ac = param->num_ac;
3312 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3313
3314 /* TLV indicating array of structures to follow */
3315 buf_ptr += sizeof(*cmd);
3316 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3317
3318 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303319
3320 /*
3321 * Update tag and length for uapsd auto trigger params (this will take
3322 * care of updating tag and length if it is not pre-filled by caller).
3323 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003324 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3325 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303326 for (i = 0; i < param->num_ac; i++) {
3327 WMITLV_SET_HDR((buf_ptr +
3328 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3329 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3330 WMITLV_GET_STRUCT_TLVLEN
3331 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003332 trig_param->wmm_ac = uapsd_param->wmm_ac;
3333 trig_param->user_priority = uapsd_param->user_priority;
3334 trig_param->service_interval = uapsd_param->service_interval;
3335 trig_param->suspend_interval = uapsd_param->suspend_interval;
3336 trig_param->delay_interval = uapsd_param->delay_interval;
3337 trig_param++;
3338 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303339 }
3340
3341 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3342 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303343 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303344 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303345 wmi_buf_free(buf);
3346 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303347
Govind Singh427ee5a2016-02-26 18:09:36 +05303348 return ret;
3349}
3350
Govind Singh2edc80f2016-03-01 15:30:53 +05303351/**
3352 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3353 * @wmi_handle: pointer to the wmi handle
3354 * @utc: pointer to the UTC time struct
3355 *
3356 * Return: 0 on succes
3357 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303358static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303359 struct ocb_utc_param *utc)
3360{
Govind Singh67922e82016-04-01 16:48:57 +05303361 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303362 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3363 uint8_t *buf_ptr;
3364 uint32_t len, i;
3365 wmi_buf_t buf;
3366
3367 len = sizeof(*cmd);
3368 buf = wmi_buf_alloc(wmi_handle, len);
3369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303370 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303371 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303372 }
3373
3374 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3375 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3376 WMITLV_SET_HDR(&cmd->tlv_header,
3377 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3378 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3379 cmd->vdev_id = utc->vdev_id;
3380
3381 for (i = 0; i < SIZE_UTC_TIME; i++)
3382 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3383
3384 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3385 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3386
3387 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3388 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303389 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303390 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303391 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303392 }
3393
Govind Singh67922e82016-04-01 16:48:57 +05303394 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303395}
3396
3397/**
3398 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3399 * frames on a channel
3400 * @wmi_handle: pointer to the wmi handle
3401 * @timing_advert: pointer to the timing advertisement struct
3402 *
3403 * Return: 0 on succes
3404 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303405static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303406 struct ocb_timing_advert_param *timing_advert)
3407{
Govind Singh67922e82016-04-01 16:48:57 +05303408 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303409 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3410 uint8_t *buf_ptr;
3411 uint32_t len, len_template;
3412 wmi_buf_t buf;
3413
3414 len = sizeof(*cmd) +
3415 WMI_TLV_HDR_SIZE;
3416
3417 len_template = timing_advert->template_length;
3418 /* Add padding to the template if needed */
3419 if (len_template % 4 != 0)
3420 len_template += 4 - (len_template % 4);
3421 len += len_template;
3422
3423 buf = wmi_buf_alloc(wmi_handle, len);
3424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303425 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303426 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303427 }
3428
3429 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3430 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3431 WMITLV_SET_HDR(&cmd->tlv_header,
3432 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3433 WMITLV_GET_STRUCT_TLVLEN(
3434 wmi_ocb_start_timing_advert_cmd_fixed_param));
3435 cmd->vdev_id = timing_advert->vdev_id;
3436 cmd->repeat_rate = timing_advert->repeat_rate;
3437 cmd->channel_freq = timing_advert->chan_freq;
3438 cmd->timestamp_offset = timing_advert->timestamp_offset;
3439 cmd->time_value_offset = timing_advert->time_value_offset;
3440 cmd->timing_advert_template_length = timing_advert->template_length;
3441 buf_ptr += sizeof(*cmd);
3442
3443 /* Add the timing advert template */
3444 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3445 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303446 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303447 (uint8_t *)timing_advert->template_value,
3448 timing_advert->template_length);
3449
3450 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3451 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303452 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303453 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303454 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303455 }
3456
Govind Singh67922e82016-04-01 16:48:57 +05303457 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303458}
3459
3460/**
3461 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3462 * on a channel
3463 * @wmi_handle: pointer to the wmi handle
3464 * @timing_advert: pointer to the timing advertisement struct
3465 *
3466 * Return: 0 on succes
3467 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303468static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303469 struct ocb_timing_advert_param *timing_advert)
3470{
Govind Singh67922e82016-04-01 16:48:57 +05303471 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303472 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3473 uint8_t *buf_ptr;
3474 uint32_t len;
3475 wmi_buf_t buf;
3476
3477 len = sizeof(*cmd);
3478 buf = wmi_buf_alloc(wmi_handle, len);
3479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303480 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303481 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303482 }
3483
3484 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3485 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3486 WMITLV_SET_HDR(&cmd->tlv_header,
3487 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3488 WMITLV_GET_STRUCT_TLVLEN(
3489 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3490 cmd->vdev_id = timing_advert->vdev_id;
3491 cmd->channel_freq = timing_advert->chan_freq;
3492
3493 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3494 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303495 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303496 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303497 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303498 }
3499
Govind Singh67922e82016-04-01 16:48:57 +05303500 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303501}
3502
3503/**
3504 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3505 * @wmi_handle: pointer to the wmi handle
3506 * @request: pointer to the request
3507 *
3508 * Return: 0 on succes
3509 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303510static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303511 uint8_t vdev_id)
3512{
Govind Singhb53420c2016-03-09 14:32:57 +05303513 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303514 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3515 uint8_t *buf_ptr;
3516 wmi_buf_t buf;
3517 int32_t len;
3518
3519 len = sizeof(*cmd);
3520 buf = wmi_buf_alloc(wmi_handle, len);
3521 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303522 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303523 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303524 }
3525 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3526
3527 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303528 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303529 WMITLV_SET_HDR(&cmd->tlv_header,
3530 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3531 WMITLV_GET_STRUCT_TLVLEN(
3532 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3533 cmd->vdev_id = vdev_id;
3534
3535 /* Send the WMI command */
3536 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3537 WMI_OCB_GET_TSF_TIMER_CMDID);
3538 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303539 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303540 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303541 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303542 }
3543
Govind Singh67922e82016-04-01 16:48:57 +05303544 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303545}
3546
3547/**
3548 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3549 * @wmi_handle: pointer to the wmi handle
3550 * @get_stats_param: pointer to the dcc stats
3551 *
3552 * Return: 0 on succes
3553 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303554static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303555 struct dcc_get_stats_param *get_stats_param)
3556{
Govind Singh67922e82016-04-01 16:48:57 +05303557 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303558 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3559 wmi_dcc_channel_stats_request *channel_stats_array;
3560 wmi_buf_t buf;
3561 uint8_t *buf_ptr;
3562 uint32_t len;
3563 uint32_t i;
3564
3565 /* Validate the input */
3566 if (get_stats_param->request_array_len !=
3567 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303568 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303569 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303570 }
3571
3572 /* Allocate memory for the WMI command */
3573 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3574 get_stats_param->request_array_len;
3575
3576 buf = wmi_buf_alloc(wmi_handle, len);
3577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303578 WMI_LOGE(FL("wmi_buf_alloc failed"));
3579 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303580 }
3581
3582 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303583 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303584
3585 /* Populate the WMI command */
3586 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3587 buf_ptr += sizeof(*cmd);
3588
3589 WMITLV_SET_HDR(&cmd->tlv_header,
3590 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3591 WMITLV_GET_STRUCT_TLVLEN(
3592 wmi_dcc_get_stats_cmd_fixed_param));
3593 cmd->vdev_id = get_stats_param->vdev_id;
3594 cmd->num_channels = get_stats_param->channel_count;
3595
3596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3597 get_stats_param->request_array_len);
3598 buf_ptr += WMI_TLV_HDR_SIZE;
3599
3600 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303601 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303602 get_stats_param->request_array_len);
3603 for (i = 0; i < cmd->num_channels; i++)
3604 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3605 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3606 WMITLV_GET_STRUCT_TLVLEN(
3607 wmi_dcc_channel_stats_request));
3608
3609 /* Send the WMI command */
3610 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3611 WMI_DCC_GET_STATS_CMDID);
3612
Govind Singh67922e82016-04-01 16:48:57 +05303613 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303614 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303615 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303616 }
3617
Govind Singh67922e82016-04-01 16:48:57 +05303618 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303619}
3620
3621/**
3622 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3623 * @wmi_handle: pointer to the wmi handle
3624 * @vdev_id: vdev id
3625 * @dcc_stats_bitmap: dcc status bitmap
3626 *
3627 * Return: 0 on succes
3628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303629static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303630 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3631{
Govind Singh67922e82016-04-01 16:48:57 +05303632 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303633 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3634 wmi_buf_t buf;
3635 uint8_t *buf_ptr;
3636 uint32_t len;
3637
3638 /* Allocate memory for the WMI command */
3639 len = sizeof(*cmd);
3640
3641 buf = wmi_buf_alloc(wmi_handle, len);
3642 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303643 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303644 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303645 }
3646
3647 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303648 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303649
3650 /* Populate the WMI command */
3651 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3652
3653 WMITLV_SET_HDR(&cmd->tlv_header,
3654 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3655 WMITLV_GET_STRUCT_TLVLEN(
3656 wmi_dcc_clear_stats_cmd_fixed_param));
3657 cmd->vdev_id = vdev_id;
3658 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3659
3660 /* Send the WMI command */
3661 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3662 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303663 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303664 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303665 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303666 }
3667
Govind Singh67922e82016-04-01 16:48:57 +05303668 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303669}
3670
3671/**
3672 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3673 * @wmi_handle: pointer to the wmi handle
3674 * @update_ndl_param: pointer to the request parameters
3675 *
3676 * Return: 0 on success
3677 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303678static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303679 struct dcc_update_ndl_param *update_ndl_param)
3680{
Govind Singhb53420c2016-03-09 14:32:57 +05303681 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303682 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3683 wmi_dcc_ndl_chan *ndl_chan_array;
3684 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3685 uint32_t active_state_count;
3686 wmi_buf_t buf;
3687 uint8_t *buf_ptr;
3688 uint32_t len;
3689 uint32_t i;
3690
3691 /* validate the input */
3692 if (update_ndl_param->dcc_ndl_chan_list_len !=
3693 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303694 WMI_LOGE(FL("Invalid parameter"));
3695 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303696 }
3697 active_state_count = 0;
3698 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3699 for (i = 0; i < update_ndl_param->channel_count; i++)
3700 active_state_count +=
3701 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3702 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3703 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303704 WMI_LOGE(FL("Invalid parameter"));
3705 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303706 }
3707
3708 /* Allocate memory for the WMI command */
3709 len = sizeof(*cmd) +
3710 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3711 WMI_TLV_HDR_SIZE +
3712 update_ndl_param->dcc_ndl_active_state_list_len;
3713
3714 buf = wmi_buf_alloc(wmi_handle, len);
3715 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303716 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303717 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303718 }
3719
3720 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303721 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303722
3723 /* Populate the WMI command */
3724 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3725 buf_ptr += sizeof(*cmd);
3726
3727 WMITLV_SET_HDR(&cmd->tlv_header,
3728 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3729 WMITLV_GET_STRUCT_TLVLEN(
3730 wmi_dcc_update_ndl_cmd_fixed_param));
3731 cmd->vdev_id = update_ndl_param->vdev_id;
3732 cmd->num_channel = update_ndl_param->channel_count;
3733
3734 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3735 update_ndl_param->dcc_ndl_chan_list_len);
3736 buf_ptr += WMI_TLV_HDR_SIZE;
3737
3738 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303739 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303740 update_ndl_param->dcc_ndl_chan_list_len);
3741 for (i = 0; i < cmd->num_channel; i++)
3742 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3743 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3744 WMITLV_GET_STRUCT_TLVLEN(
3745 wmi_dcc_ndl_chan));
3746 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3747
3748 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3749 update_ndl_param->dcc_ndl_active_state_list_len);
3750 buf_ptr += WMI_TLV_HDR_SIZE;
3751
3752 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303753 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303754 update_ndl_param->dcc_ndl_active_state_list,
3755 update_ndl_param->dcc_ndl_active_state_list_len);
3756 for (i = 0; i < active_state_count; i++) {
3757 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3758 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3759 WMITLV_GET_STRUCT_TLVLEN(
3760 wmi_dcc_ndl_active_state_config));
3761 }
3762 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3763
3764 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303765 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303766 WMI_DCC_UPDATE_NDL_CMDID);
3767 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303768 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303769 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303770 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303771 }
3772
Govind Singh67922e82016-04-01 16:48:57 +05303773 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303774}
3775
3776/**
3777 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3778 * @wmi_handle: pointer to the wmi handle
3779 * @config: the OCB configuration
3780 *
3781 * Return: 0 on success
3782 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303783static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303784 struct ocb_config_param *config, uint32_t *ch_mhz)
3785{
Govind Singh67922e82016-04-01 16:48:57 +05303786 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303787 wmi_ocb_set_config_cmd_fixed_param *cmd;
3788 wmi_channel *chan;
3789 wmi_ocb_channel *ocb_chan;
3790 wmi_qos_parameter *qos_param;
3791 wmi_dcc_ndl_chan *ndl_chan;
3792 wmi_dcc_ndl_active_state_config *ndl_active_config;
3793 wmi_ocb_schedule_element *sched_elem;
3794 uint8_t *buf_ptr;
3795 wmi_buf_t buf;
3796 int32_t len;
3797 int32_t i, j, active_state_count;
3798
3799 /*
3800 * Validate the dcc_ndl_chan_list_len and count the number of active
3801 * states. Validate dcc_ndl_active_state_list_len.
3802 */
3803 active_state_count = 0;
3804 if (config->dcc_ndl_chan_list_len) {
3805 if (!config->dcc_ndl_chan_list ||
3806 config->dcc_ndl_chan_list_len !=
3807 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303808 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303809 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303810 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303811 }
3812
3813 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3814 i < config->channel_count; ++i, ++ndl_chan)
3815 active_state_count +=
3816 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3817
3818 if (active_state_count) {
3819 if (!config->dcc_ndl_active_state_list ||
3820 config->dcc_ndl_active_state_list_len !=
3821 active_state_count *
3822 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303823 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303824 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303825 }
3826 }
3827 }
3828
3829 len = sizeof(*cmd) +
3830 WMI_TLV_HDR_SIZE + config->channel_count *
3831 sizeof(wmi_channel) +
3832 WMI_TLV_HDR_SIZE + config->channel_count *
3833 sizeof(wmi_ocb_channel) +
3834 WMI_TLV_HDR_SIZE + config->channel_count *
3835 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3836 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3837 WMI_TLV_HDR_SIZE + active_state_count *
3838 sizeof(wmi_dcc_ndl_active_state_config) +
3839 WMI_TLV_HDR_SIZE + config->schedule_size *
3840 sizeof(wmi_ocb_schedule_element);
3841 buf = wmi_buf_alloc(wmi_handle, len);
3842 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303843 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303844 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303845 }
3846
3847 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3848 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3849 WMITLV_SET_HDR(&cmd->tlv_header,
3850 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3851 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3852 cmd->vdev_id = config->session_id;
3853 cmd->channel_count = config->channel_count;
3854 cmd->schedule_size = config->schedule_size;
3855 cmd->flags = config->flags;
3856 buf_ptr += sizeof(*cmd);
3857
3858 /* Add the wmi_channel info */
3859 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3860 config->channel_count*sizeof(wmi_channel));
3861 buf_ptr += WMI_TLV_HDR_SIZE;
3862 for (i = 0; i < config->channel_count; i++) {
3863 chan = (wmi_channel *)buf_ptr;
3864 WMITLV_SET_HDR(&chan->tlv_header,
3865 WMITLV_TAG_STRUC_wmi_channel,
3866 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3867 chan->mhz = config->channels[i].chan_freq;
3868 chan->band_center_freq1 = config->channels[i].chan_freq;
3869 chan->band_center_freq2 = 0;
3870 chan->info = 0;
3871
3872 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3873 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3874 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3875 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3876 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3877 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3878 config->channels[i].antenna_max);
3879
3880 if (config->channels[i].bandwidth < 10)
3881 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3882 else if (config->channels[i].bandwidth < 20)
3883 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3884 buf_ptr += sizeof(*chan);
3885 }
3886
3887 /* Add the wmi_ocb_channel info */
3888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3889 config->channel_count*sizeof(wmi_ocb_channel));
3890 buf_ptr += WMI_TLV_HDR_SIZE;
3891 for (i = 0; i < config->channel_count; i++) {
3892 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3893 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3894 WMITLV_TAG_STRUC_wmi_ocb_channel,
3895 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3896 ocb_chan->bandwidth = config->channels[i].bandwidth;
3897 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3898 config->channels[i].mac_address.bytes,
3899 &ocb_chan->mac_address);
3900 buf_ptr += sizeof(*ocb_chan);
3901 }
3902
3903 /* Add the wmi_qos_parameter info */
3904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3905 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3906 buf_ptr += WMI_TLV_HDR_SIZE;
3907 /* WMI_MAX_NUM_AC parameters for each channel */
3908 for (i = 0; i < config->channel_count; i++) {
3909 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3910 qos_param = (wmi_qos_parameter *)buf_ptr;
3911 WMITLV_SET_HDR(&qos_param->tlv_header,
3912 WMITLV_TAG_STRUC_wmi_qos_parameter,
3913 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3914 qos_param->aifsn =
3915 config->channels[i].qos_params[j].aifsn;
3916 qos_param->cwmin =
3917 config->channels[i].qos_params[j].cwmin;
3918 qos_param->cwmax =
3919 config->channels[i].qos_params[j].cwmax;
3920 buf_ptr += sizeof(*qos_param);
3921 }
3922 }
3923
3924 /* Add the wmi_dcc_ndl_chan (per channel) */
3925 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3926 config->dcc_ndl_chan_list_len);
3927 buf_ptr += WMI_TLV_HDR_SIZE;
3928 if (config->dcc_ndl_chan_list_len) {
3929 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303930 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303931 config->dcc_ndl_chan_list_len);
3932 for (i = 0; i < config->channel_count; i++)
3933 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3934 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3935 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3936 buf_ptr += config->dcc_ndl_chan_list_len;
3937 }
3938
3939 /* Add the wmi_dcc_ndl_active_state_config */
3940 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3941 sizeof(wmi_dcc_ndl_active_state_config));
3942 buf_ptr += WMI_TLV_HDR_SIZE;
3943 if (active_state_count) {
3944 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303945 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303946 config->dcc_ndl_active_state_list,
3947 active_state_count * sizeof(*ndl_active_config));
3948 for (i = 0; i < active_state_count; ++i)
3949 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3950 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3951 WMITLV_GET_STRUCT_TLVLEN(
3952 wmi_dcc_ndl_active_state_config));
3953 buf_ptr += active_state_count *
3954 sizeof(*ndl_active_config);
3955 }
3956
3957 /* Add the wmi_ocb_schedule_element info */
3958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3959 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3960 buf_ptr += WMI_TLV_HDR_SIZE;
3961 for (i = 0; i < config->schedule_size; i++) {
3962 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3963 WMITLV_SET_HDR(&sched_elem->tlv_header,
3964 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3965 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3966 sched_elem->channel_freq = config->schedule[i].chan_freq;
3967 sched_elem->total_duration = config->schedule[i].total_duration;
3968 sched_elem->guard_interval = config->schedule[i].guard_interval;
3969 buf_ptr += sizeof(*sched_elem);
3970 }
3971
3972
3973 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3974 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303975 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303976 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303977 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303978 }
3979
Govind Singh67922e82016-04-01 16:48:57 +05303980 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303981}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303982
3983/**
3984 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3985 * @wmi_handle: wmi handle
3986 * @mcc_adaptive_scheduler: enable/disable
3987 *
3988 * This function enable/disable mcc adaptive scheduler in fw.
3989 *
Govind Singhb53420c2016-03-09 14:32:57 +05303990 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303991 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303992static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003993 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3994 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303995{
Govind Singh67922e82016-04-01 16:48:57 +05303996 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303997 wmi_buf_t buf = 0;
3998 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3999 uint16_t len =
4000 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4001
4002 buf = wmi_buf_alloc(wmi_handle, len);
4003 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304004 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4005 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304006 }
4007 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4008 wmi_buf_data(buf);
4009
4010 WMITLV_SET_HDR(&cmd->tlv_header,
4011 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4012 WMITLV_GET_STRUCT_TLVLEN
4013 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4014 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304015 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304016
4017 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4018 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304019 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304020 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304021 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304022 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304023 }
Govind Singh67922e82016-04-01 16:48:57 +05304024
4025 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304026}
4027
4028/**
4029 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4030 * @wmi: wmi handle
4031 * @mcc_channel: mcc channel
4032 * @mcc_channel_time_latency: MCC channel time latency.
4033 *
4034 * Currently used to set time latency for an MCC vdev/adapter using operating
4035 * channel of it and channel number. The info is provided run time using
4036 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4037 *
4038 * Return: CDF status
4039 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304040static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304041 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4042{
Govind Singh67922e82016-04-01 16:48:57 +05304043 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304044 wmi_buf_t buf = 0;
4045 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4046 uint16_t len = 0;
4047 uint8_t *buf_ptr = NULL;
4048 wmi_resmgr_chan_latency chan_latency;
4049 /* Note: we only support MCC time latency for a single channel */
4050 uint32_t num_channels = 1;
4051 uint32_t chan1_freq = mcc_channel_freq;
4052 uint32_t latency_chan1 = mcc_channel_time_latency;
4053
4054
4055 /* If 0ms latency is provided, then FW will set to a default.
4056 * Otherwise, latency must be at least 30ms.
4057 */
4058 if ((latency_chan1 > 0) &&
4059 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304060 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304061 "Minimum is 30ms (or 0 to use default value by "
4062 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304063 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304064 }
4065
4066 /* Set WMI CMD for channel time latency here */
4067 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4068 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4069 num_channels * sizeof(wmi_resmgr_chan_latency);
4070 buf = wmi_buf_alloc(wmi_handle, len);
4071 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304072 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4073 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304074 }
4075 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4076 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4077 wmi_buf_data(buf);
4078 WMITLV_SET_HDR(&cmdTL->tlv_header,
4079 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4080 WMITLV_GET_STRUCT_TLVLEN
4081 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4082 cmdTL->num_chans = num_channels;
4083 /* Update channel time latency information for home channel(s) */
4084 buf_ptr += sizeof(*cmdTL);
4085 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4086 num_channels * sizeof(wmi_resmgr_chan_latency));
4087 buf_ptr += WMI_TLV_HDR_SIZE;
4088 chan_latency.chan_mhz = chan1_freq;
4089 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304090 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304091 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4092 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304093 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304094 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304095 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304096 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304097 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304098 }
Govind Singh67922e82016-04-01 16:48:57 +05304099
4100 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304101}
4102
4103/**
4104 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4105 * @wmi: wmi handle
4106 * @adapter_1_chan_number: adapter 1 channel number
4107 * @adapter_1_quota: adapter 1 quota
4108 * @adapter_2_chan_number: adapter 2 channel number
4109 *
4110 * Return: CDF status
4111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304112static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304113 uint32_t adapter_1_chan_freq,
4114 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4115{
Govind Singh67922e82016-04-01 16:48:57 +05304116 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304117 wmi_buf_t buf = 0;
4118 uint16_t len = 0;
4119 uint8_t *buf_ptr = NULL;
4120 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4121 wmi_resmgr_chan_time_quota chan_quota;
4122 uint32_t quota_chan1 = adapter_1_quota;
4123 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4124 uint32_t quota_chan2 = 100 - quota_chan1;
4125 /* Note: setting time quota for MCC requires info for 2 channels */
4126 uint32_t num_channels = 2;
4127 uint32_t chan1_freq = adapter_1_chan_freq;
4128 uint32_t chan2_freq = adapter_2_chan_freq;
4129
Govind Singhb53420c2016-03-09 14:32:57 +05304130 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304131 "freq2:%dMHz, Quota2:%dms", __func__,
4132 chan1_freq, quota_chan1, chan2_freq,
4133 quota_chan2);
4134
4135 /*
4136 * Perform sanity check on time quota values provided.
4137 */
4138 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4139 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304140 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304141 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304142 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304143 }
4144 /* Set WMI CMD for channel time quota here */
4145 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4146 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4147 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4148 buf = wmi_buf_alloc(wmi_handle, len);
4149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304150 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4151 QDF_ASSERT(0);
4152 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304153 }
4154 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4155 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4156 wmi_buf_data(buf);
4157 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4158 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4159 WMITLV_GET_STRUCT_TLVLEN
4160 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4161 cmdTQ->num_chans = num_channels;
4162
4163 /* Update channel time quota information for home channel(s) */
4164 buf_ptr += sizeof(*cmdTQ);
4165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4166 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4167 buf_ptr += WMI_TLV_HDR_SIZE;
4168 chan_quota.chan_mhz = chan1_freq;
4169 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304170 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304171 /* Construct channel and quota record for the 2nd MCC mode. */
4172 buf_ptr += sizeof(chan_quota);
4173 chan_quota.chan_mhz = chan2_freq;
4174 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304175 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304176
4177 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4178 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304179 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304180 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304181 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304182 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304183 }
Govind Singh67922e82016-04-01 16:48:57 +05304184
4185 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304186}
4187
4188/**
4189 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4190 * @wmi_handle: Pointer to wmi handle
4191 * @thermal_info: Thermal command information
4192 *
4193 * This function sends the thermal management command
4194 * to the firmware
4195 *
Govind Singhb53420c2016-03-09 14:32:57 +05304196 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304197 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304198static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304199 struct thermal_cmd_params *thermal_info)
4200{
4201 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4202 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304203 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304204 uint32_t len = 0;
4205
4206 len = sizeof(*cmd);
4207
4208 buf = wmi_buf_alloc(wmi_handle, len);
4209 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304210 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4211 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304212 }
4213
4214 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4215
4216 WMITLV_SET_HDR(&cmd->tlv_header,
4217 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4218 WMITLV_GET_STRUCT_TLVLEN
4219 (wmi_thermal_mgmt_cmd_fixed_param));
4220
4221 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4222 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4223 cmd->enable = thermal_info->thermal_enable;
4224
Govind Singhb53420c2016-03-09 14:32:57 +05304225 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304226 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4227
4228 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4229 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304230 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304231 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304232 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304233 }
4234
Govind Singh67922e82016-04-01 16:48:57 +05304235 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304236}
4237
4238
4239/**
4240 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304241 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304242 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4243 *
4244 * This function sends down the LRO configuration parameters to
4245 * the firmware to enable LRO, sets the TCP flags and sets the
4246 * seed values for the toeplitz hash generation
4247 *
Govind Singhb53420c2016-03-09 14:32:57 +05304248 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304249 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304250static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304251 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4252{
4253 wmi_lro_info_cmd_fixed_param *cmd;
4254 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304255 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304256
4257
4258 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4259 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304260 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4261 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304262 }
4263
4264 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4265
4266 WMITLV_SET_HDR(&cmd->tlv_header,
4267 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4268 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4269
4270 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4271 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4272 wmi_lro_cmd->tcp_flag);
4273 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4274 wmi_lro_cmd->tcp_flag_mask);
4275 cmd->toeplitz_hash_ipv4_0_3 =
4276 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4277 cmd->toeplitz_hash_ipv4_4_7 =
4278 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4279 cmd->toeplitz_hash_ipv4_8_11 =
4280 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4281 cmd->toeplitz_hash_ipv4_12_15 =
4282 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4283 cmd->toeplitz_hash_ipv4_16 =
4284 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4285
4286 cmd->toeplitz_hash_ipv6_0_3 =
4287 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4288 cmd->toeplitz_hash_ipv6_4_7 =
4289 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4290 cmd->toeplitz_hash_ipv6_8_11 =
4291 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4292 cmd->toeplitz_hash_ipv6_12_15 =
4293 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4294 cmd->toeplitz_hash_ipv6_16_19 =
4295 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4296 cmd->toeplitz_hash_ipv6_20_23 =
4297 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4298 cmd->toeplitz_hash_ipv6_24_27 =
4299 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4300 cmd->toeplitz_hash_ipv6_28_31 =
4301 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4302 cmd->toeplitz_hash_ipv6_32_35 =
4303 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4304 cmd->toeplitz_hash_ipv6_36_39 =
4305 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4306 cmd->toeplitz_hash_ipv6_40 =
4307 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4308
Govind Singhb53420c2016-03-09 14:32:57 +05304309 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304310 cmd->lro_enable, cmd->tcp_flag_u32);
4311
4312 status = wmi_unified_cmd_send(wmi_handle, buf,
4313 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304314 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304315 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304316 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304317 }
4318
Govind Singh67922e82016-04-01 16:48:57 +05304319 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304320}
4321
Govind Singh4eacd2b2016-03-07 14:24:22 +05304322/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304323 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4324 * @wmi_handle: Pointer to wmi handle
4325 * @rate_report_params: Pointer to peer rate report parameters
4326 *
4327 *
4328 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4329 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304330static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304331 struct wmi_peer_rate_report_params *rate_report_params)
4332{
4333 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4334 wmi_buf_t buf = NULL;
4335 QDF_STATUS status = 0;
4336 uint32_t len = 0;
4337 uint32_t i, j;
4338
4339 len = sizeof(*cmd);
4340
4341 buf = wmi_buf_alloc(wmi_handle, len);
4342 if (!buf) {
4343 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4344 return QDF_STATUS_E_FAILURE;
4345 }
4346
4347 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4348 wmi_buf_data(buf);
4349
4350 WMITLV_SET_HDR(
4351 &cmd->tlv_header,
4352 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4353 WMITLV_GET_STRUCT_TLVLEN(
4354 wmi_peer_set_rate_report_condition_fixed_param));
4355
4356 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4357 cmd->report_backoff_time = rate_report_params->backoff_time;
4358 cmd->report_timer_period = rate_report_params->timer_period;
4359 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4360 cmd->cond_per_phy[i].val_cond_flags =
4361 rate_report_params->report_per_phy[i].cond_flags;
4362 cmd->cond_per_phy[i].rate_delta.min_delta =
4363 rate_report_params->report_per_phy[i].delta.delta_min;
4364 cmd->cond_per_phy[i].rate_delta.percentage =
4365 rate_report_params->report_per_phy[i].delta.percent;
4366 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4367 cmd->cond_per_phy[i].rate_threshold[j] =
4368 rate_report_params->report_per_phy[i].
4369 report_rate_threshold[j];
4370 }
4371 }
4372
4373 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4374 cmd->enable_rate_report,
4375 cmd->report_backoff_time, cmd->report_timer_period);
4376
4377 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4378 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4379 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304380 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304381 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4382 __func__);
4383 }
4384 return status;
4385}
4386
4387/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304388 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4389 * @wmi_handle: wmi handle
4390 * @param: bcn ll cmd parameter
4391 *
Govind Singhb53420c2016-03-09 14:32:57 +05304392 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304393 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304394static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304395 wmi_bcn_send_from_host_cmd_fixed_param *param)
4396{
4397 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4398 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304399 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304400
4401 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4402 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304403 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4404 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304405 }
4406
4407 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4408 WMITLV_SET_HDR(&cmd->tlv_header,
4409 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4410 WMITLV_GET_STRUCT_TLVLEN
4411 (wmi_bcn_send_from_host_cmd_fixed_param));
4412 cmd->vdev_id = param->vdev_id;
4413 cmd->data_len = param->data_len;
4414 cmd->frame_ctrl = param->frame_ctrl;
4415 cmd->frag_ptr = param->frag_ptr;
4416 cmd->dtim_flag = param->dtim_flag;
4417
4418 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4419 WMI_PDEV_SEND_BCN_CMDID);
4420
Govind Singh67922e82016-04-01 16:48:57 +05304421 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304422 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304423 wmi_buf_free(wmi_buf);
4424 }
4425
4426 return ret;
4427}
4428
4429/**
4430 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4431 * @wmi_handle: wmi handle
4432 * @vdev_id: vdev id
4433 * @max_retries: max retries
4434 * @retry_interval: retry interval
4435 * This function sets sta query related parameters in fw.
4436 *
Govind Singhb53420c2016-03-09 14:32:57 +05304437 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304438 */
4439
Sathish Kumarfd347372017-02-13 12:29:09 +05304440static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304441 uint8_t vdev_id, uint32_t max_retries,
4442 uint32_t retry_interval)
4443{
4444 wmi_buf_t buf;
4445 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4446 int len;
4447
4448 len = sizeof(*cmd);
4449 buf = wmi_buf_alloc(wmi_handle, len);
4450 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304451 WMI_LOGE(FL("wmi_buf_alloc failed"));
4452 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304453 }
4454
4455 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4456 WMITLV_SET_HDR(&cmd->tlv_header,
4457 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4458 WMITLV_GET_STRUCT_TLVLEN
4459 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4460
4461
4462 cmd->vdev_id = vdev_id;
4463 cmd->sa_query_max_retry_count = max_retries;
4464 cmd->sa_query_retry_interval = retry_interval;
4465
Govind Singhb53420c2016-03-09 14:32:57 +05304466 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304467 vdev_id, retry_interval, max_retries);
4468
4469 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4470 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304471 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304472 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304473 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304474 }
4475
Govind Singhb53420c2016-03-09 14:32:57 +05304476 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304477 return 0;
4478}
4479
4480/**
4481 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4482 * @wmi_handle: wmi handle
4483 * @params: sta keep alive parameter
4484 *
4485 * This function sets keep alive related parameters in fw.
4486 *
4487 * Return: CDF status
4488 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304489static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304490 struct sta_params *params)
4491{
4492 wmi_buf_t buf;
4493 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4494 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4495 uint8_t *buf_ptr;
4496 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304497 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304498
Govind Singhb53420c2016-03-09 14:32:57 +05304499 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304500
Govind Singh4eacd2b2016-03-07 14:24:22 +05304501 len = sizeof(*cmd) + sizeof(*arp_rsp);
4502 buf = wmi_buf_alloc(wmi_handle, len);
4503 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304504 WMI_LOGE("wmi_buf_alloc failed");
4505 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304506 }
4507
4508 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4509 buf_ptr = (uint8_t *) cmd;
4510 WMITLV_SET_HDR(&cmd->tlv_header,
4511 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4512 WMITLV_GET_STRUCT_TLVLEN
4513 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4514 cmd->interval = params->timeperiod;
4515 cmd->enable = (params->timeperiod) ? 1 : 0;
4516 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304517 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304518 params->timeperiod, params->method);
4519 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4520 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4521 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4522 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4523
4524 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4525 if ((NULL == params->hostv4addr) ||
4526 (NULL == params->destv4addr) ||
4527 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304528 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304529 "destv4addr:%p destmac:%p ", __func__,
4530 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304531 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304532 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304533 }
4534 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304535 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304536 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304537 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304538 WMI_IPV4_ADDR_LEN);
4539 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4540 } else {
4541 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4542 }
4543
Govind Singh67922e82016-04-01 16:48:57 +05304544 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4545 WMI_STA_KEEPALIVE_CMDID);
4546 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304547 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304548 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549 }
4550
Govind Singhb53420c2016-03-09 14:32:57 +05304551 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304552 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304553}
4554
4555/**
4556 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4557 * @wmi_handle: wmi handle
4558 * @if_id: vdev id
4559 * @gtx_info: GTX config params
4560 *
4561 * This function set GTX related params in firmware.
4562 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304565static 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 +05304566 struct wmi_gtx_config *gtx_info)
4567{
4568 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4569 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304570 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304571 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304572
Govind Singh4eacd2b2016-03-07 14:24:22 +05304573 buf = wmi_buf_alloc(wmi_handle, len);
4574 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304575 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304576 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304577 }
4578 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4579 WMITLV_SET_HDR(&cmd->tlv_header,
4580 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4581 WMITLV_GET_STRUCT_TLVLEN
4582 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4583 cmd->vdev_id = if_id;
4584
4585 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4586 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4587 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4588 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4589 cmd->gtxPERMargin = gtx_info->gtx_margin;
4590 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4591 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4592 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4593
Govind Singhb53420c2016-03-09 14:32:57 +05304594 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304595 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4596 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4597 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4598 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4599
Abhishek Singh716c46c2016-05-04 16:24:07 +05304600 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304601 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304602 if (QDF_IS_STATUS_ERROR(ret)) {
4603 WMI_LOGE("Failed to set GTX PARAMS");
4604 wmi_buf_free(buf);
4605 }
4606 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304607}
4608
4609/**
4610 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4611 * @wmi_handle: wmi handle
4612 * @edca_params: edca parameters
4613 *
4614 * This function updates EDCA parameters to the target
4615 *
4616 * Return: CDF Status
4617 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304618static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304619 uint8_t vdev_id,
4620 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4621{
4622 uint8_t *buf_ptr;
4623 wmi_buf_t buf;
4624 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4625 wmi_wmm_vparams *wmm_param, *twmm_param;
4626 int len = sizeof(*cmd);
4627 int ac;
4628
4629 buf = wmi_buf_alloc(wmi_handle, len);
4630
4631 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304632 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4633 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634 }
4635
4636 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4637 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4638 WMITLV_SET_HDR(&cmd->tlv_header,
4639 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4640 WMITLV_GET_STRUCT_TLVLEN
4641 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4642 cmd->vdev_id = vdev_id;
4643
4644 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4645 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4646 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4647 WMITLV_SET_HDR(&wmm_param->tlv_header,
4648 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4649 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4650 wmm_param->cwmin = twmm_param->cwmin;
4651 wmm_param->cwmax = twmm_param->cwmax;
4652 wmm_param->aifs = twmm_param->aifs;
4653 wmm_param->txoplimit = twmm_param->txoplimit;
4654 wmm_param->acm = twmm_param->acm;
4655 wmm_param->no_ack = twmm_param->no_ack;
4656 }
4657
4658 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4659 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4660 goto fail;
4661
Govind Singhb53420c2016-03-09 14:32:57 +05304662 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304663
4664fail:
4665 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304666 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4667 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304668}
4669
4670/**
4671 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4672 * @wmi_handle: wmi handle
4673 * @vdev_id: vdev id
4674 * @probe_rsp_info: probe response info
4675 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304676 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304677 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304678static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304679 uint8_t vdev_id,
4680 struct wmi_probe_resp_params *probe_rsp_info,
4681 uint8_t *frm)
4682{
4683 wmi_prb_tmpl_cmd_fixed_param *cmd;
4684 wmi_bcn_prb_info *bcn_prb_info;
4685 wmi_buf_t wmi_buf;
4686 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4687 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304688 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304689
Govind Singhb53420c2016-03-09 14:32:57 +05304690 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304691
4692 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4693 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4694
4695 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4696 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4697 tmpl_len_aligned;
4698
4699 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304700 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304701 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304702 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304703 }
4704
4705 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4706 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304707 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304708 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304709 }
4710
4711 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4712
4713 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4714 WMITLV_SET_HDR(&cmd->tlv_header,
4715 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4716 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4717 cmd->vdev_id = vdev_id;
4718 cmd->buf_len = tmpl_len;
4719 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4720
4721 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4722 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4723 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4724 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4725 bcn_prb_info->caps = 0;
4726 bcn_prb_info->erp = 0;
4727 buf_ptr += sizeof(wmi_bcn_prb_info);
4728
4729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4730 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304731 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304732
4733 ret = wmi_unified_cmd_send(wmi_handle,
4734 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304735 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304736 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304737 wmi_buf_free(wmi_buf);
4738 }
4739
4740 return ret;
4741}
4742
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304743#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304744#define WPI_IV_LEN 16
4745
4746/**
4747 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4748 *
4749 * @dest_tx: destination address of tsc key counter
4750 * @src_tx: source address of tsc key counter
4751 * @dest_rx: destination address of rsc key counter
4752 * @src_rx: source address of rsc key counter
4753 *
4754 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4755 *
4756 * Return: None
4757 *
4758 */
4759static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4760 uint8_t *dest_rx, uint8_t *src_rx)
4761{
4762 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4763 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4764}
4765#else
4766static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4767 uint8_t *dest_rx, uint8_t *src_rx)
4768{
4769 return;
4770}
4771#endif
4772
4773/**
4774 * send_setup_install_key_cmd_tlv() - set key parameters
4775 * @wmi_handle: wmi handle
4776 * @key_params: key parameters
4777 *
4778 * This function fills structure from information
4779 * passed in key_params.
4780 *
4781 * Return: QDF_STATUS_SUCCESS - success
4782 * QDF_STATUS_E_FAILURE - failure
4783 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4784 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304785static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304786 struct set_key_params *key_params)
4787{
4788 wmi_vdev_install_key_cmd_fixed_param *cmd;
4789 wmi_buf_t buf;
4790 uint8_t *buf_ptr;
4791 uint32_t len;
4792 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304793 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304794
4795 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4796 WMI_TLV_HDR_SIZE;
4797
4798 buf = wmi_buf_alloc(wmi_handle, len);
4799 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304800 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304801 return QDF_STATUS_E_NOMEM;
4802 }
4803
4804 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4805 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4806 WMITLV_SET_HDR(&cmd->tlv_header,
4807 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4808 WMITLV_GET_STRUCT_TLVLEN
4809 (wmi_vdev_install_key_cmd_fixed_param));
4810 cmd->vdev_id = key_params->vdev_id;
4811 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304812
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304813
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304814 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4815 cmd->key_flags |= key_params->key_flags;
4816 cmd->key_cipher = key_params->key_cipher;
4817 if ((key_params->key_txmic_len) &&
4818 (key_params->key_rxmic_len)) {
4819 cmd->key_txmic_len = key_params->key_txmic_len;
4820 cmd->key_rxmic_len = key_params->key_rxmic_len;
4821 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304822#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304823 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4824 key_params->tx_iv,
4825 cmd->wpi_key_rsc_counter,
4826 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304827#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304828 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4829 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4830 roundup(key_params->key_len, sizeof(uint32_t)));
4831 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4832 qdf_mem_copy((void *)key_data,
4833 (const void *)key_params->key_data, key_params->key_len);
4834 cmd->key_len = key_params->key_len;
4835
4836 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4837 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304838 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304839 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304840
Govind Singh67922e82016-04-01 16:48:57 +05304841 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304842}
4843
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304844/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004845 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4846 * @wmi_handle: wmi handle
4847 * @params: sar limit params
4848 *
4849 * Return: QDF_STATUS_SUCCESS for success or error code
4850 */
4851static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4852 struct sar_limit_cmd_params *sar_limit_params)
4853{
4854 wmi_buf_t buf;
4855 QDF_STATUS qdf_status;
4856 wmi_sar_limits_cmd_fixed_param *cmd;
4857 int i;
4858 uint8_t *buf_ptr;
4859 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4860 struct sar_limit_cmd_row *sar_rows_list;
4861 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4862
4863 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4864 buf = wmi_buf_alloc(wmi_handle, len);
4865 if (!buf) {
4866 WMI_LOGE("Failed to allocate memory");
4867 qdf_status = QDF_STATUS_E_NOMEM;
4868 goto end;
4869 }
4870
4871 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4872 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4873 WMITLV_SET_HDR(&cmd->tlv_header,
4874 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4875 WMITLV_GET_STRUCT_TLVLEN
4876 (wmi_sar_limits_cmd_fixed_param));
4877 cmd->sar_enable = sar_limit_params->sar_enable;
4878 cmd->commit_limits = sar_limit_params->commit_limits;
4879 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4880
4881 WMI_LOGD("no of sar rows = %d, len = %d",
4882 sar_limit_params->num_limit_rows, len);
4883 buf_ptr += sizeof(*cmd);
4884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4885 sizeof(wmi_sar_limit_cmd_row) *
4886 sar_limit_params->num_limit_rows);
4887 if (cmd->num_limit_rows == 0)
4888 goto send_sar_limits;
4889
4890 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4891 (buf_ptr + WMI_TLV_HDR_SIZE);
4892 sar_rows_list = sar_limit_params->sar_limit_row_list;
4893
4894 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4895 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4896 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4897 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4898 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4899 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4900 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4901 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4902 wmi_sar_rows_list->validity_bitmap =
4903 sar_rows_list->validity_bitmap;
4904 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4905 i, wmi_sar_rows_list->band_id,
4906 wmi_sar_rows_list->chain_id,
4907 wmi_sar_rows_list->mod_id,
4908 wmi_sar_rows_list->limit_value,
4909 wmi_sar_rows_list->validity_bitmap);
4910 sar_rows_list++;
4911 wmi_sar_rows_list++;
4912 }
4913send_sar_limits:
4914 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4915 WMI_SAR_LIMITS_CMDID);
4916
4917 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4918 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4919 wmi_buf_free(buf);
4920 }
4921
4922end:
4923 return qdf_status;
4924}
4925
4926/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304927 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4928 * @wmi_handle: wmi handle
4929 * @params: encrypt/decrypt params
4930 *
4931 * Return: QDF_STATUS_SUCCESS for success or error code
4932 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004933static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304934QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4935 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4936{
4937 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4938 wmi_buf_t wmi_buf;
4939 uint8_t *buf_ptr;
4940 QDF_STATUS ret;
4941 uint32_t len;
4942
4943 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4944
4945 len = sizeof(*cmd) +
4946 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4947 WMI_TLV_HDR_SIZE;
4948 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4949 if (!wmi_buf) {
4950 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4951 __func__);
4952 return QDF_STATUS_E_NOMEM;
4953 }
4954
4955 buf_ptr = wmi_buf_data(wmi_buf);
4956 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4957
4958 WMITLV_SET_HDR(&cmd->tlv_header,
4959 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4960 WMITLV_GET_STRUCT_TLVLEN(
4961 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4962
4963 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4964 cmd->key_flag = encrypt_decrypt_params->key_flag;
4965 cmd->key_idx = encrypt_decrypt_params->key_idx;
4966 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4967 cmd->key_len = encrypt_decrypt_params->key_len;
4968 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4969 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4970
4971 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4972 encrypt_decrypt_params->key_len);
4973
4974 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4975 MAX_MAC_HEADER_LEN);
4976
4977 cmd->data_len = encrypt_decrypt_params->data_len;
4978
4979 if (cmd->data_len) {
4980 buf_ptr += sizeof(*cmd);
4981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4982 roundup(encrypt_decrypt_params->data_len,
4983 sizeof(A_UINT32)));
4984 buf_ptr += WMI_TLV_HDR_SIZE;
4985 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4986 encrypt_decrypt_params->data_len);
4987 }
4988
4989 /* This conversion is to facilitate data to FW in little endian */
4990 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4991 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4992 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4993 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4994 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4995 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4996
4997 ret = wmi_unified_cmd_send(wmi_handle,
4998 wmi_buf, len,
4999 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5000 if (QDF_IS_STATUS_ERROR(ret)) {
5001 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5002 wmi_buf_free(wmi_buf);
5003 }
5004
5005 return ret;
5006}
5007
5008
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305009
Govind Singh4eacd2b2016-03-07 14:24:22 +05305010/**
5011 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5012 * @wmi_handle: wmi handle
5013 * @vdev_id: vdev id
5014 * @p2p_ie: p2p IE
5015 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305016 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305017 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305018static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305019 A_UINT32 vdev_id, uint8_t *p2p_ie)
5020{
Govind Singh67922e82016-04-01 16:48:57 +05305021 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305022 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5023 wmi_buf_t wmi_buf;
5024 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5025 uint8_t *buf_ptr;
5026
5027 ie_len = (uint32_t) (p2p_ie[1] + 2);
5028
5029 /* More than one P2P IE may be included in a single frame.
5030 If multiple P2P IEs are present, the complete P2P attribute
5031 data consists of the concatenation of the P2P Attribute
5032 fields of the P2P IEs. The P2P Attributes field of each
5033 P2P IE may be any length up to the maximum (251 octets).
5034 In this case host sends one P2P IE to firmware so the length
5035 should not exceed more than 251 bytes
5036 */
5037 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305038 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305039 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305040 }
5041
5042 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5043
5044 wmi_buf_len =
5045 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5046 WMI_TLV_HDR_SIZE;
5047
5048 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5049 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305050 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305051 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305052 }
5053
5054 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5055
5056 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5057 WMITLV_SET_HDR(&cmd->tlv_header,
5058 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5059 WMITLV_GET_STRUCT_TLVLEN
5060 (wmi_p2p_go_set_beacon_ie_fixed_param));
5061 cmd->vdev_id = vdev_id;
5062 cmd->ie_buf_len = ie_len;
5063
5064 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5065 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5066 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305067 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305068
Govind Singhb53420c2016-03-09 14:32:57 +05305069 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305070
5071 ret = wmi_unified_cmd_send(wmi_handle,
5072 wmi_buf, wmi_buf_len,
5073 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305074 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305075 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305076 wmi_buf_free(wmi_buf);
5077 }
5078
Govind Singhb53420c2016-03-09 14:32:57 +05305079 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305080 return ret;
5081}
5082
5083/**
5084 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5085 * @wmi_handle: wmi handle
5086 * @req: gateway parameter update request structure
5087 *
5088 * This function reads the incoming @req and fill in the destination
5089 * WMI structure and sends down the gateway configs down to the firmware
5090 *
Govind Singhb53420c2016-03-09 14:32:57 +05305091 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305092 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305093static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305094 struct gateway_update_req_param *req)
5095{
5096 wmi_roam_subnet_change_config_fixed_param *cmd;
5097 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305098 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305099 int len = sizeof(*cmd);
5100
5101 buf = wmi_buf_alloc(wmi_handle, len);
5102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305103 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5104 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305105 }
5106
5107 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5108 WMITLV_SET_HDR(&cmd->tlv_header,
5109 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5110 WMITLV_GET_STRUCT_TLVLEN(
5111 wmi_roam_subnet_change_config_fixed_param));
5112
5113 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305114 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5115 QDF_IPV4_ADDR_SIZE);
5116 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5117 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305118 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5119 &cmd->inet_gw_mac_addr);
5120 cmd->max_retries = req->max_retries;
5121 cmd->timeout = req->timeout;
5122 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5123 cmd->flag = 0;
5124 if (req->ipv4_addr_type)
5125 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5126
5127 if (req->ipv6_addr_type)
5128 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5129
5130 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5131 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305132 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305133 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305134 ret);
5135 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305136 }
5137
Govind Singh67922e82016-04-01 16:48:57 +05305138 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305139}
5140
5141/**
5142 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5143 * @wmi_handle: wmi handle
5144 * @req: rssi monitoring request structure
5145 *
5146 * This function reads the incoming @req and fill in the destination
5147 * WMI structure and send down the rssi monitoring configs down to the firmware
5148 *
5149 * Return: 0 on success; error number otherwise
5150 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305151static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305152 struct rssi_monitor_param *req)
5153{
5154 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5155 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305156 QDF_STATUS ret;
5157 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305158
5159 buf = wmi_buf_alloc(wmi_handle, len);
5160 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305161 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5162 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305163 }
5164
5165 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5166 WMITLV_SET_HDR(&cmd->tlv_header,
5167 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5168 WMITLV_GET_STRUCT_TLVLEN(
5169 wmi_rssi_breach_monitor_config_fixed_param));
5170
5171 cmd->vdev_id = req->session_id;
5172 cmd->request_id = req->request_id;
5173 cmd->lo_rssi_reenable_hysteresis = 0;
5174 cmd->hi_rssi_reenable_histeresis = 0;
5175 cmd->min_report_interval = 0;
5176 cmd->max_num_report = 1;
5177 if (req->control) {
5178 /* enable one threshold for each min/max */
5179 cmd->enabled_bitmap = 0x09;
5180 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5181 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5182 } else {
5183 cmd->enabled_bitmap = 0;
5184 cmd->low_rssi_breach_threshold[0] = 0;
5185 cmd->hi_rssi_breach_threshold[0] = 0;
5186 }
5187
5188 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5189 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305190 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305191 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305193 }
5194
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005195 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5196
Govind Singh67922e82016-04-01 16:48:57 +05305197 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305198}
5199
5200/**
5201 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5202 * @wmi_handle: wmi handle
5203 * @psetoui: OUI parameters
5204 *
5205 * set scan probe OUI parameters in firmware
5206 *
5207 * Return: CDF status
5208 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305209static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305210 struct scan_mac_oui *psetoui)
5211{
5212 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5213 wmi_buf_t wmi_buf;
5214 uint32_t len;
5215 uint8_t *buf_ptr;
5216 uint32_t *oui_buf;
5217
5218 len = sizeof(*cmd);
5219 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5220 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305221 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5222 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305223 }
5224 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5225 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5226 WMITLV_SET_HDR(&cmd->tlv_header,
5227 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5228 WMITLV_GET_STRUCT_TLVLEN
5229 (wmi_scan_prob_req_oui_cmd_fixed_param));
5230
5231 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305232 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5234 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305235 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305236 cmd->prob_req_oui);
5237
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305238 cmd->vdev_id = psetoui->vdev_id;
5239 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5240 if (psetoui->enb_probe_req_sno_randomization)
5241 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5242
Govind Singh4eacd2b2016-03-07 14:24:22 +05305243 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5244 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305245 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305246 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305247 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305248 }
Govind Singhb53420c2016-03-09 14:32:57 +05305249 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305250}
5251
5252/**
5253 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5254 * @wmi_handle: wmi handle
5255 * @req: passpoint network request structure
5256 *
5257 * This function sends down WMI command with network id set to wildcard id.
5258 * firmware shall clear all the config entries
5259 *
Govind Singhb53420c2016-03-09 14:32:57 +05305260 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305262static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305263 struct wifi_passpoint_req_param *req)
5264{
5265 wmi_passpoint_config_cmd_fixed_param *cmd;
5266 wmi_buf_t buf;
5267 uint32_t len;
5268 int ret;
5269
5270 len = sizeof(*cmd);
5271 buf = wmi_buf_alloc(wmi_handle, len);
5272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305273 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5274 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305275 }
5276
5277 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5278
5279 WMITLV_SET_HDR(&cmd->tlv_header,
5280 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5281 WMITLV_GET_STRUCT_TLVLEN(
5282 wmi_passpoint_config_cmd_fixed_param));
5283 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5284
5285 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5286 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5287 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305288 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305289 __func__);
5290 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305291 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305292 }
5293
Govind Singhb53420c2016-03-09 14:32:57 +05305294 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305295}
5296
5297/**
5298 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5299 * @wmi_handle: wmi handle
5300 * @req: passpoint network request structure
5301 *
5302 * This function reads the incoming @req and fill in the destination
5303 * WMI structure and send down the passpoint configs down to the firmware
5304 *
Govind Singhb53420c2016-03-09 14:32:57 +05305305 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305306 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305307static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308 struct wifi_passpoint_req_param *req)
5309{
5310 wmi_passpoint_config_cmd_fixed_param *cmd;
5311 u_int8_t i, j, *bytes;
5312 wmi_buf_t buf;
5313 uint32_t len;
5314 int ret;
5315
5316 len = sizeof(*cmd);
5317 for (i = 0; i < req->num_networks; i++) {
5318 buf = wmi_buf_alloc(wmi_handle, len);
5319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305320 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5321 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305322 }
5323
5324 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5325 wmi_buf_data(buf);
5326
5327 WMITLV_SET_HDR(&cmd->tlv_header,
5328 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5329 WMITLV_GET_STRUCT_TLVLEN(
5330 wmi_passpoint_config_cmd_fixed_param));
5331 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305332 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5333 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305334 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305335 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305336 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5337 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305338 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305339 j, bytes[0], bytes[1], bytes[2], bytes[3],
5340 bytes[4], bytes[5], bytes[6], bytes[7]);
5341
Govind Singhb53420c2016-03-09 14:32:57 +05305342 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305343 &req->networks[i].roaming_consortium_ids[j],
5344 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5345 }
Govind Singhb53420c2016-03-09 14:32:57 +05305346 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305347 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305348 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305349 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5350
5351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5352 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5353 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305354 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305355 __func__);
5356 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305357 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305358 }
5359 }
5360
Govind Singhb53420c2016-03-09 14:32:57 +05305361 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305362}
5363
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305364/**
5365 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5366 * @wmi_handle: wmi handle
5367 * @scan_cmd_fp: start scan command ptr
5368 * @roam_req: roam request param
5369 *
5370 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5371 * of WMI_ROAM_SCAN_MODE.
5372 *
5373 * Return: QDF status
5374 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305375static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305376 wmi_start_scan_cmd_fixed_param *
5377 scan_cmd_fp,
5378 struct roam_offload_scan_params *roam_req)
5379{
5380 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305381 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305382 int len;
5383 uint8_t *buf_ptr;
5384 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305385
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305386#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5387 int auth_mode = roam_req->auth_mode;
5388 wmi_roam_offload_tlv_param *roam_offload_params;
5389 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5390 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5391 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305392 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305393#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5394 /* Need to create a buf with roam_scan command at
5395 * front and piggyback with scan command */
5396 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5397#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5398 (2 * WMI_TLV_HDR_SIZE) +
5399#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5400 sizeof(wmi_start_scan_cmd_fixed_param);
5401#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5402 if (roam_req->is_roam_req_valid &&
5403 roam_req->roam_offload_enabled) {
5404 len += sizeof(wmi_roam_offload_tlv_param);
5405 len += WMI_TLV_HDR_SIZE;
5406 if ((auth_mode != WMI_AUTH_NONE) &&
5407 ((auth_mode != WMI_AUTH_OPEN) ||
5408 (auth_mode == WMI_AUTH_OPEN &&
5409 roam_req->mdid.mdie_present) ||
5410 roam_req->is_ese_assoc)) {
5411 len += WMI_TLV_HDR_SIZE;
5412 if (roam_req->is_ese_assoc)
5413 len +=
5414 sizeof(wmi_roam_ese_offload_tlv_param);
5415 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5416 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5417 (auth_mode == WMI_AUTH_OPEN &&
5418 roam_req->mdid.mdie_present))
5419 len +=
5420 sizeof(wmi_roam_11r_offload_tlv_param);
5421 else
5422 len +=
5423 sizeof(wmi_roam_11i_offload_tlv_param);
5424 } else {
5425 len += WMI_TLV_HDR_SIZE;
5426 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305427
5428 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5429 + roundup(roam_req->assoc_ie_length,
5430 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305431 } else {
5432 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305433 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305434 __func__, roam_req->roam_offload_enabled);
5435 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305436 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305437 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305438 }
5439 if (roam_req->is_roam_req_valid &&
5440 roam_req->roam_offload_enabled) {
5441 roam_req->mode = roam_req->mode |
5442 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5443 }
5444#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5445
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305446 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5447 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5448 len = sizeof(wmi_roam_scan_mode_fixed_param);
5449
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305450 buf = wmi_buf_alloc(wmi_handle, len);
5451 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305452 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305453 return QDF_STATUS_E_NOMEM;
5454 }
5455
5456 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305457
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305458 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5459 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5460 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5461 WMITLV_GET_STRUCT_TLVLEN
5462 (wmi_roam_scan_mode_fixed_param));
5463
5464 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5465 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305466 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5467 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5468 roam_scan_mode_fp->flags |=
5469 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305470 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305471 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305472
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305473 /* Fill in scan parameters suitable for roaming scan */
5474 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305475
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305476 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5477 sizeof(wmi_start_scan_cmd_fixed_param));
5478 /* Ensure there is no additional IEs */
5479 scan_cmd_fp->ie_len = 0;
5480 WMITLV_SET_HDR(buf_ptr,
5481 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5482 WMITLV_GET_STRUCT_TLVLEN
5483 (wmi_start_scan_cmd_fixed_param));
5484#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5485 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5486 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5487 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5488 sizeof(wmi_roam_offload_tlv_param));
5489 buf_ptr += WMI_TLV_HDR_SIZE;
5490 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5491 WMITLV_SET_HDR(buf_ptr,
5492 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5493 WMITLV_GET_STRUCT_TLVLEN
5494 (wmi_roam_offload_tlv_param));
5495 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5496 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5497 roam_offload_params->select_5g_margin =
5498 roam_req->select_5ghz_margin;
5499 roam_offload_params->reassoc_failure_timeout =
5500 roam_req->reassoc_failure_timeout;
5501
5502 /* Fill the capabilities */
5503 roam_offload_params->capability =
5504 roam_req->roam_offload_params.capability;
5505 roam_offload_params->ht_caps_info =
5506 roam_req->roam_offload_params.ht_caps_info;
5507 roam_offload_params->ampdu_param =
5508 roam_req->roam_offload_params.ampdu_param;
5509 roam_offload_params->ht_ext_cap =
5510 roam_req->roam_offload_params.ht_ext_cap;
5511 roam_offload_params->ht_txbf =
5512 roam_req->roam_offload_params.ht_txbf;
5513 roam_offload_params->asel_cap =
5514 roam_req->roam_offload_params.asel_cap;
5515 roam_offload_params->qos_caps =
5516 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005517 roam_offload_params->qos_enabled =
5518 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305519 roam_offload_params->wmm_caps =
5520 roam_req->roam_offload_params.wmm_caps;
5521 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5522 (uint8_t *)roam_req->roam_offload_params.mcsset,
5523 ROAM_OFFLOAD_NUM_MCS_SET);
5524
5525 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5526 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5527 * they are filled in the same order.Depending on the
5528 * authentication type, the other mode TLV's are nullified
5529 * and only headers are filled.*/
5530 if ((auth_mode != WMI_AUTH_NONE) &&
5531 ((auth_mode != WMI_AUTH_OPEN) ||
5532 (auth_mode == WMI_AUTH_OPEN
5533 && roam_req->mdid.mdie_present) ||
5534 roam_req->is_ese_assoc)) {
5535 if (roam_req->is_ese_assoc) {
5536 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5537 WMITLV_GET_STRUCT_TLVLEN(0));
5538 buf_ptr += WMI_TLV_HDR_SIZE;
5539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5540 WMITLV_GET_STRUCT_TLVLEN(0));
5541 buf_ptr += WMI_TLV_HDR_SIZE;
5542 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5543 sizeof(wmi_roam_ese_offload_tlv_param));
5544 buf_ptr += WMI_TLV_HDR_SIZE;
5545 roam_offload_ese =
5546 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5547 qdf_mem_copy(roam_offload_ese->krk,
5548 roam_req->krk,
5549 sizeof(roam_req->krk));
5550 qdf_mem_copy(roam_offload_ese->btk,
5551 roam_req->btk,
5552 sizeof(roam_req->btk));
5553 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5554 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5555 WMITLV_GET_STRUCT_TLVLEN
5556 (wmi_roam_ese_offload_tlv_param));
5557 buf_ptr +=
5558 sizeof(wmi_roam_ese_offload_tlv_param);
5559 } else if (auth_mode == WMI_AUTH_FT_RSNA
5560 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5561 || (auth_mode == WMI_AUTH_OPEN
5562 && roam_req->mdid.mdie_present)) {
5563 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5564 0);
5565 buf_ptr += WMI_TLV_HDR_SIZE;
5566 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5567 sizeof(wmi_roam_11r_offload_tlv_param));
5568 buf_ptr += WMI_TLV_HDR_SIZE;
5569 roam_offload_11r =
5570 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5571 roam_offload_11r->r0kh_id_len =
5572 roam_req->rokh_id_length;
5573 qdf_mem_copy(roam_offload_11r->r0kh_id,
5574 roam_req->rokh_id,
5575 roam_offload_11r->r0kh_id_len);
5576 qdf_mem_copy(roam_offload_11r->psk_msk,
5577 roam_req->psk_pmk,
5578 sizeof(roam_req->psk_pmk));
5579 roam_offload_11r->psk_msk_len =
5580 roam_req->pmk_len;
5581 roam_offload_11r->mdie_present =
5582 roam_req->mdid.mdie_present;
5583 roam_offload_11r->mdid =
5584 roam_req->mdid.mobility_domain;
5585 if (auth_mode == WMI_AUTH_OPEN) {
5586 /* If FT-Open ensure pmk length
5587 and r0khid len are zero */
5588 roam_offload_11r->r0kh_id_len = 0;
5589 roam_offload_11r->psk_msk_len = 0;
5590 }
5591 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5592 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5593 WMITLV_GET_STRUCT_TLVLEN
5594 (wmi_roam_11r_offload_tlv_param));
5595 buf_ptr +=
5596 sizeof(wmi_roam_11r_offload_tlv_param);
5597 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5598 WMITLV_GET_STRUCT_TLVLEN(0));
5599 buf_ptr += WMI_TLV_HDR_SIZE;
5600 } else {
5601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5602 sizeof(wmi_roam_11i_offload_tlv_param));
5603 buf_ptr += WMI_TLV_HDR_SIZE;
5604 roam_offload_11i =
5605 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005606
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005607 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005608 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305609 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5610 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005611 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305612 } else {
5613 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5614 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005615 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005616 }
5617 if (roam_req->roam_key_mgmt_offload_enabled &&
5618 roam_req->fw_pmksa_cache) {
5619 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
5620 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005621 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08005622 } else {
5623 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
5624 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07005625 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305626 }
5627
5628 qdf_mem_copy(roam_offload_11i->pmk,
5629 roam_req->psk_pmk,
5630 sizeof(roam_req->psk_pmk));
5631 roam_offload_11i->pmk_len = roam_req->pmk_len;
5632 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5633 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5634 WMITLV_GET_STRUCT_TLVLEN
5635 (wmi_roam_11i_offload_tlv_param));
5636 buf_ptr +=
5637 sizeof(wmi_roam_11i_offload_tlv_param);
5638 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5639 0);
5640 buf_ptr += WMI_TLV_HDR_SIZE;
5641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5642 0);
5643 buf_ptr += WMI_TLV_HDR_SIZE;
5644 }
5645 } else {
5646 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5647 WMITLV_GET_STRUCT_TLVLEN(0));
5648 buf_ptr += WMI_TLV_HDR_SIZE;
5649 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5650 WMITLV_GET_STRUCT_TLVLEN(0));
5651 buf_ptr += WMI_TLV_HDR_SIZE;
5652 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5653 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305654 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305655 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305656
5657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5658 sizeof(*assoc_ies));
5659 buf_ptr += WMI_TLV_HDR_SIZE;
5660
5661 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5662 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5663 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5664 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5665 assoc_ies->buf_len = roam_req->assoc_ie_length;
5666
5667 buf_ptr += sizeof(*assoc_ies);
5668
5669 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5670 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5671 buf_ptr += WMI_TLV_HDR_SIZE;
5672
5673 if (assoc_ies->buf_len != 0) {
5674 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5675 assoc_ies->buf_len);
5676 }
5677
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305678 } else {
5679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5680 WMITLV_GET_STRUCT_TLVLEN(0));
5681 buf_ptr += WMI_TLV_HDR_SIZE;
5682 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5683 WMITLV_GET_STRUCT_TLVLEN(0));
5684 buf_ptr += WMI_TLV_HDR_SIZE;
5685 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5686 WMITLV_GET_STRUCT_TLVLEN(0));
5687 buf_ptr += WMI_TLV_HDR_SIZE;
5688 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5689 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305690 buf_ptr += WMI_TLV_HDR_SIZE;
5691 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5692 WMITLV_GET_STRUCT_TLVLEN(0));
5693 buf_ptr += WMI_TLV_HDR_SIZE;
5694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5695 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305696 }
5697#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305698
5699send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305700 status = wmi_unified_cmd_send(wmi_handle, buf,
5701 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305702 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305703 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305704 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5705 status);
5706 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305707 }
5708
Govind Singh67922e82016-04-01 16:48:57 +05305709 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305710}
5711
5712
5713/**
5714 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5715 * rssi threashold
5716 * @wmi_handle: wmi handle
5717 * @roam_req: Roaming request buffer
5718 *
5719 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5720 *
5721 * Return: QDF status
5722 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305723static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305724 struct roam_offload_scan_rssi_params *roam_req)
5725{
5726 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305727 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305728 int len;
5729 uint8_t *buf_ptr;
5730 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5731 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5732 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305733 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305734
5735 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5736 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5737 len += sizeof(wmi_roam_scan_extended_threshold_param);
5738 len += WMI_TLV_HDR_SIZE;
5739 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305740 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5741 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305742 buf = wmi_buf_alloc(wmi_handle, len);
5743 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305744 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305745 return QDF_STATUS_E_NOMEM;
5746 }
5747
5748 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5749 rssi_threshold_fp =
5750 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5751 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5752 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5753 WMITLV_GET_STRUCT_TLVLEN
5754 (wmi_roam_scan_rssi_threshold_fixed_param));
5755 /* fill in threshold values */
5756 rssi_threshold_fp->vdev_id = roam_req->session_id;
5757 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5758 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5759 rssi_threshold_fp->hirssi_scan_max_count =
5760 roam_req->hi_rssi_scan_max_count;
5761 rssi_threshold_fp->hirssi_scan_delta =
5762 roam_req->hi_rssi_scan_rssi_delta;
5763 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5764
5765 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5766 WMITLV_SET_HDR(buf_ptr,
5767 WMITLV_TAG_ARRAY_STRUC,
5768 sizeof(wmi_roam_scan_extended_threshold_param));
5769 buf_ptr += WMI_TLV_HDR_SIZE;
5770 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5771
5772 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5773 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5774 ext_thresholds->boost_threshold_5g =
5775 roam_req->boost_threshold_5g;
5776
5777 ext_thresholds->boost_algorithm_5g =
5778 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5779 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5780 ext_thresholds->penalty_algorithm_5g =
5781 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5782 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5783 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5784 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5785 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5786
5787 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5788 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5789 WMITLV_GET_STRUCT_TLVLEN
5790 (wmi_roam_scan_extended_threshold_param));
5791 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5792 WMITLV_SET_HDR(buf_ptr,
5793 WMITLV_TAG_ARRAY_STRUC,
5794 sizeof(wmi_roam_earlystop_rssi_thres_param));
5795 buf_ptr += WMI_TLV_HDR_SIZE;
5796 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5797 early_stop_thresholds->roam_earlystop_thres_min =
5798 roam_req->roam_earlystop_thres_min;
5799 early_stop_thresholds->roam_earlystop_thres_max =
5800 roam_req->roam_earlystop_thres_max;
5801 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5802 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5803 WMITLV_GET_STRUCT_TLVLEN
5804 (wmi_roam_earlystop_rssi_thres_param));
5805
Gupta, Kapil7e652922016-04-12 15:02:00 +05305806 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5808 sizeof(wmi_roam_dense_thres_param));
5809 buf_ptr += WMI_TLV_HDR_SIZE;
5810 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5811 dense_thresholds->roam_dense_rssi_thres_offset =
5812 roam_req->dense_rssi_thresh_offset;
5813 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5814 dense_thresholds->roam_dense_traffic_thres =
5815 roam_req->traffic_threshold;
5816 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5817 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5818 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5819 WMITLV_GET_STRUCT_TLVLEN
5820 (wmi_roam_dense_thres_param));
5821
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305822 status = wmi_unified_cmd_send(wmi_handle, buf,
5823 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305824 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305825 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305826 status);
5827 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305828 }
5829
Govind Singh67922e82016-04-01 16:48:57 +05305830 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305831}
5832
5833/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305834 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5835 * configuration params
5836 * @wma_handle: wma handler
5837 * @dwelltime_params: pointer to dwelltime_params
5838 *
5839 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5840 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005841static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305842QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5843 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5844{
5845 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5846 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5847 wmi_buf_t buf;
5848 uint8_t *buf_ptr;
5849 int32_t err;
5850 int len;
5851
5852 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5853 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5854 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5855 buf = wmi_buf_alloc(wmi_handle, len);
5856 if (!buf) {
5857 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5858 __func__);
5859 return QDF_STATUS_E_NOMEM;
5860 }
5861 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5862 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5863 WMITLV_SET_HDR(&dwell_param->tlv_header,
5864 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5865 WMITLV_GET_STRUCT_TLVLEN
5866 (wmi_scan_adaptive_dwell_config_fixed_param));
5867
5868 dwell_param->enable = dwelltime_params->is_enabled;
5869 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5870 WMITLV_SET_HDR(buf_ptr,
5871 WMITLV_TAG_ARRAY_STRUC,
5872 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5873 buf_ptr += WMI_TLV_HDR_SIZE;
5874
5875 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5876 WMITLV_SET_HDR(&cmd->tlv_header,
5877 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5878 WMITLV_GET_STRUCT_TLVLEN(
5879 wmi_scan_adaptive_dwell_parameters_tlv));
5880
5881 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5882 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5883 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5884 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5885 err = wmi_unified_cmd_send(wmi_handle, buf,
5886 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5887 if (err) {
5888 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5889 wmi_buf_free(buf);
5890 return QDF_STATUS_E_FAILURE;
5891 }
5892
5893 return QDF_STATUS_SUCCESS;
5894}
5895
Nitesh Shah52323d02017-05-22 15:49:00 +05305896/**
5897 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
5898 * configuration params
5899 * @wmi_handle: wmi handler
5900 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
5901 *
5902 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5903 */
5904static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
5905 struct wmi_dbs_scan_sel_params *dbs_scan_params)
5906{
5907 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
5908 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
5909 wmi_buf_t buf;
5910 uint8_t *buf_ptr;
5911 QDF_STATUS err;
5912 uint32_t i;
5913 int len;
5914
5915 len = sizeof(*dbs_scan_param);
5916 len += WMI_TLV_HDR_SIZE;
5917 len += dbs_scan_params->num_clients * sizeof(*cmd);
5918
5919 buf = wmi_buf_alloc(wmi_handle, len);
5920 if (!buf) {
5921 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
5922 return QDF_STATUS_E_NOMEM;
5923 }
5924
5925 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5926 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
5927 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
5928 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
5929 WMITLV_GET_STRUCT_TLVLEN
5930 (wmi_scan_dbs_duty_cycle_fixed_param));
5931
5932 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
5933 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
5934 buf_ptr += sizeof(*dbs_scan_param);
5935 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5936 (sizeof(*cmd) * dbs_scan_params->num_clients));
5937 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
5938
5939 for (i = 0; i < dbs_scan_params->num_clients; i++) {
5940 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
5941 WMITLV_SET_HDR(&cmd->tlv_header,
5942 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
5943 WMITLV_GET_STRUCT_TLVLEN(
5944 wmi_scan_dbs_duty_cycle_tlv_param));
5945 cmd->module_id = dbs_scan_params->module_id[i];
5946 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
5947 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
5948 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
5949 }
5950
5951 err = wmi_unified_cmd_send(wmi_handle, buf,
5952 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
5953 if (QDF_IS_STATUS_ERROR(err)) {
5954 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
5955 wmi_buf_free(buf);
5956 return QDF_STATUS_E_FAILURE;
5957 }
5958
5959 return QDF_STATUS_SUCCESS;
5960}
Gupta, Kapil2e685982016-04-25 19:14:19 +05305961
5962/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305963 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5964 * @wmi_handle: wmi handle
5965 * @roam_req: Request which contains the filters
5966 *
5967 * There are filters such as whitelist, blacklist and preferred
5968 * list that need to be applied to the scan results to form the
5969 * probable candidates for roaming.
5970 *
5971 * Return: Return success upon succesfully passing the
5972 * parameters to the firmware, otherwise failure.
5973 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305974static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305975 struct roam_scan_filter_params *roam_req)
5976{
5977 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305978 QDF_STATUS status;
5979 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05305980 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305981 uint8_t *buf_ptr;
5982 wmi_roam_filter_fixed_param *roam_filter;
5983 uint8_t *bssid_src_ptr = NULL;
5984 wmi_mac_addr *bssid_dst_ptr = NULL;
5985 wmi_ssid *ssid_ptr = NULL;
5986 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05305987 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05305988 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305989
5990 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05305991
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305992 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05305993 if (roam_req->num_bssid_black_list)
5994 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
5995 len += WMI_TLV_HDR_SIZE;
5996 if (roam_req->num_ssid_white_list)
5997 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
5998 len += 2 * WMI_TLV_HDR_SIZE;
5999 if (roam_req->num_bssid_preferred_list) {
6000 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6001 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6002 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306003 len += WMI_TLV_HDR_SIZE;
6004 if (roam_req->lca_disallow_config_present) {
6005 len += sizeof(*blist_param);
6006 blist_len = sizeof(*blist_param);
6007 }
6008
6009 len += WMI_TLV_HDR_SIZE;
6010 if (roam_req->num_rssi_rejection_ap)
6011 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306012
6013 buf = wmi_buf_alloc(wmi_handle, len);
6014 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306015 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306016 return QDF_STATUS_E_NOMEM;
6017 }
6018
6019 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6020 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6021 WMITLV_SET_HDR(&roam_filter->tlv_header,
6022 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6023 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6024 /* fill in fixed values */
6025 roam_filter->vdev_id = roam_req->session_id;
6026 roam_filter->flags = 0;
6027 roam_filter->op_bitmap = roam_req->op_bitmap;
6028 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6029 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6030 roam_filter->num_bssid_preferred_list =
6031 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306032 roam_filter->num_rssi_rejection_ap =
6033 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306034 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6035
6036 WMITLV_SET_HDR((buf_ptr),
6037 WMITLV_TAG_ARRAY_FIXED_STRUC,
6038 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6039 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6040 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6041 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6042 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6043 bssid_src_ptr += ATH_MAC_LEN;
6044 bssid_dst_ptr++;
6045 }
6046 buf_ptr += WMI_TLV_HDR_SIZE +
6047 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6048 WMITLV_SET_HDR((buf_ptr),
6049 WMITLV_TAG_ARRAY_FIXED_STRUC,
6050 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6051 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6052 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6053 qdf_mem_copy(&ssid_ptr->ssid,
6054 &roam_req->ssid_allowed_list[i].mac_ssid,
6055 roam_req->ssid_allowed_list[i].length);
6056 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6057 ssid_ptr++;
6058 }
6059 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6060 sizeof(wmi_ssid));
6061 WMITLV_SET_HDR((buf_ptr),
6062 WMITLV_TAG_ARRAY_FIXED_STRUC,
6063 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6064 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6065 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6066 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6067 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6068 (wmi_mac_addr *)bssid_dst_ptr);
6069 bssid_src_ptr += ATH_MAC_LEN;
6070 bssid_dst_ptr++;
6071 }
6072 buf_ptr += WMI_TLV_HDR_SIZE +
6073 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6074 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6075 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6076 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6077 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6078 *bssid_preferred_factor_ptr =
6079 roam_req->bssid_favored_factor[i];
6080 bssid_preferred_factor_ptr++;
6081 }
6082 buf_ptr += WMI_TLV_HDR_SIZE +
6083 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6084
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306085 WMITLV_SET_HDR(buf_ptr,
6086 WMITLV_TAG_ARRAY_STRUC, blist_len);
6087 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306088 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306089 blist_param =
6090 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6091 WMITLV_SET_HDR(&blist_param->tlv_header,
6092 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6093 WMITLV_GET_STRUCT_TLVLEN(
6094 wmi_roam_lca_disallow_config_tlv_param));
6095
6096 blist_param->disallow_duration = roam_req->disallow_duration;
6097 blist_param->rssi_channel_penalization =
6098 roam_req->rssi_channel_penalization;
6099 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
6100 blist_param->disallow_lca_enable_source_bitmap = 0x1;
6101 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6102 }
6103
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306104 WMITLV_SET_HDR(buf_ptr,
6105 WMITLV_TAG_ARRAY_STRUC,
6106 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6107 buf_ptr += WMI_TLV_HDR_SIZE;
6108 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6109 rssi_rej =
6110 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6111 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6112 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6113 WMITLV_GET_STRUCT_TLVLEN(
6114 wmi_roam_rssi_rejection_oce_config_param));
6115 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6116 roam_req->rssi_rejection_ap[i].bssid.bytes,
6117 &rssi_rej->bssid);
6118 rssi_rej->remaining_disallow_duration =
6119 roam_req->rssi_rejection_ap[i].remaining_duration;
6120 rssi_rej->requested_rssi =
6121 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
6122 buf_ptr +=
6123 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6124 }
6125
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306126 status = wmi_unified_cmd_send(wmi_handle, buf,
6127 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306128 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306129 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306130 status);
6131 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306132 }
Govind Singh67922e82016-04-01 16:48:57 +05306133
6134 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306135}
6136
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137/** send_set_epno_network_list_cmd_tlv() - set epno network list
6138 * @wmi_handle: wmi handle
6139 * @req: epno config params request structure
6140 *
6141 * This function reads the incoming epno config request structure
6142 * and constructs the WMI message to the firmware.
6143 *
6144 * Returns: 0 on success, error number otherwise
6145 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306146static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306147 struct wifi_enhanched_pno_params *req)
6148{
6149 wmi_nlo_config_cmd_fixed_param *cmd;
6150 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306151 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306152 u_int8_t i, *buf_ptr;
6153 wmi_buf_t buf;
6154 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05306155 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306156
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306157 /* Fixed Params */
6158 len = sizeof(*cmd);
6159 if (req->num_networks) {
6160 /* TLV place holder for array of structures
6161 * then each nlo_configured_parameters(nlo_list) TLV.
6162 */
6163 len += WMI_TLV_HDR_SIZE;
6164 len += (sizeof(nlo_configured_parameters)
6165 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
6166 /* TLV for array of uint32 channel_list */
6167 len += WMI_TLV_HDR_SIZE;
6168 /* TLV for nlo_channel_prediction_cfg */
6169 len += WMI_TLV_HDR_SIZE;
6170 /* TLV for candidate score params */
6171 len += sizeof(enlo_candidate_score_params);
6172 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05306173
6174 buf = wmi_buf_alloc(wmi_handle, len);
6175 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306176 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6177 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306178 }
6179
6180 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6181
6182 buf_ptr = (u_int8_t *) cmd;
6183 WMITLV_SET_HDR(&cmd->tlv_header,
6184 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6185 WMITLV_GET_STRUCT_TLVLEN(
6186 wmi_nlo_config_cmd_fixed_param));
6187 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306188
6189 /* set flag to reset if num of networks are 0 */
6190 cmd->flags = (req->num_networks == 0 ?
6191 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306192
6193 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6194
Govind Singhb53420c2016-03-09 14:32:57 +05306195 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306196 WMI_LOGD("SSID count: %d flags: %d",
6197 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306198
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306199 /* Fill nlo_config only when num_networks are non zero */
6200 if (cmd->no_of_ssids) {
6201 /* Fill networks */
6202 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6203 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6204 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306205
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306206 nlo_list = (nlo_configured_parameters *) buf_ptr;
6207 for (i = 0; i < cmd->no_of_ssids; i++) {
6208 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6209 WMITLV_TAG_ARRAY_BYTE,
6210 WMITLV_GET_STRUCT_TLVLEN(
6211 nlo_configured_parameters));
6212 /* Copy ssid and it's length */
6213 nlo_list[i].ssid.valid = true;
6214 nlo_list[i].ssid.ssid.ssid_len =
6215 req->networks[i].ssid.length;
6216 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
6217 req->networks[i].ssid.mac_ssid,
6218 nlo_list[i].ssid.ssid.ssid_len);
6219 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
6220 nlo_list[i].ssid.ssid.ssid_len,
6221 (char *) nlo_list[i].ssid.ssid.ssid,
6222 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306223
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306224 /* Copy pno flags */
6225 nlo_list[i].bcast_nw_type.valid = true;
6226 nlo_list[i].bcast_nw_type.bcast_nw_type =
6227 req->networks[i].flags;
6228 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306229 nlo_list[i].bcast_nw_type.bcast_nw_type);
6230
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306231 /* Copy auth bit field */
6232 nlo_list[i].auth_type.valid = true;
6233 nlo_list[i].auth_type.auth_type =
6234 req->networks[i].auth_bit_field;
6235 WMI_LOGD("Auth bit field (%u)",
6236 nlo_list[i].auth_type.auth_type);
6237 }
6238
6239 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6240 /* Fill the channel list */
6241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6242 buf_ptr += WMI_TLV_HDR_SIZE;
6243
6244 /* Fill prediction_param */
6245 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6246 buf_ptr += WMI_TLV_HDR_SIZE;
6247
6248 /* Fill epno candidate score params */
6249 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
6250 WMITLV_SET_HDR(buf_ptr,
6251 WMITLV_TAG_STRUC_enlo_candidate_score_param,
6252 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
6253 cand_score_params->min5GHz_rssi =
6254 req->min_5ghz_rssi;
6255 cand_score_params->min24GHz_rssi =
6256 req->min_24ghz_rssi;
6257 cand_score_params->initial_score_max =
6258 req->initial_score_max;
6259 cand_score_params->current_connection_bonus =
6260 req->current_connection_bonus;
6261 cand_score_params->same_network_bonus =
6262 req->same_network_bonus;
6263 cand_score_params->secure_bonus =
6264 req->secure_bonus;
6265 cand_score_params->band5GHz_bonus =
6266 req->band_5ghz_bonus;
6267 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306268 }
6269
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306271 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306272 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306273 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306274 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306275 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306276 }
6277
Govind Singhb53420c2016-03-09 14:32:57 +05306278 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306279 req->session_id);
6280
Govind Singh67922e82016-04-01 16:48:57 +05306281 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306282}
6283
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306284
Govind Singh4eacd2b2016-03-07 14:24:22 +05306285/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6286 * @wmi_handle: wmi handle
6287 * @ipa_offload: ipa offload control parameter
6288 *
6289 * Returns: 0 on success, error number otherwise
6290 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306291static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306292 struct ipa_offload_control_params *ipa_offload)
6293{
6294 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6295 wmi_buf_t wmi_buf;
6296 uint32_t len;
6297 u_int8_t *buf_ptr;
6298
6299 len = sizeof(*cmd);
6300 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6301 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306302 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6303 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306304 }
6305
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08006306 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306307 ipa_offload->offload_type, ipa_offload->enable);
6308
6309 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6310
6311 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6312 WMITLV_SET_HDR(&cmd->tlv_header,
6313 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6314 WMITLV_GET_STRUCT_TLVLEN(
6315 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6316
6317 cmd->offload_type = ipa_offload->offload_type;
6318 cmd->vdev_id = ipa_offload->vdev_id;
6319 cmd->enable = ipa_offload->enable;
6320
6321 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6322 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306323 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306324 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306325 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306326 }
6327
Govind Singhb53420c2016-03-09 14:32:57 +05306328 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306329}
6330
6331/**
6332 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6333 * @wmi_handle: wmi handle
6334 * @pgetcapab: get capabilities params
6335 *
6336 * This function send request to fw to get extscan capabilities.
6337 *
6338 * Return: CDF status
6339 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306340static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306341 struct extscan_capabilities_params *pgetcapab)
6342{
6343 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6344 wmi_buf_t wmi_buf;
6345 uint32_t len;
6346 uint8_t *buf_ptr;
6347
6348 len = sizeof(*cmd);
6349 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6350 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306351 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6352 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306353 }
6354 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6355
6356 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6357 WMITLV_SET_HDR(&cmd->tlv_header,
6358 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6359 WMITLV_GET_STRUCT_TLVLEN
6360 (wmi_extscan_get_capabilities_cmd_fixed_param));
6361
6362 cmd->request_id = pgetcapab->request_id;
6363
6364 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6365 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306366 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306367 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306368 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306369 }
Govind Singhb53420c2016-03-09 14:32:57 +05306370 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306371}
6372
6373/**
6374 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6375 * @wmi_handle: wmi handle
6376 * @pcached_results: cached results parameters
6377 *
6378 * This function send request to fw to get cached results.
6379 *
6380 * Return: CDF status
6381 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306382static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306383 struct extscan_cached_result_params *pcached_results)
6384{
6385 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6386 wmi_buf_t wmi_buf;
6387 uint32_t len;
6388 uint8_t *buf_ptr;
6389
6390 len = sizeof(*cmd);
6391 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6392 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306393 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6394 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306395 }
6396 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6397
6398 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6399 WMITLV_SET_HDR(&cmd->tlv_header,
6400 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6401 WMITLV_GET_STRUCT_TLVLEN
6402 (wmi_extscan_get_cached_results_cmd_fixed_param));
6403
6404 cmd->request_id = pcached_results->request_id;
6405 cmd->vdev_id = pcached_results->session_id;
6406 cmd->control_flags = pcached_results->flush;
6407
6408 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6409 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306410 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306411 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306412 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306413 }
Govind Singhb53420c2016-03-09 14:32:57 +05306414 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306415}
6416
6417/**
6418 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6419 * @wmi_handle: wmi handle
6420 * @reset_req: Reset change request params
6421 *
6422 * This function sends stop change monitor request to fw.
6423 *
6424 * Return: CDF status
6425 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306426static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306427 struct extscan_capabilities_reset_params *reset_req)
6428{
6429 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6430 wmi_buf_t wmi_buf;
6431 uint32_t len;
6432 uint8_t *buf_ptr;
6433 int change_list = 0;
6434
6435 len = sizeof(*cmd);
6436
6437 /* reset significant change tlv is set to 0 */
6438 len += WMI_TLV_HDR_SIZE;
6439 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6440 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6441 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306442 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6443 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 }
6445 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6446
6447 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6448 buf_ptr;
6449 WMITLV_SET_HDR(&cmd->tlv_header,
6450 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6451 WMITLV_GET_STRUCT_TLVLEN
6452 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6453
6454 cmd->request_id = reset_req->request_id;
6455 cmd->vdev_id = reset_req->session_id;
6456 cmd->mode = 0;
6457
6458 buf_ptr += sizeof(*cmd);
6459 WMITLV_SET_HDR(buf_ptr,
6460 WMITLV_TAG_ARRAY_STRUC,
6461 change_list *
6462 sizeof(wmi_extscan_wlan_change_bssid_param));
6463 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6464 sizeof
6465 (wmi_extscan_wlan_change_bssid_param));
6466
6467 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6468 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306469 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306470 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306471 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306472 }
Govind Singhb53420c2016-03-09 14:32:57 +05306473 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306474}
6475
6476/**
6477 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6478 * @wmi_handle: wmi handle
6479 * @psigchange: change monitor request params
6480 * @buf: wmi buffer
6481 * @buf_len: buffer length
6482 *
6483 * This function fills elements of change monitor request buffer.
6484 *
6485 * Return: CDF status
6486 */
Govind Singhb53420c2016-03-09 14:32:57 +05306487static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306488 struct extscan_set_sig_changereq_params
6489 *psigchange, wmi_buf_t *buf, int *buf_len)
6490{
6491 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6492 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6493 uint8_t *buf_ptr;
6494 int j;
6495 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006496 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306497 struct ap_threshold_params *src_ap = psigchange->ap;
6498
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006499 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306500 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6501 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306502 }
6503 len += WMI_TLV_HDR_SIZE;
6504 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6505
6506 *buf = wmi_buf_alloc(wmi_handle, len);
6507 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306509 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306510 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306511 }
6512 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6513 cmd =
6514 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6515 buf_ptr;
6516 WMITLV_SET_HDR(&cmd->tlv_header,
6517 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6518 WMITLV_GET_STRUCT_TLVLEN
6519 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6520
6521 cmd->request_id = psigchange->request_id;
6522 cmd->vdev_id = psigchange->session_id;
6523 cmd->total_entries = numap;
6524 cmd->mode = 1;
6525 cmd->num_entries_in_page = numap;
6526 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6527 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6528 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6529 cmd->max_out_of_range_count = psigchange->min_breaching;
6530
6531 buf_ptr += sizeof(*cmd);
6532 WMITLV_SET_HDR(buf_ptr,
6533 WMITLV_TAG_ARRAY_STRUC,
6534 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6535 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6536 (buf_ptr + WMI_TLV_HDR_SIZE);
6537
6538 for (j = 0; j < numap; j++) {
6539 WMITLV_SET_HDR(dest_chglist,
6540 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6541 WMITLV_GET_STRUCT_TLVLEN
6542 (wmi_extscan_wlan_change_bssid_param));
6543
6544 dest_chglist->lower_rssi_limit = src_ap->low;
6545 dest_chglist->upper_rssi_limit = src_ap->high;
6546 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6547 &dest_chglist->bssid);
6548
Govind Singhb53420c2016-03-09 14:32:57 +05306549 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306550 dest_chglist->lower_rssi_limit);
6551 dest_chglist++;
6552 src_ap++;
6553 }
6554 buf_ptr += WMI_TLV_HDR_SIZE +
6555 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6556 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306557 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306558}
6559
6560/**
6561 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6562 * @wmi_handle: wmi handle
6563 * @psigchange: change monitor request params
6564 *
6565 * This function sends start change monitor request to fw.
6566 *
6567 * Return: CDF status
6568 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306569static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306570 struct extscan_set_sig_changereq_params *
6571 psigchange)
6572{
Govind Singhb53420c2016-03-09 14:32:57 +05306573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306574 wmi_buf_t buf;
6575 int len;
6576
6577
Govind Singhb53420c2016-03-09 14:32:57 +05306578 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306579 psigchange, &buf,
6580 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306581 if (qdf_status != QDF_STATUS_SUCCESS) {
6582 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306583 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306584 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306585 }
6586 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306587 WMI_LOGE("%s: Failed to get buffer", __func__);
6588 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306589 }
6590 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6591 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306592 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306593 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306594 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306595 }
Govind Singhb53420c2016-03-09 14:32:57 +05306596 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306597}
6598
6599/**
6600 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6601 * @wmi_handle: wmi handle
6602 * @photlist_reset: hotlist reset params
6603 *
6604 * This function configures hotlist monitor to stop in fw.
6605 *
6606 * Return: CDF status
6607 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306608static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306609 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6610{
6611 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6612 wmi_buf_t wmi_buf;
6613 uint32_t len;
6614 uint8_t *buf_ptr;
6615 int hotlist_entries = 0;
6616
6617 len = sizeof(*cmd);
6618
6619 /* reset bssid hotlist with tlv set to 0 */
6620 len += WMI_TLV_HDR_SIZE;
6621 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6622
6623 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6624 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306625 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6626 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306627 }
6628
6629 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6630 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6631 buf_ptr;
6632 WMITLV_SET_HDR(&cmd->tlv_header,
6633 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6634 WMITLV_GET_STRUCT_TLVLEN
6635 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6636
6637 cmd->request_id = photlist_reset->request_id;
6638 cmd->vdev_id = photlist_reset->session_id;
6639 cmd->mode = 0;
6640
6641 buf_ptr += sizeof(*cmd);
6642 WMITLV_SET_HDR(buf_ptr,
6643 WMITLV_TAG_ARRAY_STRUC,
6644 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6645 buf_ptr += WMI_TLV_HDR_SIZE +
6646 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6647
6648 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6649 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306650 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306651 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306652 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306653 }
Govind Singhb53420c2016-03-09 14:32:57 +05306654 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306655}
6656
6657/**
6658 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6659 * @wmi_handle: wmi handle
6660 * @pstopcmd: stop scan command request params
6661 *
6662 * This function sends stop extscan request to fw.
6663 *
6664 * Return: CDF Status.
6665 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306666static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306667 struct extscan_stop_req_params *pstopcmd)
6668{
6669 wmi_extscan_stop_cmd_fixed_param *cmd;
6670 wmi_buf_t wmi_buf;
6671 uint32_t len;
6672 uint8_t *buf_ptr;
6673
6674 len = sizeof(*cmd);
6675 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6676 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306677 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6678 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306679 }
6680 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6681 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6682 WMITLV_SET_HDR(&cmd->tlv_header,
6683 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6684 WMITLV_GET_STRUCT_TLVLEN
6685 (wmi_extscan_stop_cmd_fixed_param));
6686
6687 cmd->request_id = pstopcmd->request_id;
6688 cmd->vdev_id = pstopcmd->session_id;
6689
6690 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6691 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306692 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306693 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306694 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306695 }
6696
Govind Singhb53420c2016-03-09 14:32:57 +05306697 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306698}
6699
6700/**
6701 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6702 * @wmi_handle: wmi handle
6703 * @pstart: scan command request params
6704 * @buf: event buffer
6705 * @buf_len: length of buffer
6706 *
6707 * This function fills individual elements of extscan request and
6708 * TLV for buckets, channel list.
6709 *
6710 * Return: CDF Status.
6711 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006712static
Govind Singhb53420c2016-03-09 14:32:57 +05306713QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306714 struct wifi_scan_cmd_req_params *pstart,
6715 wmi_buf_t *buf, int *buf_len)
6716{
6717 wmi_extscan_start_cmd_fixed_param *cmd;
6718 wmi_extscan_bucket *dest_blist;
6719 wmi_extscan_bucket_channel *dest_clist;
6720 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6721 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6722 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6723
6724 uint8_t *buf_ptr;
6725 int i, k, count = 0;
6726 int len = sizeof(*cmd);
6727 int nbuckets = pstart->numBuckets;
6728 int nchannels = 0;
6729
6730 /* These TLV's are are NULL by default */
6731 uint32_t ie_len_with_pad = 0;
6732 int num_ssid = 0;
6733 int num_bssid = 0;
6734 int ie_len = 0;
6735
6736 uint32_t base_period = pstart->basePeriod;
6737
6738 /* TLV placeholder for ssid_list (NULL) */
6739 len += WMI_TLV_HDR_SIZE;
6740 len += num_ssid * sizeof(wmi_ssid);
6741
6742 /* TLV placeholder for bssid_list (NULL) */
6743 len += WMI_TLV_HDR_SIZE;
6744 len += num_bssid * sizeof(wmi_mac_addr);
6745
6746 /* TLV placeholder for ie_data (NULL) */
6747 len += WMI_TLV_HDR_SIZE;
6748 len += ie_len * sizeof(uint32_t);
6749
6750 /* TLV placeholder for bucket */
6751 len += WMI_TLV_HDR_SIZE;
6752 len += nbuckets * sizeof(wmi_extscan_bucket);
6753
6754 /* TLV channel placeholder */
6755 len += WMI_TLV_HDR_SIZE;
6756 for (i = 0; i < nbuckets; i++) {
6757 nchannels += src_bucket->numChannels;
6758 src_bucket++;
6759 }
6760
Govind Singhb53420c2016-03-09 14:32:57 +05306761 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306762 __func__, nbuckets, nchannels);
6763 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6764 /* Allocate the memory */
6765 *buf = wmi_buf_alloc(wmi_handle, len);
6766 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306767 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306768 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306769 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306770 }
6771 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6772 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6773 WMITLV_SET_HDR(&cmd->tlv_header,
6774 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6775 WMITLV_GET_STRUCT_TLVLEN
6776 (wmi_extscan_start_cmd_fixed_param));
6777
6778 cmd->request_id = pstart->requestId;
6779 cmd->vdev_id = pstart->sessionId;
6780 cmd->base_period = pstart->basePeriod;
6781 cmd->num_buckets = nbuckets;
6782 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306783 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306784 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306785 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306786 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306787#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306788 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6789 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306790 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6791 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6792#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306793 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6794
6795 /* The max dwell time is retrieved from the first channel
6796 * of the first bucket and kept common for all channels.
6797 */
6798 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6799 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6800 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6801 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6802 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6803 cmd->max_table_usage = pstart->report_threshold_percent;
6804 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6805
6806 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306807 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306808 cmd->probe_delay = 0;
6809 cmd->probe_spacing_time = 0;
6810 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306811 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6812 WMI_SCAN_ADD_CCK_RATES |
6813 WMI_SCAN_ADD_OFDM_RATES |
6814 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6815 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306816 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6817 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306818 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306819 cmd->num_ssids = 0;
6820 cmd->num_bssid = 0;
6821 cmd->ie_len = 0;
6822 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6823 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6824
6825 buf_ptr += sizeof(*cmd);
6826 WMITLV_SET_HDR(buf_ptr,
6827 WMITLV_TAG_ARRAY_FIXED_STRUC,
6828 num_ssid * sizeof(wmi_ssid));
6829 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6830
6831 WMITLV_SET_HDR(buf_ptr,
6832 WMITLV_TAG_ARRAY_FIXED_STRUC,
6833 num_bssid * sizeof(wmi_mac_addr));
6834 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6835
6836 ie_len_with_pad = 0;
6837 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6838 ie_len_with_pad);
6839 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6840
6841 WMITLV_SET_HDR(buf_ptr,
6842 WMITLV_TAG_ARRAY_STRUC,
6843 nbuckets * sizeof(wmi_extscan_bucket));
6844 dest_blist = (wmi_extscan_bucket *)
6845 (buf_ptr + WMI_TLV_HDR_SIZE);
6846 src_bucket = pstart->buckets;
6847
6848 /* Retrieve scanning information from each bucket and
6849 * channels and send it to the target
6850 */
6851 for (i = 0; i < nbuckets; i++) {
6852 WMITLV_SET_HDR(dest_blist,
6853 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6854 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6855
6856 dest_blist->bucket_id = src_bucket->bucket;
6857 dest_blist->base_period_multiplier =
6858 src_bucket->period / base_period;
6859 dest_blist->min_period = src_bucket->period;
6860 dest_blist->max_period = src_bucket->max_period;
6861 dest_blist->exp_backoff = src_bucket->exponent;
6862 dest_blist->exp_max_step_count = src_bucket->step_count;
6863 dest_blist->channel_band = src_bucket->band;
6864 dest_blist->num_channels = src_bucket->numChannels;
6865 dest_blist->notify_extscan_events = 0;
6866
6867 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6868 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006869 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6870 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306871
6872 if (src_bucket->reportEvents &
6873 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6874 dest_blist->forwarding_flags =
6875 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6876 dest_blist->notify_extscan_events |=
6877 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6878 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6879 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6880 } else {
6881 dest_blist->forwarding_flags =
6882 WMI_EXTSCAN_NO_FORWARDING;
6883 }
6884
6885 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6886 dest_blist->configuration_flags = 0;
6887 else
6888 dest_blist->configuration_flags =
6889 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6890
Govind Singhb53420c2016-03-09 14:32:57 +05306891 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306892 __func__, dest_blist->notify_extscan_events,
6893 dest_blist->configuration_flags,
6894 dest_blist->forwarding_flags);
6895
6896 dest_blist->min_dwell_time_active =
6897 src_bucket->min_dwell_time_active;
6898 dest_blist->max_dwell_time_active =
6899 src_bucket->max_dwell_time_active;
6900 dest_blist->min_dwell_time_passive =
6901 src_bucket->min_dwell_time_passive;
6902 dest_blist->max_dwell_time_passive =
6903 src_bucket->max_dwell_time_passive;
6904 src_channel = src_bucket->channels;
6905
6906 /* save the channel info to later populate
6907 * the channel TLV
6908 */
6909 for (k = 0; k < src_bucket->numChannels; k++) {
6910 save_channel[count++].channel = src_channel->channel;
6911 src_channel++;
6912 }
6913 dest_blist++;
6914 src_bucket++;
6915 }
6916 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6917 WMITLV_SET_HDR(buf_ptr,
6918 WMITLV_TAG_ARRAY_STRUC,
6919 nchannels * sizeof(wmi_extscan_bucket_channel));
6920 dest_clist = (wmi_extscan_bucket_channel *)
6921 (buf_ptr + WMI_TLV_HDR_SIZE);
6922
6923 /* Active or passive scan is based on the bucket dwell time
6924 * and channel specific active,passive scans are not
6925 * supported yet
6926 */
6927 for (i = 0; i < nchannels; i++) {
6928 WMITLV_SET_HDR(dest_clist,
6929 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6930 WMITLV_GET_STRUCT_TLVLEN
6931 (wmi_extscan_bucket_channel));
6932 dest_clist->channel = save_channel[i].channel;
6933 dest_clist++;
6934 }
6935 buf_ptr += WMI_TLV_HDR_SIZE +
6936 (nchannels * sizeof(wmi_extscan_bucket_channel));
6937 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306938 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306939}
6940
6941/**
6942 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6943 * @wmi_handle: wmi handle
6944 * @pstart: scan command request params
6945 *
6946 * This function sends start extscan request to fw.
6947 *
6948 * Return: CDF Status.
6949 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306950static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306951 struct wifi_scan_cmd_req_params *pstart)
6952{
Govind Singhb53420c2016-03-09 14:32:57 +05306953 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306954 wmi_buf_t buf;
6955 int len;
6956
6957 /* Fill individual elements of extscan request and
6958 * TLV for buckets, channel list.
6959 */
Govind Singhb53420c2016-03-09 14:32:57 +05306960 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306962 if (qdf_status != QDF_STATUS_SUCCESS) {
6963 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6964 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306965 }
6966 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306967 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306968 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306969 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306970 }
6971 if (wmi_unified_cmd_send(wmi_handle, buf,
6972 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306973 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306974 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306975 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306976 }
6977
Govind Singhb53420c2016-03-09 14:32:57 +05306978 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306979}
6980
6981/**
6982 * send_plm_stop_cmd_tlv() - plm stop request
6983 * @wmi_handle: wmi handle
6984 * @plm: plm request parameters
6985 *
6986 * This function request FW to stop PLM.
6987 *
6988 * Return: CDF status
6989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306990static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306991 const struct plm_req_params *plm)
6992{
6993 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6994 int32_t len;
6995 wmi_buf_t buf;
6996 uint8_t *buf_ptr;
6997 int ret;
6998
6999 len = sizeof(*cmd);
7000 buf = wmi_buf_alloc(wmi_handle, len);
7001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307002 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7003 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307004 }
7005
7006 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7007
7008 buf_ptr = (uint8_t *) cmd;
7009
7010 WMITLV_SET_HDR(&cmd->tlv_header,
7011 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7012 WMITLV_GET_STRUCT_TLVLEN
7013 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7014
7015 cmd->vdev_id = plm->session_id;
7016
7017 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307018 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307019
7020 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7021 WMI_VDEV_PLMREQ_STOP_CMDID);
7022 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307023 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307024 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307025 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307026 }
7027
Govind Singhb53420c2016-03-09 14:32:57 +05307028 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307029}
7030
7031/**
7032 * send_plm_start_cmd_tlv() - plm start request
7033 * @wmi_handle: wmi handle
7034 * @plm: plm request parameters
7035 *
7036 * This function request FW to start PLM.
7037 *
7038 * Return: CDF status
7039 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307040static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307041 const struct plm_req_params *plm,
7042 uint32_t *gchannel_list)
7043{
7044 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7045 uint32_t *channel_list;
7046 int32_t len;
7047 wmi_buf_t buf;
7048 uint8_t *buf_ptr;
7049 uint8_t count;
7050 int ret;
7051
7052 /* TLV place holder for channel_list */
7053 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7054 len += sizeof(uint32_t) * plm->plm_num_ch;
7055
7056 buf = wmi_buf_alloc(wmi_handle, len);
7057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307058 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7059 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307060 }
7061 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7062
7063 buf_ptr = (uint8_t *) cmd;
7064
7065 WMITLV_SET_HDR(&cmd->tlv_header,
7066 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7067 WMITLV_GET_STRUCT_TLVLEN
7068 (wmi_vdev_plmreq_start_cmd_fixed_param));
7069
7070 cmd->vdev_id = plm->session_id;
7071
7072 cmd->meas_token = plm->meas_token;
7073 cmd->dialog_token = plm->diag_token;
7074 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307075 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307076 cmd->off_duration = plm->meas_duration;
7077 cmd->burst_cycle = plm->burst_len;
7078 cmd->tx_power = plm->desired_tx_pwr;
7079 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7080 cmd->num_chans = plm->plm_num_ch;
7081
7082 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7083
Govind Singhb53420c2016-03-09 14:32:57 +05307084 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7085 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7086 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7087 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7088 WMI_LOGD("off_duration: %d", cmd->off_duration);
7089 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7090 WMI_LOGD("tx_power: %d", cmd->tx_power);
7091 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307092
7093 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7094 (cmd->num_chans * sizeof(uint32_t)));
7095
7096 buf_ptr += WMI_TLV_HDR_SIZE;
7097 if (cmd->num_chans) {
7098 channel_list = (uint32_t *) buf_ptr;
7099 for (count = 0; count < cmd->num_chans; count++) {
7100 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307101 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307102 channel_list[count] =
7103 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307104 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307105 }
7106 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7107 }
7108
7109 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7110 WMI_VDEV_PLMREQ_START_CMDID);
7111 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307112 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307113 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307114 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307115 }
7116
Govind Singhb53420c2016-03-09 14:32:57 +05307117 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307118}
7119
7120/**
7121 * send_pno_stop_cmd_tlv() - PNO stop request
7122 * @wmi_handle: wmi handle
7123 * @vdev_id: vdev id
7124 *
7125 * This function request FW to stop ongoing PNO operation.
7126 *
7127 * Return: CDF status
7128 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307129static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307130{
7131 wmi_nlo_config_cmd_fixed_param *cmd;
7132 int32_t len = sizeof(*cmd);
7133 wmi_buf_t buf;
7134 uint8_t *buf_ptr;
7135 int ret;
7136
7137 /*
7138 * TLV place holder for array of structures nlo_configured_parameters
7139 * TLV place holder for array of uint32_t channel_list
7140 * TLV place holder for chnl prediction cfg
7141 */
7142 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7143 buf = wmi_buf_alloc(wmi_handle, len);
7144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307145 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7146 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307147 }
7148
7149 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7150 buf_ptr = (uint8_t *) cmd;
7151
7152 WMITLV_SET_HDR(&cmd->tlv_header,
7153 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7154 WMITLV_GET_STRUCT_TLVLEN
7155 (wmi_nlo_config_cmd_fixed_param));
7156
7157 cmd->vdev_id = vdev_id;
7158 cmd->flags = WMI_NLO_CONFIG_STOP;
7159 buf_ptr += sizeof(*cmd);
7160
7161 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7162 buf_ptr += WMI_TLV_HDR_SIZE;
7163
7164 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7165 buf_ptr += WMI_TLV_HDR_SIZE;
7166
7167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7168 buf_ptr += WMI_TLV_HDR_SIZE;
7169
7170
7171 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7172 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7173 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307174 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307175 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307176 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307177 }
7178
Govind Singhb53420c2016-03-09 14:32:57 +05307179 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307180}
7181
7182/**
Govind Singhccb0c272016-04-01 16:30:08 +05307183 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7184 * @buf_ptr: Buffer passed by upper layers
7185 * @pno: Buffer to be sent to the firmware
7186 *
7187 * Copy the PNO Channel prediction configuration parameters
7188 * passed by the upper layers to a WMI format TLV and send it
7189 * down to the firmware.
7190 *
7191 * Return: None
7192 */
7193static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7194 struct pno_scan_req_params *pno)
7195{
7196 nlo_channel_prediction_cfg *channel_prediction_cfg =
7197 (nlo_channel_prediction_cfg *) buf_ptr;
7198 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7199 WMITLV_TAG_ARRAY_BYTE,
7200 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307201#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307202 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7203 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7204 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7205 channel_prediction_cfg->full_scan_period_ms =
7206 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307207#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307208 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7209 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7210 channel_prediction_cfg->enable,
7211 channel_prediction_cfg->top_k_num,
7212 channel_prediction_cfg->stationary_threshold,
7213 channel_prediction_cfg->full_scan_period_ms);
7214}
7215
7216/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307217 * send_pno_start_cmd_tlv() - PNO start request
7218 * @wmi_handle: wmi handle
7219 * @pno: PNO request
7220 *
7221 * This function request FW to start PNO request.
7222 * Request: CDF status
7223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307224static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307225 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226{
7227 wmi_nlo_config_cmd_fixed_param *cmd;
7228 nlo_configured_parameters *nlo_list;
7229 uint32_t *channel_list;
7230 int32_t len;
7231 wmi_buf_t buf;
7232 uint8_t *buf_ptr;
7233 uint8_t i;
7234 int ret;
7235
7236 /*
7237 * TLV place holder for array nlo_configured_parameters(nlo_list)
7238 * TLV place holder for array of uint32_t channel_list
7239 * TLV place holder for chnnl prediction cfg
7240 */
7241 len = sizeof(*cmd) +
7242 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7243
Abhishek Singh5987b632017-03-03 22:09:07 +05307244 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245 WMI_NLO_MAX_CHAN);
7246 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307247 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248 len += sizeof(nlo_channel_prediction_cfg);
7249
7250 buf = wmi_buf_alloc(wmi_handle, len);
7251 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307252 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7253 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307254 }
7255
7256 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7257
7258 buf_ptr = (uint8_t *) cmd;
7259 WMITLV_SET_HDR(&cmd->tlv_header,
7260 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7261 WMITLV_GET_STRUCT_TLVLEN
7262 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307263 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307264 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7265
Govind Singh87542482016-06-08 19:40:11 +05307266#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307267 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307268 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307269#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307271 cmd->active_dwell_time = pno->active_dwell_time;
7272 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307273
7274 /* Copy scan interval */
7275 cmd->fast_scan_period = pno->fast_scan_period;
7276 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007277 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307278 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007279 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307280 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307282 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307283
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307284 /* mac randomization attributes */
7285 if (pno->scan_random.randomize) {
7286 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7287 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7288 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7289 pno->scan_random.mac_mask,
7290 &cmd->mac_addr,
7291 &cmd->mac_mask);
7292 }
7293
Govind Singh4eacd2b2016-03-07 14:24:22 +05307294 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7295
Abhishek Singh5987b632017-03-03 22:09:07 +05307296 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307297 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307298 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7299 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7300 buf_ptr += WMI_TLV_HDR_SIZE;
7301
7302 nlo_list = (nlo_configured_parameters *) buf_ptr;
7303 for (i = 0; i < cmd->no_of_ssids; i++) {
7304 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7305 WMITLV_TAG_ARRAY_BYTE,
7306 WMITLV_GET_STRUCT_TLVLEN
7307 (nlo_configured_parameters));
7308 /* Copy ssid and it's length */
7309 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307310 nlo_list[i].ssid.ssid.ssid_len =
7311 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307312 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307313 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307314 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307315 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307316 nlo_list[i].ssid.ssid.ssid_len,
7317 (char *)nlo_list[i].ssid.ssid.ssid,
7318 nlo_list[i].ssid.ssid.ssid_len);
7319
7320 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307321 if (pno->networks_list[i].rssi_thresh &&
7322 pno->networks_list[i].rssi_thresh >
7323 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307324 nlo_list[i].rssi_cond.valid = true;
7325 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307326 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307327 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307328 nlo_list[i].rssi_cond.rssi);
7329 }
7330 nlo_list[i].bcast_nw_type.valid = true;
7331 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307332 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007333 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307334 nlo_list[i].bcast_nw_type.bcast_nw_type);
7335 }
7336 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7337
7338 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307339 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307340 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307341 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307342 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7343 (cmd->num_of_channels * sizeof(uint32_t)));
7344 buf_ptr += WMI_TLV_HDR_SIZE;
7345
7346 channel_list = (uint32_t *) buf_ptr;
7347 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307348 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307349
7350 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307351 channel_list[i] =
7352 wlan_chan_to_freq(pno->
7353 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307354
Govind Singhb53420c2016-03-09 14:32:57 +05307355 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307356 }
7357 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7359 sizeof(nlo_channel_prediction_cfg));
7360 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307361 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307362 buf_ptr += WMI_TLV_HDR_SIZE;
7363 /** TODO: Discrete firmware doesn't have command/option to configure
7364 * App IE which comes from wpa_supplicant as of part PNO start request.
7365 */
7366 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7367 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7368 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307369 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307370 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307371 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307372 }
7373
Govind Singhb53420c2016-03-09 14:32:57 +05307374 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307375}
7376
7377/* send_set_ric_req_cmd_tlv() - set ric request element
7378 * @wmi_handle: wmi handle
7379 * @msg: message
7380 * @is_add_ts: is addts required
7381 *
7382 * This function sets ric request element for 11r roaming.
7383 *
7384 * Return: CDF status
7385 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307386static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307387 void *msg, uint8_t is_add_ts)
7388{
7389 wmi_ric_request_fixed_param *cmd;
7390 wmi_ric_tspec *tspec_param;
7391 wmi_buf_t buf;
7392 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307393 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307394 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7395 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7396
7397 buf = wmi_buf_alloc(wmi_handle, len);
7398 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307399 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7400 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307401 }
7402
7403 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7404
7405 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7406 WMITLV_SET_HDR(&cmd->tlv_header,
7407 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7408 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7409 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007410 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307411 else
7412 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7413 cmd->num_ric_request = 1;
7414 cmd->is_add_ric = is_add_ts;
7415
7416 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7417 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7418
7419 buf_ptr += WMI_TLV_HDR_SIZE;
7420 tspec_param = (wmi_ric_tspec *) buf_ptr;
7421 WMITLV_SET_HDR(&tspec_param->tlv_header,
7422 WMITLV_TAG_STRUC_wmi_ric_tspec,
7423 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7424
7425 if (is_add_ts)
7426 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307427#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307428 else
7429 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307430#endif
7431 if (ptspecIE) {
7432 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307433#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307434 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7435 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307436#else
Govind Singh87542482016-06-08 19:40:11 +05307437 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7438 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307439#endif /* ANI_LITTLE_BIT_ENDIAN */
7440
Govind Singh87542482016-06-08 19:40:11 +05307441 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7442 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7443 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7444 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7445 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7446 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7447 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7448 tspec_param->min_data_rate = ptspecIE->minDataRate;
7449 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7450 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7451 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7452 tspec_param->delay_bound = ptspecIE->delayBound;
7453 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7454 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7455 tspec_param->medium_time = 0;
7456 }
Govind Singhb53420c2016-03-09 14:32:57 +05307457 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307458
7459 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7460 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307461 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307462 __func__);
7463 if (is_add_ts)
7464 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307465 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307466 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307467 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307468 }
7469
Govind Singhb53420c2016-03-09 14:32:57 +05307470 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307471}
7472
7473/**
7474 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7475 * @wmi_handle: wmi handle
7476 * @clear_req: ll stats clear request command params
7477 *
Govind Singhb53420c2016-03-09 14:32:57 +05307478 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307479 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307480static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307481 const struct ll_stats_clear_params *clear_req,
7482 uint8_t addr[IEEE80211_ADDR_LEN])
7483{
7484 wmi_clear_link_stats_cmd_fixed_param *cmd;
7485 int32_t len;
7486 wmi_buf_t buf;
7487 uint8_t *buf_ptr;
7488 int ret;
7489
7490 len = sizeof(*cmd);
7491 buf = wmi_buf_alloc(wmi_handle, len);
7492
7493 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307494 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7495 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307496 }
7497
7498 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307499 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307500 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7501
7502 WMITLV_SET_HDR(&cmd->tlv_header,
7503 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7504 WMITLV_GET_STRUCT_TLVLEN
7505 (wmi_clear_link_stats_cmd_fixed_param));
7506
7507 cmd->stop_stats_collection_req = clear_req->stop_req;
7508 cmd->vdev_id = clear_req->sta_id;
7509 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7510
7511 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7512 &cmd->peer_macaddr);
7513
Govind Singhb53420c2016-03-09 14:32:57 +05307514 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7515 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7516 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7517 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7518 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 cmd->peer_macaddr); */
7520
7521 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7522 WMI_CLEAR_LINK_STATS_CMDID);
7523 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307524 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307525 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307526 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527 }
7528
Govind Singhb53420c2016-03-09 14:32:57 +05307529 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7530 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307531}
7532
7533/**
7534 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7535 * @wmi_handle: wmi handle
7536 * @setReq: ll stats set request command params
7537 *
Govind Singhb53420c2016-03-09 14:32:57 +05307538 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307539 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307540static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307541 const struct ll_stats_set_params *set_req)
7542{
7543 wmi_start_link_stats_cmd_fixed_param *cmd;
7544 int32_t len;
7545 wmi_buf_t buf;
7546 uint8_t *buf_ptr;
7547 int ret;
7548
7549 len = sizeof(*cmd);
7550 buf = wmi_buf_alloc(wmi_handle, len);
7551
7552 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307553 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7554 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307555 }
7556
7557 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307558 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307559 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7560
7561 WMITLV_SET_HDR(&cmd->tlv_header,
7562 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7563 WMITLV_GET_STRUCT_TLVLEN
7564 (wmi_start_link_stats_cmd_fixed_param));
7565
7566 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7567 cmd->aggressive_statistics_gathering =
7568 set_req->aggressive_statistics_gathering;
7569
Govind Singhb53420c2016-03-09 14:32:57 +05307570 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7571 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7572 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307573
7574 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7575 WMI_START_LINK_STATS_CMDID);
7576 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307577 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307578 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307579 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307580 }
7581
Govind Singhb53420c2016-03-09 14:32:57 +05307582 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307583}
7584
7585/**
7586 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7587 * @wmi_handle:wmi handle
7588 * @get_req:ll stats get request command params
7589 * @addr: mac address
7590 *
Govind Singhb53420c2016-03-09 14:32:57 +05307591 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307593static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307594 const struct ll_stats_get_params *get_req,
7595 uint8_t addr[IEEE80211_ADDR_LEN])
7596{
7597 wmi_request_link_stats_cmd_fixed_param *cmd;
7598 int32_t len;
7599 wmi_buf_t buf;
7600 uint8_t *buf_ptr;
7601 int ret;
7602
7603 len = sizeof(*cmd);
7604 buf = wmi_buf_alloc(wmi_handle, len);
7605
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307606 if (!buf) {
7607 WMI_LOGE("%s: buf allocation failed", __func__);
7608 return QDF_STATUS_E_NOMEM;
7609 }
7610
Govind Singh4eacd2b2016-03-07 14:24:22 +05307611 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307612 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307613 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7614
7615 WMITLV_SET_HDR(&cmd->tlv_header,
7616 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7617 WMITLV_GET_STRUCT_TLVLEN
7618 (wmi_request_link_stats_cmd_fixed_param));
7619
7620 cmd->request_id = get_req->req_id;
7621 cmd->stats_type = get_req->param_id_mask;
7622 cmd->vdev_id = get_req->sta_id;
7623
7624 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7625 &cmd->peer_macaddr);
7626
Govind Singhb53420c2016-03-09 14:32:57 +05307627 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007628 WMI_LOGD("Request ID : %u", cmd->request_id);
7629 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307630 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7631 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307632
7633 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7634 WMI_REQUEST_LINK_STATS_CMDID);
7635 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307636 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307637 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307638 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307639 }
7640
Govind Singhb53420c2016-03-09 14:32:57 +05307641 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642}
7643
7644/**
7645 * send_get_stats_cmd_tlv() - get stats request
7646 * @wmi_handle: wmi handle
7647 * @get_stats_param: stats params
7648 * @addr: mac address
7649 *
7650 * Return: CDF status
7651 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307652static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307653 struct pe_stats_req *get_stats_param,
7654 uint8_t addr[IEEE80211_ADDR_LEN])
7655{
7656 wmi_buf_t buf;
7657 wmi_request_stats_cmd_fixed_param *cmd;
7658 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7659
7660 buf = wmi_buf_alloc(wmi_handle, len);
7661 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307662 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7663 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307664 }
7665
7666
7667 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7668 WMITLV_SET_HDR(&cmd->tlv_header,
7669 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7670 WMITLV_GET_STRUCT_TLVLEN
7671 (wmi_request_stats_cmd_fixed_param));
Gurumoorthi Gnanasambandhan4aec3672017-07-10 11:55:23 +05307672 cmd->stats_id = get_stats_param->stats_mask;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307673 cmd->vdev_id = get_stats_param->session_id;
7674 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307675 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307676 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7677 WMI_REQUEST_STATS_CMDID)) {
7678
Govind Singhb53420c2016-03-09 14:32:57 +05307679 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307680 __func__);
7681 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307682 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307683 }
7684
Govind Singhb53420c2016-03-09 14:32:57 +05307685 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307686
7687}
7688
Govind Singh20c5dac2016-03-07 15:33:31 +05307689/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307690 * send_congestion_cmd_tlv() - send request to fw to get CCA
7691 * @wmi_handle: wmi handle
7692 * @vdev_id: vdev id
7693 *
7694 * Return: CDF status
7695 */
7696static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7697 A_UINT8 vdev_id)
7698{
7699 wmi_buf_t buf;
7700 wmi_request_stats_cmd_fixed_param *cmd;
7701 uint8_t len;
7702 uint8_t *buf_ptr;
7703
7704 len = sizeof(*cmd);
7705 buf = wmi_buf_alloc(wmi_handle, len);
7706 if (!buf) {
7707 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7708 return QDF_STATUS_E_FAILURE;
7709 }
7710
7711 buf_ptr = wmi_buf_data(buf);
7712 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7713 WMITLV_SET_HDR(&cmd->tlv_header,
7714 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7715 WMITLV_GET_STRUCT_TLVLEN
7716 (wmi_request_stats_cmd_fixed_param));
7717
7718 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7719 cmd->vdev_id = vdev_id;
7720 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7721 cmd->vdev_id, cmd->stats_id);
7722
7723 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7724 WMI_REQUEST_STATS_CMDID)) {
7725 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7726 __func__);
7727 wmi_buf_free(buf);
7728 return QDF_STATUS_E_FAILURE;
7729 }
7730
7731 return QDF_STATUS_SUCCESS;
7732}
7733
7734/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7736 * @wmi_handle: wmi handle
7737 * @rssi_req: get RSSI request
7738 *
7739 * Return: CDF status
7740 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307741static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307742{
7743 wmi_buf_t buf;
7744 wmi_request_stats_cmd_fixed_param *cmd;
7745 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7746
7747 buf = wmi_buf_alloc(wmi_handle, len);
7748 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307749 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7750 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307751 }
7752
7753 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7754 WMITLV_SET_HDR(&cmd->tlv_header,
7755 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7756 WMITLV_GET_STRUCT_TLVLEN
7757 (wmi_request_stats_cmd_fixed_param));
7758 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7759 if (wmi_unified_cmd_send
7760 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307761 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307762 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307763 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307764 }
7765
Govind Singhb53420c2016-03-09 14:32:57 +05307766 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307767}
7768
7769/**
7770 * send_snr_cmd_tlv() - get RSSI from fw
7771 * @wmi_handle: wmi handle
7772 * @vdev_id: vdev id
7773 *
7774 * Return: CDF status
7775 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307776static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307777{
7778 wmi_buf_t buf;
7779 wmi_request_stats_cmd_fixed_param *cmd;
7780 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7781
7782 buf = wmi_buf_alloc(wmi_handle, len);
7783 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307784 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7785 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307786 }
7787
7788 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7789 cmd->vdev_id = vdev_id;
7790
7791 WMITLV_SET_HDR(&cmd->tlv_header,
7792 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7793 WMITLV_GET_STRUCT_TLVLEN
7794 (wmi_request_stats_cmd_fixed_param));
7795 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7796 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7797 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307798 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307799 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307800 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307801 }
7802
Govind Singhb53420c2016-03-09 14:32:57 +05307803 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307804}
7805
7806/**
7807 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7808 * @wmi_handle: wmi handle
7809 * @link_status: get link params
7810 *
7811 * Return: CDF status
7812 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307813static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307814 struct link_status_params *link_status)
7815{
7816 wmi_buf_t buf;
7817 wmi_request_stats_cmd_fixed_param *cmd;
7818 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7819
7820 buf = wmi_buf_alloc(wmi_handle, len);
7821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307822 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7823 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307824 }
7825
7826 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7827 WMITLV_SET_HDR(&cmd->tlv_header,
7828 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7829 WMITLV_GET_STRUCT_TLVLEN
7830 (wmi_request_stats_cmd_fixed_param));
7831 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7832 cmd->vdev_id = link_status->session_id;
7833 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7834 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307835 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307836 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307837 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307838 }
7839
Govind Singhb53420c2016-03-09 14:32:57 +05307840 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307841}
7842
Govind Singh20c5dac2016-03-07 15:33:31 +05307843/**
7844 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7845 * @wmi_handle: wmi handle
7846 * @ta_dhcp_ind: DHCP indication parameter
7847 *
7848 * Return: CDF Status
7849 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307850static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307851 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7852{
Govind Singh67922e82016-04-01 16:48:57 +05307853 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307854 wmi_buf_t buf = NULL;
7855 uint8_t *buf_ptr;
7856 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7857 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7858
7859
7860 buf = wmi_buf_alloc(wmi_handle, len);
7861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307862 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7863 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307864 }
7865
7866 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7867 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7868 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7869 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7870 WMITLV_GET_STRUCT_TLVLEN
7871 (wmi_peer_set_param_cmd_fixed_param));
7872
7873 /* fill in values */
7874 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7875 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7876 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307877 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307878 &ta_dhcp_ind->peer_macaddr,
7879 sizeof(ta_dhcp_ind->peer_macaddr));
7880
7881 status = wmi_unified_cmd_send(wmi_handle, buf,
7882 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307883 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307884 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307885 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307886 wmi_buf_free(buf);
7887 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307888
Govind Singh67922e82016-04-01 16:48:57 +05307889 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307890}
7891
7892/**
7893 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7894 * @wmi_handle: wmi handle
7895 * @pLinkSpeed: link speed info
7896 *
7897 * Return: CDF status
7898 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307899static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307900 wmi_mac_addr peer_macaddr)
7901{
7902 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7903 wmi_buf_t wmi_buf;
7904 uint32_t len;
7905 uint8_t *buf_ptr;
7906
7907 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7908 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7909 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307910 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7911 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307912 }
7913 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7914
7915 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7916 WMITLV_SET_HDR(&cmd->tlv_header,
7917 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7918 WMITLV_GET_STRUCT_TLVLEN
7919 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7920
7921 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307922 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 &peer_macaddr,
7924 sizeof(peer_macaddr));
7925
7926
7927 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7928 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307929 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307930 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307931 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307932 }
Govind Singhb53420c2016-03-09 14:32:57 +05307933 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307934}
7935
7936/**
7937 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7938 * @wmi_handle: wmi handler
7939 * @egap_params: pointer to egap_params
7940 *
7941 * Return: 0 for success, otherwise appropriate error code
7942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307943static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307944 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7945{
7946 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7947 wmi_buf_t buf;
7948 int32_t err;
7949
7950 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7951 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307952 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7953 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307954 }
7955 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7956 WMITLV_SET_HDR(&cmd->tlv_header,
7957 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7958 WMITLV_GET_STRUCT_TLVLEN(
7959 wmi_ap_ps_egap_param_cmd_fixed_param));
7960
7961 cmd->enable = egap_params->enable;
7962 cmd->inactivity_time = egap_params->inactivity_time;
7963 cmd->wait_time = egap_params->wait_time;
7964 cmd->flags = egap_params->flags;
7965 err = wmi_unified_cmd_send(wmi_handle, buf,
7966 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7967 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307968 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307969 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307970 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307971 }
7972
Govind Singhb53420c2016-03-09 14:32:57 +05307973 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307974}
7975
7976/**
7977 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7978 * @wmi_handl: wmi handle
7979 * @cmd: Profiling command index
7980 * @value1: parameter1 value
7981 * @value2: parameter2 value
7982 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307983 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307984 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307985static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307986 uint32_t cmd, uint32_t value1, uint32_t value2)
7987{
7988 wmi_buf_t buf;
7989 int32_t len = 0;
7990 int ret;
7991 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7992 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7993 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7994 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7995
7996 switch (cmd) {
7997 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7998 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7999 buf = wmi_buf_alloc(wmi_handle, len);
8000 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308001 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308002 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308003 }
8004 prof_trig_cmd =
8005 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8006 wmi_buf_data(buf);
8007 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8008 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8009 WMITLV_GET_STRUCT_TLVLEN
8010 (wmi_wlan_profile_trigger_cmd_fixed_param));
8011 prof_trig_cmd->enable = value1;
8012 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8013 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8014 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308016 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308017 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308018 return ret;
8019 }
8020 break;
8021
8022 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8023 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8024 buf = wmi_buf_alloc(wmi_handle, len);
8025 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308026 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308027 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308028 }
8029 profile_getdata_cmd =
8030 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8031 wmi_buf_data(buf);
8032 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8033 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8034 WMITLV_GET_STRUCT_TLVLEN
8035 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8037 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8038 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308039 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308040 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308041 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308042 return ret;
8043 }
8044 break;
8045
8046 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8047 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8048 buf = wmi_buf_alloc(wmi_handle, len);
8049 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308050 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308051 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308052 }
8053 hist_intvl_cmd =
8054 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8055 wmi_buf_data(buf);
8056 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8057 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8058 WMITLV_GET_STRUCT_TLVLEN
8059 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8060 hist_intvl_cmd->profile_id = value1;
8061 hist_intvl_cmd->value = value2;
8062 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8063 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8064 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308065 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308066 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308067 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308068 return ret;
8069 }
8070 break;
8071
8072 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8073 len =
8074 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8075 buf = wmi_buf_alloc(wmi_handle, len);
8076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308077 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308078 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308079 }
8080 profile_enable_cmd =
8081 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8082 wmi_buf_data(buf);
8083 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8084 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8085 WMITLV_GET_STRUCT_TLVLEN
8086 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8087 profile_enable_cmd->profile_id = value1;
8088 profile_enable_cmd->enable = value2;
8089 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8090 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8091 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308092 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308093 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308094 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 return ret;
8096 }
8097 break;
8098
8099 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308100 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 break;
8102 }
8103
8104 return 0;
8105}
8106
Govind Singh20c5dac2016-03-07 15:33:31 +05308107/**
8108 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8109 * @wmi_handle: wmi handle
8110 * @vdev_id: vdev id
8111 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308112 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308113 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308114static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308115{
8116 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8117 wmi_buf_t buf;
8118 int32_t len = sizeof(*cmd);
8119
Govind Singhb53420c2016-03-09 14:32:57 +05308120 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 buf = wmi_buf_alloc(wmi_handle, len);
8122 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308123 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308124 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308125 }
8126 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8127 wmi_buf_data(buf);
8128 WMITLV_SET_HDR(&cmd->tlv_header,
8129 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8130 WMITLV_GET_STRUCT_TLVLEN
8131 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8132 cmd->vdev_id = vdev_id;
8133 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8134 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8135 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308136 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308137 __func__);
8138 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308139 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308140 }
8141
8142 return 0;
8143}
8144
8145/**
8146 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8147 * @wmi_handle: wmi handle
8148 * @vdev_id: vdev id
8149 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308150 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308151 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308152static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308153 uint8_t vdev_id)
8154{
8155 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8156 wmi_buf_t buf;
8157 int32_t len = sizeof(*cmd);
8158
Govind Singhb53420c2016-03-09 14:32:57 +05308159 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308160 buf = wmi_buf_alloc(wmi_handle, len);
8161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308162 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308163 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308164 }
8165 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8166 WMITLV_SET_HDR(&cmd->tlv_header,
8167 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8168 WMITLV_GET_STRUCT_TLVLEN
8169 (wmi_csa_offload_enable_cmd_fixed_param));
8170 cmd->vdev_id = vdev_id;
8171 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8172 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8173 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308174 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308175 __func__);
8176 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308177 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308178 }
8179
8180 return 0;
8181}
8182
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008183#ifdef WLAN_FEATURE_CIF_CFR
8184/**
8185 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8186 * @wmi_handle: wmi handle
8187 * @data_len: len of dma cfg req
8188 * @data: dma cfg req
8189 *
8190 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8191 */
8192static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8193 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8194{
8195 wmi_buf_t buf;
8196 uint8_t *cmd;
8197 QDF_STATUS ret;
8198
8199 WMITLV_SET_HDR(cfg,
8200 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8201 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8202
8203 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8204 if (!buf) {
8205 WMI_LOGE(FL("wmi_buf_alloc failed"));
8206 return QDF_STATUS_E_FAILURE;
8207 }
8208
8209 cmd = (uint8_t *) wmi_buf_data(buf);
8210 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8211 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8212 sizeof(*cfg));
8213 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8214 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8215 if (QDF_IS_STATUS_ERROR(ret)) {
8216 WMI_LOGE(FL(":wmi cmd send failed"));
8217 wmi_buf_free(buf);
8218 }
8219
8220 return ret;
8221}
8222#endif
8223
Govind Singh20c5dac2016-03-07 15:33:31 +05308224/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008225 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8226 * @wmi_handle: wmi handle
8227 * @start_11d_scan: 11d scan start request parameters
8228 *
8229 * This function request FW to start 11d scan.
8230 *
8231 * Return: QDF status
8232 */
8233static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8234 struct reg_start_11d_scan_req *start_11d_scan)
8235{
8236 wmi_11d_scan_start_cmd_fixed_param *cmd;
8237 int32_t len;
8238 wmi_buf_t buf;
8239 int ret;
8240
8241 len = sizeof(*cmd);
8242 buf = wmi_buf_alloc(wmi_handle, len);
8243 if (!buf) {
8244 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8245 return QDF_STATUS_E_NOMEM;
8246 }
8247
8248 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8249
8250 WMITLV_SET_HDR(&cmd->tlv_header,
8251 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8252 WMITLV_GET_STRUCT_TLVLEN
8253 (wmi_11d_scan_start_cmd_fixed_param));
8254
8255 cmd->vdev_id = start_11d_scan->vdev_id;
8256 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8257 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8258
8259 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8260
8261 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8262 WMI_11D_SCAN_START_CMDID);
8263 if (ret) {
8264 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8265 wmi_buf_free(buf);
8266 return QDF_STATUS_E_FAILURE;
8267 }
8268
8269 return QDF_STATUS_SUCCESS;
8270}
8271
8272/**
8273 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8274 * @wmi_handle: wmi handle
8275 * @start_11d_scan: 11d scan stop request parameters
8276 *
8277 * This function request FW to stop 11d scan.
8278 *
8279 * Return: QDF status
8280 */
8281static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8282 struct reg_stop_11d_scan_req *stop_11d_scan)
8283{
8284 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8285 int32_t len;
8286 wmi_buf_t buf;
8287 int ret;
8288
8289 len = sizeof(*cmd);
8290 buf = wmi_buf_alloc(wmi_handle, len);
8291 if (!buf) {
8292 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8293 return QDF_STATUS_E_NOMEM;
8294 }
8295
8296 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8297
8298 WMITLV_SET_HDR(&cmd->tlv_header,
8299 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8300 WMITLV_GET_STRUCT_TLVLEN
8301 (wmi_11d_scan_stop_cmd_fixed_param));
8302
8303 cmd->vdev_id = stop_11d_scan->vdev_id;
8304
8305 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8306
8307 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8308 WMI_11D_SCAN_STOP_CMDID);
8309 if (ret) {
8310 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8311 wmi_buf_free(buf);
8312 return QDF_STATUS_E_FAILURE;
8313 }
8314
8315 return QDF_STATUS_SUCCESS;
8316}
8317
8318/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308319 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8320 * @wmi_handle: wmi handle
8321 * @startOemDataReq: start request params
8322 *
8323 * Return: CDF status
8324 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308325static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008326 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308327 uint8_t *data)
8328{
8329 wmi_buf_t buf;
8330 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308331 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308332
8333 buf = wmi_buf_alloc(wmi_handle,
8334 (data_len + WMI_TLV_HDR_SIZE));
8335 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308336 WMI_LOGE(FL("wmi_buf_alloc failed"));
8337 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308338 }
8339
8340 cmd = (uint8_t *) wmi_buf_data(buf);
8341
8342 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8343 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308344 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308345 data_len);
8346
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008347 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 data_len);
8349
8350 ret = wmi_unified_cmd_send(wmi_handle, buf,
8351 (data_len +
8352 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8353
Govind Singh67922e82016-04-01 16:48:57 +05308354 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308355 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308356 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308357 }
8358
Govind Singh67922e82016-04-01 16:48:57 +05308359 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308360}
8361
8362/**
8363 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8364 * @wmi_handle: wmi handle
8365 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8366 *
8367 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8368 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8369 * to firmware based on phyerr filtering
8370 * offload status.
8371 *
8372 * Return: 1 success, 0 failure
8373 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308374static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308375send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8376 bool dfs_phyerr_filter_offload)
8377{
8378 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8379 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8380 wmi_buf_t buf;
8381 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308382 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308383
8384
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008385 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308386 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308387 __func__);
8388 len = sizeof(*disable_phyerr_offload_cmd);
8389 buf = wmi_buf_alloc(wmi_handle, len);
8390 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308391 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308392 return 0;
8393 }
8394 disable_phyerr_offload_cmd =
8395 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8396 wmi_buf_data(buf);
8397
8398 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8399 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8400 WMITLV_GET_STRUCT_TLVLEN
8401 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8402
8403 /*
8404 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8405 * to the firmware to disable the phyerror
8406 * filtering offload.
8407 */
8408 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8409 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308410 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308411 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308412 __func__, ret);
8413 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308414 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308415 }
Govind Singhb53420c2016-03-09 14:32:57 +05308416 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308417 __func__);
8418 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308419 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308420 __func__);
8421
8422 len = sizeof(*enable_phyerr_offload_cmd);
8423 buf = wmi_buf_alloc(wmi_handle, len);
8424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308425 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8426 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308427 }
8428
8429 enable_phyerr_offload_cmd =
8430 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8431 wmi_buf_data(buf);
8432
8433 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8434 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8435 WMITLV_GET_STRUCT_TLVLEN
8436 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8437
8438 /*
8439 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8440 * to the firmware to enable the phyerror
8441 * filtering offload.
8442 */
8443 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8444 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8445
Govind Singh67922e82016-04-01 16:48:57 +05308446 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308447 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308448 __func__, ret);
8449 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308450 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308451 }
Govind Singhb53420c2016-03-09 14:32:57 +05308452 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308453 __func__);
8454 }
8455
Govind Singhb53420c2016-03-09 14:32:57 +05308456 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308457}
8458
8459#if !defined(REMOVE_PKT_LOG)
8460/**
8461 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8462 * @wmi_handle: wmi handle
8463 * @pktlog_event: pktlog event
8464 * @cmd_id: pktlog cmd id
8465 *
8466 * Return: CDF status
8467 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308468static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308469 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308470 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308471{
8472 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8473 WMI_CMD_ID CMD_ID;
8474 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8475 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8476 int len = 0;
8477 wmi_buf_t buf;
8478
8479 PKTLOG_EVENT = pktlog_event;
8480 CMD_ID = cmd_id;
8481
8482 switch (CMD_ID) {
8483 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8484 len = sizeof(*cmd);
8485 buf = wmi_buf_alloc(wmi_handle, len);
8486 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308487 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8488 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308489 }
8490 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8491 wmi_buf_data(buf);
8492 WMITLV_SET_HDR(&cmd->tlv_header,
8493 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8494 WMITLV_GET_STRUCT_TLVLEN
8495 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8496 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308497 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8498 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308499 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8500 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308501 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8502 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308503 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308504 goto wmi_send_failed;
8505 }
8506 break;
8507 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8508 len = sizeof(*disable_cmd);
8509 buf = wmi_buf_alloc(wmi_handle, len);
8510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308511 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8512 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513 }
8514 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8515 wmi_buf_data(buf);
8516 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8517 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8518 WMITLV_GET_STRUCT_TLVLEN
8519 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308520 disable_cmd->pdev_id =
8521 wmi_handle->ops->convert_pdev_id_host_to_target(
8522 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308523 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8524 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308525 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 goto wmi_send_failed;
8527 }
8528 break;
8529 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308530 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308531 break;
8532 }
8533
Govind Singhb53420c2016-03-09 14:32:57 +05308534 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308535
8536wmi_send_failed:
8537 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308538 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308539}
8540#endif /* REMOVE_PKT_LOG */
8541
8542/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8544 * @wmi_handle: wmi handle
8545 * @ptrn_id: pattern id
8546 * @vdev_id: vdev id
8547 *
8548 * Return: CDF status
8549 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308550static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8551 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308552{
8553 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8554 wmi_buf_t buf;
8555 int32_t len;
8556 int ret;
8557
8558 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8559
8560
8561 buf = wmi_buf_alloc(wmi_handle, len);
8562 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308563 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8564 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308565 }
8566
8567 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8568
8569 WMITLV_SET_HDR(&cmd->tlv_header,
8570 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8571 WMITLV_GET_STRUCT_TLVLEN(
8572 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8573 cmd->vdev_id = vdev_id;
8574 cmd->pattern_id = ptrn_id;
8575 cmd->pattern_type = WOW_BITMAP_PATTERN;
8576
Govind Singhb53420c2016-03-09 14:32:57 +05308577 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308578 cmd->pattern_id, vdev_id);
8579
8580 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8581 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8582 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308583 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308584 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308585 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308586 }
8587
Govind Singhb53420c2016-03-09 14:32:57 +05308588 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308589}
8590
8591/**
8592 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8593 * @wmi_handle: wmi handle
8594 *
8595 * Sends host wakeup indication to FW. On receiving this indication,
8596 * FW will come out of WOW.
8597 *
8598 * Return: CDF status
8599 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308600static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308601{
8602 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8603 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308604 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308605 int32_t len;
8606 int ret;
8607
8608 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8609
8610 buf = wmi_buf_alloc(wmi_handle, len);
8611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308612 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8613 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308614 }
8615
8616 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8617 wmi_buf_data(buf);
8618 WMITLV_SET_HDR(&cmd->tlv_header,
8619 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8620 WMITLV_GET_STRUCT_TLVLEN
8621 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8622
8623
8624 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8625 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8626 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308627 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308628 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308629 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308630 }
8631
Govind Singhb53420c2016-03-09 14:32:57 +05308632 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308633}
8634
8635/**
8636 * send_del_ts_cmd_tlv() - send DELTS request to fw
8637 * @wmi_handle: wmi handle
8638 * @msg: delts params
8639 *
8640 * Return: CDF status
8641 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308642static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308643 uint8_t ac)
8644{
8645 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8646 wmi_buf_t buf;
8647 int32_t len = sizeof(*cmd);
8648
8649 buf = wmi_buf_alloc(wmi_handle, len);
8650 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308651 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8652 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308653 }
8654 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8655 WMITLV_SET_HDR(&cmd->tlv_header,
8656 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8657 WMITLV_GET_STRUCT_TLVLEN
8658 (wmi_vdev_wmm_delts_cmd_fixed_param));
8659 cmd->vdev_id = vdev_id;
8660 cmd->ac = ac;
8661
Govind Singhb53420c2016-03-09 14:32:57 +05308662 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308663 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8664 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8665 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308666 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308667 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308668 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308669 }
8670
Govind Singhb53420c2016-03-09 14:32:57 +05308671 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308672}
8673
8674/**
8675 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8676 * @wmi_handle: handle to wmi
8677 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8678 *
Govind Singhb53420c2016-03-09 14:32:57 +05308679 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308680 * ADD_TS requestes to firmware in loop for all the ACs with
8681 * active flow.
8682 *
8683 * Return: CDF status
8684 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308685static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308686 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8687{
8688 int i = 0;
8689 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8690 wmi_buf_t buf;
8691 int32_t len = sizeof(*cmd);
8692
8693 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8694 /* if flow in this AC is active */
8695 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8696 /*
8697 * as per implementation of wma_add_ts_req() we
8698 * are not waiting any response from firmware so
8699 * apart from sending ADDTS to firmware just send
8700 * success to upper layers
8701 */
Govind Singhb53420c2016-03-09 14:32:57 +05308702 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308703
8704 buf = wmi_buf_alloc(wmi_handle, len);
8705 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308706 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8707 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308708 }
8709 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8710 wmi_buf_data(buf);
8711 WMITLV_SET_HDR(&cmd->tlv_header,
8712 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8713 WMITLV_GET_STRUCT_TLVLEN
8714 (wmi_vdev_wmm_addts_cmd_fixed_param));
8715 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8716 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308717 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308718 traffic.userPrio);
8719 cmd->medium_time_us =
8720 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8721 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308722 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308723 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8724 cmd->medium_time_us, cmd->downgrade_type);
8725 if (wmi_unified_cmd_send
8726 (wmi_handle, buf, len,
8727 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308728 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308729 __func__);
8730 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308731 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308732 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308733 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308734 }
8735 }
8736 }
8737
Govind Singhb53420c2016-03-09 14:32:57 +05308738 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308739}
8740
8741/**
8742 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8743 * @wmi_handle: wmi handle
8744 * @msg: ADDTS params
8745 *
8746 * Return: CDF status
8747 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308748static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308749 struct add_ts_param *msg)
8750{
8751 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8752 wmi_buf_t buf;
8753 int32_t len = sizeof(*cmd);
8754
Govind Singhb53420c2016-03-09 14:32:57 +05308755 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308756
8757 buf = wmi_buf_alloc(wmi_handle, len);
8758 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308759 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8760 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308761 }
8762 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8763 WMITLV_SET_HDR(&cmd->tlv_header,
8764 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8765 WMITLV_GET_STRUCT_TLVLEN
8766 (wmi_vdev_wmm_addts_cmd_fixed_param));
8767 cmd->vdev_id = msg->sme_session_id;
8768 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8769 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8770 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308771 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308772 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8773 cmd->downgrade_type, __func__, __LINE__);
8774 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8775 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308776 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8777 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308778 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308779 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308780 }
8781
Govind Singhb53420c2016-03-09 14:32:57 +05308782 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308783}
8784
8785/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308786 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8787 * @wmi_handle: wmi handle
8788 * @pAddPeriodicTxPtrnParams: tx ptrn params
8789 *
8790 * Retrun: CDF status
8791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308792static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308793 struct periodic_tx_pattern *
8794 pAddPeriodicTxPtrnParams,
8795 uint8_t vdev_id)
8796{
8797 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8798 wmi_buf_t wmi_buf;
8799 uint32_t len;
8800 uint8_t *buf_ptr;
8801 uint32_t ptrn_len, ptrn_len_aligned;
8802 int j;
8803
8804 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8805 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8806 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8807 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8808
8809 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8810 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308811 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8812 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308813 }
8814
8815 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8816
8817 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8818 WMITLV_SET_HDR(&cmd->tlv_header,
8819 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8820 WMITLV_GET_STRUCT_TLVLEN
8821 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8822
8823 /* Pass the pattern id to delete for the corresponding vdev id */
8824 cmd->vdev_id = vdev_id;
8825 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8826 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8827 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8828
8829 /* Pattern info */
8830 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8831 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8832 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308833 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308835 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308836
Govind Singhb53420c2016-03-09 14:32:57 +05308837 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308838 __func__, cmd->pattern_id, cmd->vdev_id);
8839
8840 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8841 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308842 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308843 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308844 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308845 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308846 }
Govind Singhb53420c2016-03-09 14:32:57 +05308847 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308848}
8849
8850/**
8851 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8852 * @wmi_handle: wmi handle
8853 * @vdev_id: vdev id
8854 * @pattern_id: pattern id
8855 *
8856 * Retrun: CDF status
8857 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308858static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308859 uint8_t vdev_id,
8860 uint8_t pattern_id)
8861{
8862 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8863 wmi_buf_t wmi_buf;
8864 uint32_t len =
8865 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8866
8867 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8868 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308869 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8870 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308871 }
8872
8873 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8874 wmi_buf_data(wmi_buf);
8875 WMITLV_SET_HDR(&cmd->tlv_header,
8876 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8877 WMITLV_GET_STRUCT_TLVLEN
8878 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8879
8880 /* Pass the pattern id to delete for the corresponding vdev id */
8881 cmd->vdev_id = vdev_id;
8882 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308883 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308884 __func__, cmd->pattern_id, cmd->vdev_id);
8885
8886 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8887 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308888 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308889 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308890 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308891 }
Govind Singhb53420c2016-03-09 14:32:57 +05308892 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308893}
8894
8895/**
8896 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8897 * @wmi_handle: wmi handle
8898 * @preq: stats ext params
8899 *
8900 * Return: CDF status
8901 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308902static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308903 struct stats_ext_params *preq)
8904{
Govind Singh67922e82016-04-01 16:48:57 +05308905 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308906 wmi_req_stats_ext_cmd_fixed_param *cmd;
8907 wmi_buf_t buf;
8908 uint16_t len;
8909 uint8_t *buf_ptr;
8910
8911 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8912
8913 buf = wmi_buf_alloc(wmi_handle, len);
8914 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308915 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308916 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308917 }
8918
8919 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8920 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8921
8922 WMITLV_SET_HDR(&cmd->tlv_header,
8923 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8924 WMITLV_GET_STRUCT_TLVLEN
8925 (wmi_req_stats_ext_cmd_fixed_param));
8926 cmd->vdev_id = preq->vdev_id;
8927 cmd->data_len = preq->request_data_len;
8928
Govind Singhb53420c2016-03-09 14:32:57 +05308929 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308930 __func__, preq->request_data_len, preq->vdev_id);
8931
8932 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8934
8935 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308936 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308937
8938 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8939 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308940 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308941 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308942 ret);
8943 wmi_buf_free(buf);
8944 }
8945
8946 return ret;
8947}
8948
8949/**
8950 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8951 * @wmi_handle: wmi handle
8952 * @params: ext wow params
8953 *
8954 * Return:0 for success or error code
8955 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308956static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308957 struct ext_wow_params *params)
8958{
8959 wmi_extwow_enable_cmd_fixed_param *cmd;
8960 wmi_buf_t buf;
8961 int32_t len;
8962 int ret;
8963
8964 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8965 buf = wmi_buf_alloc(wmi_handle, len);
8966 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308967 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8968 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308969 }
8970
8971 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8972
8973 WMITLV_SET_HDR(&cmd->tlv_header,
8974 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8975 WMITLV_GET_STRUCT_TLVLEN
8976 (wmi_extwow_enable_cmd_fixed_param));
8977
8978 cmd->vdev_id = params->vdev_id;
8979 cmd->type = params->type;
8980 cmd->wakeup_pin_num = params->wakeup_pin_num;
8981
Govind Singhb53420c2016-03-09 14:32:57 +05308982 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308983 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8984
8985 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8986 WMI_EXTWOW_ENABLE_CMDID);
8987 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308988 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308989 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308990 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308991 }
8992
Govind Singhb53420c2016-03-09 14:32:57 +05308993 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308994
8995}
8996
8997/**
8998 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8999 * @wmi_handle: wmi handle
9000 * @app_type1_params: app type1 params
9001 *
9002 * Return: CDF status
9003 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309004static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309005 struct app_type1_params *app_type1_params)
9006{
9007 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9008 wmi_buf_t buf;
9009 int32_t len;
9010 int ret;
9011
9012 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9013 buf = wmi_buf_alloc(wmi_handle, len);
9014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309015 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9016 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 }
9018
9019 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9020 wmi_buf_data(buf);
9021
9022 WMITLV_SET_HDR(&cmd->tlv_header,
9023 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9024 WMITLV_GET_STRUCT_TLVLEN
9025 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9026
9027 cmd->vdev_id = app_type1_params->vdev_id;
9028 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9029 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309030 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309031 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309032 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309033 cmd->passwd_len = app_type1_params->pass_length;
9034
Govind Singhb53420c2016-03-09 14:32:57 +05309035 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 "identification_id %.8s id_length %u "
9037 "password %.16s pass_length %u",
9038 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9039 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9040
9041 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9042 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9043 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309044 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309045 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309046 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 }
9048
Govind Singhb53420c2016-03-09 14:32:57 +05309049 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309050}
9051
9052/**
9053 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9054 * @wmi_handle: wmi handle
9055 * @appType2Params: app type2 params
9056 *
9057 * Return: CDF status
9058 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309059static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 struct app_type2_params *appType2Params)
9061{
9062 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9063 wmi_buf_t buf;
9064 int32_t len;
9065 int ret;
9066
9067 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9068 buf = wmi_buf_alloc(wmi_handle, len);
9069 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309070 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9071 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 }
9073
9074 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9075 wmi_buf_data(buf);
9076
9077 WMITLV_SET_HDR(&cmd->tlv_header,
9078 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9079 WMITLV_GET_STRUCT_TLVLEN
9080 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9081
9082 cmd->vdev_id = appType2Params->vdev_id;
9083
Govind Singhb53420c2016-03-09 14:32:57 +05309084 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309085 cmd->rc4_key_len = appType2Params->rc4_key_len;
9086
9087 cmd->ip_id = appType2Params->ip_id;
9088 cmd->ip_device_ip = appType2Params->ip_device_ip;
9089 cmd->ip_server_ip = appType2Params->ip_server_ip;
9090
9091 cmd->tcp_src_port = appType2Params->tcp_src_port;
9092 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9093 cmd->tcp_seq = appType2Params->tcp_seq;
9094 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9095
9096 cmd->keepalive_init = appType2Params->keepalive_init;
9097 cmd->keepalive_min = appType2Params->keepalive_min;
9098 cmd->keepalive_max = appType2Params->keepalive_max;
9099 cmd->keepalive_inc = appType2Params->keepalive_inc;
9100
9101 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9102 &cmd->gateway_mac);
9103 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9104 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9105
Govind Singhb53420c2016-03-09 14:32:57 +05309106 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309107 "rc4_key %.16s rc4_key_len %u "
9108 "ip_id %x ip_device_ip %x ip_server_ip %x "
9109 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9110 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9111 "keepalive_max %u keepalive_inc %u "
9112 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9113 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9114 cmd->rc4_key, cmd->rc4_key_len,
9115 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9116 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9117 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9118 cmd->keepalive_max, cmd->keepalive_inc,
9119 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9120
9121 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9122 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9123 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309124 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309125 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309126 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 }
9128
Govind Singhb53420c2016-03-09 14:32:57 +05309129 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309130
9131}
9132
9133/**
9134 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9135 * @wmi_handle: wmi handle
9136 * @timer_val: auto shutdown timer value
9137 *
9138 * Return: CDF status
9139 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309140static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309141 uint32_t timer_val)
9142{
Govind Singh67922e82016-04-01 16:48:57 +05309143 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309144 wmi_buf_t buf = NULL;
9145 uint8_t *buf_ptr;
9146 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9147 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9148
Govind Singhb53420c2016-03-09 14:32:57 +05309149 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309150 __func__, timer_val);
9151
9152 buf = wmi_buf_alloc(wmi_handle, len);
9153 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309154 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9155 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309156 }
9157
9158 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9159 wmi_auto_sh_cmd =
9160 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9161 wmi_auto_sh_cmd->timer_value = timer_val;
9162
9163 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9164 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9165 WMITLV_GET_STRUCT_TLVLEN
9166 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9167
9168 status = wmi_unified_cmd_send(wmi_handle, buf,
9169 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309170 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309172 __func__, status);
9173 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309174 }
9175
Govind Singh67922e82016-04-01 16:48:57 +05309176 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309177}
9178
9179/**
9180 * send_nan_req_cmd_tlv() - to send nan request to target
9181 * @wmi_handle: wmi handle
9182 * @nan_req: request data which will be non-null
9183 *
9184 * Return: CDF status
9185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309186static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309187 struct nan_req_params *nan_req)
9188{
Govind Singh67922e82016-04-01 16:48:57 +05309189 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 wmi_nan_cmd_param *cmd;
9191 wmi_buf_t buf;
9192 uint16_t len = sizeof(*cmd);
9193 uint16_t nan_data_len, nan_data_len_aligned;
9194 uint8_t *buf_ptr;
9195
9196 /*
9197 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9198 * +------------+----------+-----------------------+--------------+
9199 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9200 * +------------+----------+-----------------------+--------------+
9201 */
9202 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309203 WMI_LOGE("%s:nan req is not valid", __func__);
9204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309205 }
9206 nan_data_len = nan_req->request_data_len;
9207 nan_data_len_aligned = roundup(nan_req->request_data_len,
9208 sizeof(uint32_t));
9209 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9210 buf = wmi_buf_alloc(wmi_handle, len);
9211 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309212 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9213 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309214 }
9215 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9216 cmd = (wmi_nan_cmd_param *) buf_ptr;
9217 WMITLV_SET_HDR(&cmd->tlv_header,
9218 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9219 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9220 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309221 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 __func__, nan_req->request_data_len);
9223 buf_ptr += sizeof(wmi_nan_cmd_param);
9224 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9225 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309226 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309227
9228 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9229 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309231 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309232 __func__, ret);
9233 wmi_buf_free(buf);
9234 }
9235
9236 return ret;
9237}
9238
9239/**
9240 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9241 * @wmi_handle: wmi handle
9242 * @pDhcpSrvOffloadInfo: DHCP server offload info
9243 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309244 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309246static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309247 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
9248{
9249 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9250 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309251 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309252
9253 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9254 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309255 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309256 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309257 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309258 }
9259
9260 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309261 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05309262
9263 WMITLV_SET_HDR(&cmd->tlv_header,
9264 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9265 WMITLV_GET_STRUCT_TLVLEN
9266 (wmi_set_dhcp_server_offload_cmd_fixed_param));
9267 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
9268 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
9269 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
9270 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
9271 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309272 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309273 sizeof(*cmd),
9274 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309275 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309276 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309277 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309278 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 }
Govind Singhb53420c2016-03-09 14:32:57 +05309280 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309281 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309282
9283 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309284}
9285
9286/**
9287 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9288 * @wmi_handle: wmi handle
9289 * @flashing: flashing request
9290 *
9291 * Return: CDF status
9292 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309293static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309294 struct flashing_req_params *flashing)
9295{
9296 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309297 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309298 wmi_buf_t buf;
9299 uint8_t *buf_ptr;
9300 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9301
9302 buf = wmi_buf_alloc(wmi_handle, len);
9303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309304 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309305 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309306 }
9307 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9308 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9309 WMITLV_SET_HDR(&cmd->tlv_header,
9310 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9311 WMITLV_GET_STRUCT_TLVLEN
9312 (wmi_set_led_flashing_cmd_fixed_param));
9313 cmd->pattern_id = flashing->pattern_id;
9314 cmd->led_x0 = flashing->led_x0;
9315 cmd->led_x1 = flashing->led_x1;
9316
9317 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9318 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309319 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309320 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309321 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309322 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309323 }
Govind Singh67922e82016-04-01 16:48:57 +05309324
9325 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309326}
9327
9328/**
9329 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9330 * @wmi_handle: wmi handle
9331 * @ch_avoid_update_req: channel avoid update params
9332 *
9333 * Return: CDF status
9334 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309335static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309336{
Govind Singh67922e82016-04-01 16:48:57 +05309337 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309338 wmi_buf_t buf = NULL;
9339 uint8_t *buf_ptr;
9340 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9341 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9342
9343
9344 buf = wmi_buf_alloc(wmi_handle, len);
9345 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309346 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9347 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309348 }
9349
9350 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9351 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9352 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9353 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9354 WMITLV_GET_STRUCT_TLVLEN
9355 (wmi_chan_avoid_update_cmd_param));
9356
9357 status = wmi_unified_cmd_send(wmi_handle, buf,
9358 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309359 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309360 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309361 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9362 " returned Error %d", status);
9363 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309364 }
9365
Govind Singh67922e82016-04-01 16:48:57 +05309366 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309367}
9368
9369/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309370 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9371 * @wmi_handle: wmi handle
9372 * @param: pointer to pdev regdomain params
9373 *
9374 * Return: 0 for success or error code
9375 */
9376static QDF_STATUS
9377send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9378 struct pdev_set_regdomain_params *param)
9379{
9380 wmi_buf_t buf;
9381 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9382 int32_t len = sizeof(*cmd);
9383
9384
9385 buf = wmi_buf_alloc(wmi_handle, len);
9386 if (!buf) {
9387 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9388 return QDF_STATUS_E_NOMEM;
9389 }
9390 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9391 WMITLV_SET_HDR(&cmd->tlv_header,
9392 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9393 WMITLV_GET_STRUCT_TLVLEN
9394 (wmi_pdev_set_regdomain_cmd_fixed_param));
9395
9396 cmd->reg_domain = param->currentRDinuse;
9397 cmd->reg_domain_2G = param->currentRD2G;
9398 cmd->reg_domain_5G = param->currentRD5G;
9399 cmd->conformance_test_limit_2G = param->ctl_2G;
9400 cmd->conformance_test_limit_5G = param->ctl_5G;
9401 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309402 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9403 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309404
9405 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9406 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9407 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9408 __func__);
9409 wmi_buf_free(buf);
9410 return QDF_STATUS_E_FAILURE;
9411 }
9412
9413 return QDF_STATUS_SUCCESS;
9414}
9415
9416/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309417 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9418 * @wmi_handle: wmi handle
9419 * @reg_dmn: reg domain
9420 * @regdmn2G: 2G reg domain
9421 * @regdmn5G: 5G reg domain
9422 * @ctl2G: 2G test limit
9423 * @ctl5G: 5G test limit
9424 *
9425 * Return: none
9426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309427static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309428 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309429 uint16_t regdmn5G, uint8_t ctl2G,
9430 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309431{
9432 wmi_buf_t buf;
9433 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9434 int32_t len = sizeof(*cmd);
9435
9436
9437 buf = wmi_buf_alloc(wmi_handle, len);
9438 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309439 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9440 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309441 }
9442 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9443 WMITLV_SET_HDR(&cmd->tlv_header,
9444 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9445 WMITLV_GET_STRUCT_TLVLEN
9446 (wmi_pdev_set_regdomain_cmd_fixed_param));
9447 cmd->reg_domain = reg_dmn;
9448 cmd->reg_domain_2G = regdmn2G;
9449 cmd->reg_domain_5G = regdmn5G;
9450 cmd->conformance_test_limit_2G = ctl2G;
9451 cmd->conformance_test_limit_5G = ctl5G;
9452
9453 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9454 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309455 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309456 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309457 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309458 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309459 }
9460
Govind Singhb53420c2016-03-09 14:32:57 +05309461 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309462}
9463
9464
9465/**
9466 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9467 * @wmi_handle: wmi handle
9468 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9469 *
9470 * This function sets tdls off channel mode
9471 *
9472 * Return: 0 on success; Negative errno otherwise
9473 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309474static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 struct tdls_channel_switch_params *chan_switch_params)
9476{
9477 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9478 wmi_buf_t wmi_buf;
9479 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9480
9481 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9482 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309483 WMI_LOGE(FL("wmi_buf_alloc failed"));
9484 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309485 }
9486 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9487 wmi_buf_data(wmi_buf);
9488 WMITLV_SET_HDR(&cmd->tlv_header,
9489 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9490 WMITLV_GET_STRUCT_TLVLEN(
9491 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9492
9493 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9494 &cmd->peer_macaddr);
9495 cmd->vdev_id = chan_switch_params->vdev_id;
9496 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9497 cmd->is_peer_responder = chan_switch_params->is_responder;
9498 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9499 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9500 cmd->offchan_oper_class = chan_switch_params->oper_class;
9501
Govind Singhb53420c2016-03-09 14:32:57 +05309502 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309503 cmd->peer_macaddr.mac_addr31to0,
9504 cmd->peer_macaddr.mac_addr47to32);
9505
Govind Singhb53420c2016-03-09 14:32:57 +05309506 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309507 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9508 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9509 ),
9510 cmd->vdev_id,
9511 cmd->offchan_mode,
9512 cmd->offchan_num,
9513 cmd->offchan_bw_bitmap,
9514 cmd->is_peer_responder,
9515 cmd->offchan_oper_class);
9516
9517 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9518 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309519 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309520 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309521 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309522 }
9523
9524
Govind Singhb53420c2016-03-09 14:32:57 +05309525 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309526}
9527
9528/**
9529 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9530 * @wmi_handle: wmi handle
9531 * @pwmaTdlsparams: TDLS params
9532 *
9533 * Return: 0 for sucess or error code
9534 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309535static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309536 void *tdls_param, uint8_t tdls_state)
9537{
9538 wmi_tdls_set_state_cmd_fixed_param *cmd;
9539 wmi_buf_t wmi_buf;
9540
9541 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9542 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9543
9544 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9545 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309546 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9547 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309548 }
9549 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9550 WMITLV_SET_HDR(&cmd->tlv_header,
9551 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9552 WMITLV_GET_STRUCT_TLVLEN
9553 (wmi_tdls_set_state_cmd_fixed_param));
9554 cmd->vdev_id = wmi_tdls->vdev_id;
9555 cmd->state = tdls_state;
9556 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9557 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9558 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9559 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9560 cmd->rssi_delta = wmi_tdls->rssi_delta;
9561 cmd->tdls_options = wmi_tdls->tdls_options;
9562 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9563 cmd->tdls_peer_traffic_response_timeout_ms =
9564 wmi_tdls->peer_traffic_response_timeout;
9565 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9566 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9567 cmd->tdls_puapsd_rx_frame_threshold =
9568 wmi_tdls->puapsd_rx_frame_threshold;
9569 cmd->teardown_notification_ms =
9570 wmi_tdls->teardown_notification_ms;
9571 cmd->tdls_peer_kickout_threshold =
9572 wmi_tdls->tdls_peer_kickout_threshold;
9573
Govind Singhb53420c2016-03-09 14:32:57 +05309574 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309575 "notification_interval_ms: %d, "
9576 "tx_discovery_threshold: %d, "
9577 "tx_teardown_threshold: %d, "
9578 "rssi_teardown_threshold: %d, "
9579 "rssi_delta: %d, "
9580 "tdls_options: 0x%x, "
9581 "tdls_peer_traffic_ind_window: %d, "
9582 "tdls_peer_traffic_response_timeout: %d, "
9583 "tdls_puapsd_mask: 0x%x, "
9584 "tdls_puapsd_inactivity_time: %d, "
9585 "tdls_puapsd_rx_frame_threshold: %d, "
9586 "teardown_notification_ms: %d, "
9587 "tdls_peer_kickout_threshold: %d",
9588 __func__, tdls_state, cmd->state,
9589 cmd->notification_interval_ms,
9590 cmd->tx_discovery_threshold,
9591 cmd->tx_teardown_threshold,
9592 cmd->rssi_teardown_threshold,
9593 cmd->rssi_delta,
9594 cmd->tdls_options,
9595 cmd->tdls_peer_traffic_ind_window,
9596 cmd->tdls_peer_traffic_response_timeout_ms,
9597 cmd->tdls_puapsd_mask,
9598 cmd->tdls_puapsd_inactivity_time_ms,
9599 cmd->tdls_puapsd_rx_frame_threshold,
9600 cmd->teardown_notification_ms,
9601 cmd->tdls_peer_kickout_threshold);
9602
9603 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9604 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309605 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309606 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309607 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309608 }
Govind Singhb53420c2016-03-09 14:32:57 +05309609 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309610
Govind Singhb53420c2016-03-09 14:32:57 +05309611 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309612}
9613
9614/**
9615 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9616 * @wmi_handle: wmi handle
9617 * @peerStateParams: TDLS peer state params
9618 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309619 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309620 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309621static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309622 struct tdls_peer_state_params *peerStateParams,
9623 uint32_t *ch_mhz)
9624{
9625 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9626 wmi_tdls_peer_capabilities *peer_cap;
9627 wmi_channel *chan_info;
9628 wmi_buf_t wmi_buf;
9629 uint8_t *buf_ptr;
9630 uint32_t i;
9631 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9632 sizeof(wmi_tdls_peer_capabilities);
9633
9634
9635 len += WMI_TLV_HDR_SIZE +
9636 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9637
9638 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9639 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309640 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9641 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309642 }
9643
9644 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9645 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9646 WMITLV_SET_HDR(&cmd->tlv_header,
9647 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9648 WMITLV_GET_STRUCT_TLVLEN
9649 (wmi_tdls_peer_update_cmd_fixed_param));
9650
9651 cmd->vdev_id = peerStateParams->vdevId;
9652 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9653 &cmd->peer_macaddr);
9654
9655
9656 cmd->peer_state = peerStateParams->peerState;
9657
Govind Singhb53420c2016-03-09 14:32:57 +05309658 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309659 "peer_macaddr.mac_addr31to0: 0x%x, "
9660 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9661 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9662 cmd->peer_macaddr.mac_addr31to0,
9663 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9664
9665 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9666 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9667 WMITLV_SET_HDR(&peer_cap->tlv_header,
9668 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9669 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9670
9671 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9672 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9673 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9674 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9675 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9676 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9677 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9678 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9679
9680 /* Ack and More Data Ack are sent as 0, so no need to set
9681 * but fill SP
9682 */
9683 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9684 peerStateParams->peerCap.peerMaxSp);
9685
9686 peer_cap->buff_sta_support =
9687 peerStateParams->peerCap.peerBuffStaSupport;
9688 peer_cap->off_chan_support =
9689 peerStateParams->peerCap.peerOffChanSupport;
9690 peer_cap->peer_curr_operclass =
9691 peerStateParams->peerCap.peerCurrOperClass;
9692 /* self curr operclass is not being used and so pass op class for
9693 * preferred off chan in it.
9694 */
9695 peer_cap->self_curr_operclass =
9696 peerStateParams->peerCap.opClassForPrefOffChan;
9697 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9698 peer_cap->peer_operclass_len =
9699 peerStateParams->peerCap.peerOperClassLen;
9700
Govind Singhb53420c2016-03-09 14:32:57 +05309701 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309702 __func__, peer_cap->peer_operclass_len);
9703 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9704 peer_cap->peer_operclass[i] =
9705 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309706 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 __func__, i, peer_cap->peer_operclass[i]);
9708 }
9709
9710 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9711 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9712 peer_cap->pref_offchan_bw =
9713 peerStateParams->peerCap.prefOffChanBandwidth;
9714
Govind Singhb53420c2016-03-09 14:32:57 +05309715 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309716 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9717 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9718 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9719 " %d, pref_offchan_bw: %d",
9720 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9721 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9722 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9723 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9724 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9725
9726 /* next fill variable size array of peer chan info */
9727 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9728 WMITLV_SET_HDR(buf_ptr,
9729 WMITLV_TAG_ARRAY_STRUC,
9730 sizeof(wmi_channel) *
9731 peerStateParams->peerCap.peerChanLen);
9732 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9733
9734 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9735 WMITLV_SET_HDR(&chan_info->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_channel,
9737 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9738 chan_info->mhz = ch_mhz[i];
9739 chan_info->band_center_freq1 = chan_info->mhz;
9740 chan_info->band_center_freq2 = 0;
9741
Govind Singhb53420c2016-03-09 14:32:57 +05309742 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309743
9744 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9745 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309746 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309747 peerStateParams->peerCap.peerChan[i].chanId,
9748 peerStateParams->peerCap.peerChan[i].dfsSet);
9749 }
9750
9751 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9752 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9753 else
9754 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9755
9756 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9757 peerStateParams->peerCap.
9758 peerChan[i].pwr);
9759
9760 WMI_SET_CHANNEL_REG_POWER(chan_info,
9761 peerStateParams->peerCap.peerChan[i].
9762 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309763 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309764 peerStateParams->peerCap.peerChan[i].pwr);
9765
9766 chan_info++;
9767 }
9768
9769 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9770 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309771 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309772 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309773 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309774 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309775 }
9776
9777
Govind Singhb53420c2016-03-09 14:32:57 +05309778 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309779}
9780
9781/*
9782 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9783 * firmware
9784 * @wmi_handle: Pointer to wmi handle
9785 * @mem_dump_req: Pointer for mem_dump_req
9786 *
9787 * This function sends memory dump request to firmware
9788 *
Govind Singhb53420c2016-03-09 14:32:57 +05309789 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309790 *
9791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309792static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309793 struct fw_dump_req_param *mem_dump_req)
9794{
9795 wmi_get_fw_mem_dump_fixed_param *cmd;
9796 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309797 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309798 int32_t len;
9799 wmi_buf_t buf;
9800 u_int8_t *buf_ptr;
9801 int ret, loop;
9802
9803 /*
9804 * len = sizeof(fixed param) that includes tlv header +
9805 * tlv header for array of struc +
9806 * sizeof (each struct)
9807 */
9808 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9809 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9810 buf = wmi_buf_alloc(wmi_handle, len);
9811
9812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309813 WMI_LOGE(FL("Failed allocate wmi buffer"));
9814 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309815 }
9816
9817 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309818 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309819 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9820
9821 WMITLV_SET_HDR(&cmd->tlv_header,
9822 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9823 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9824
9825 cmd->request_id = mem_dump_req->request_id;
9826 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9827
9828 /* TLV indicating array of structures to follow */
9829 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9830 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9831 sizeof(wmi_fw_mem_dump) *
9832 cmd->num_fw_mem_dump_segs);
9833
9834 buf_ptr += WMI_TLV_HDR_SIZE;
9835 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9836
Govind Singhb53420c2016-03-09 14:32:57 +05309837 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309838 mem_dump_req->request_id, mem_dump_req->num_seg);
9839 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309840 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309841 ((uint8_t *)(mem_dump_req->segment) +
9842 loop * sizeof(*seg_req));
9843 WMITLV_SET_HDR(&dump_params->tlv_header,
9844 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9845 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9846 dump_params->seg_id = seg_req->seg_id;
9847 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9848 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9849 dump_params->seg_length = seg_req->seg_length;
9850 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9851 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309852 WMI_LOGI(FL("seg_number:%d"), loop);
9853 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309854 dump_params->seg_id, dump_params->seg_start_addr_lo,
9855 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309856 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309857 dump_params->seg_length, dump_params->dest_addr_lo,
9858 dump_params->dest_addr_hi);
9859 dump_params++;
9860 }
9861
9862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9863 WMI_GET_FW_MEM_DUMP_CMDID);
9864 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309865 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309866 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309867 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309868 }
9869
Govind Singhb53420c2016-03-09 14:32:57 +05309870 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9871 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309872}
9873
9874/*
9875 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9876 * @wmi_handle: Pointer to WMi handle
9877 * @ie_data: Pointer for ie data
9878 *
9879 * This function sends IE information to firmware
9880 *
Govind Singhb53420c2016-03-09 14:32:57 +05309881 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309882 *
9883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309884static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309885 struct vdev_ie_info_param *ie_info)
9886{
9887 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9888 wmi_buf_t buf;
9889 uint8_t *buf_ptr;
9890 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309891 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309892
9893
9894 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9895 /* Allocate memory for the WMI command */
9896 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9897
9898 buf = wmi_buf_alloc(wmi_handle, len);
9899 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309900 WMI_LOGE(FL("wmi_buf_alloc failed"));
9901 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309902 }
9903
9904 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309905 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309906
9907 /* Populate the WMI command */
9908 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9909
9910 WMITLV_SET_HDR(&cmd->tlv_header,
9911 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9912 WMITLV_GET_STRUCT_TLVLEN(
9913 wmi_vdev_set_ie_cmd_fixed_param));
9914 cmd->vdev_id = ie_info->vdev_id;
9915 cmd->ie_id = ie_info->ie_id;
9916 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009917 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309918
Govind Singhb53420c2016-03-09 14:32:57 +05309919 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309920 ie_info->length, ie_info->vdev_id);
9921
9922 buf_ptr += sizeof(*cmd);
9923 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9924 buf_ptr += WMI_TLV_HDR_SIZE;
9925
Govind Singhb53420c2016-03-09 14:32:57 +05309926 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309927
9928 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9929 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309930 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309931 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309932 wmi_buf_free(buf);
9933 }
9934
9935 return ret;
9936}
9937
Sathish Kumar497bef42017-03-01 14:02:36 +05309938/**
9939 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9940 *
9941 * @param wmi_handle : handle to WMI.
9942 * @param param : pointer to antenna param
9943 *
9944 * This function sends smart antenna enable command to FW
9945 *
9946 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9947 */
9948static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9949 struct smart_ant_enable_params *param)
9950{
9951 /* Send WMI COMMAND to Enable */
9952 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9953 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9954 wmi_buf_t buf;
9955 uint8_t *buf_ptr;
9956 int len = 0;
9957 QDF_STATUS ret;
9958 int loop = 0;
9959
9960 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9961 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9962 buf = wmi_buf_alloc(wmi_handle, len);
9963
9964 if (!buf) {
9965 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9966 return QDF_STATUS_E_NOMEM;
9967 }
9968
9969 buf_ptr = wmi_buf_data(buf);
9970 qdf_mem_zero(buf_ptr, len);
9971 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9972
9973 WMITLV_SET_HDR(&cmd->tlv_header,
9974 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9975 WMITLV_GET_STRUCT_TLVLEN(
9976 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9977
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309978 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9979 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309980 cmd->enable = param->enable;
9981 cmd->mode = param->mode;
9982 cmd->rx_antenna = param->rx_antenna;
9983 cmd->tx_default_antenna = param->rx_antenna;
9984
9985 /* TLV indicating array of structures to follow */
9986 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9987 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9988 WMI_HAL_MAX_SANTENNA *
9989 sizeof(wmi_pdev_smart_ant_gpio_handle));
9990
9991 buf_ptr += WMI_TLV_HDR_SIZE;
9992 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9993
9994 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9995 WMITLV_SET_HDR(&gpio_param->tlv_header,
9996 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9997 WMITLV_GET_STRUCT_TLVLEN(
9998 wmi_pdev_smart_ant_gpio_handle));
9999 if (param->mode == SMART_ANT_MODE_SERIAL) {
10000 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10001 gpio_param->gpio_pin = param->gpio_pin[loop];
10002 gpio_param->gpio_func = param->gpio_func[loop];
10003 } else {
10004 gpio_param->gpio_pin = 0;
10005 gpio_param->gpio_func = 0;
10006 }
10007 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10008 gpio_param->gpio_pin = param->gpio_pin[loop];
10009 gpio_param->gpio_func = param->gpio_func[loop];
10010 }
10011 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010012 gpio_param->pdev_id =
10013 wmi_handle->ops->convert_pdev_id_host_to_target(
10014 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010015 gpio_param++;
10016 }
10017
10018 ret = wmi_unified_cmd_send(wmi_handle,
10019 buf,
10020 len,
10021 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10022
10023 if (ret != 0) {
10024 WMI_LOGE(" %s :WMI Failed\n", __func__);
10025 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10026 cmd->enable,
10027 cmd->mode,
10028 cmd->rx_antenna,
10029 param->gpio_pin[0], param->gpio_pin[1],
10030 param->gpio_pin[2], param->gpio_pin[3],
10031 param->gpio_func[0], param->gpio_func[1],
10032 param->gpio_func[2], param->gpio_func[3],
10033 ret);
10034 wmi_buf_free(buf);
10035 }
10036
10037 return ret;
10038}
10039
10040/**
10041 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10042 *
10043 * @param wmi_handle : handle to WMI.
10044 * @param param : pointer to rx antenna param
10045 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10046 */
10047static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10048 struct smart_ant_rx_ant_params *param)
10049{
10050 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10051 wmi_buf_t buf;
10052 uint8_t *buf_ptr;
10053 uint32_t len;
10054 QDF_STATUS ret;
10055
10056 len = sizeof(*cmd);
10057 buf = wmi_buf_alloc(wmi_handle, len);
10058 WMI_LOGD("%s:\n", __func__);
10059 if (!buf) {
10060 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10061 return QDF_STATUS_E_NOMEM;
10062 }
10063
10064 buf_ptr = wmi_buf_data(buf);
10065 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10066 WMITLV_SET_HDR(&cmd->tlv_header,
10067 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10068 WMITLV_GET_STRUCT_TLVLEN(
10069 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10070 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010071 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10072 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010073
10074 ret = wmi_unified_cmd_send(wmi_handle,
10075 buf,
10076 len,
10077 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10078
10079 if (ret != 0) {
10080 WMI_LOGE(" %s :WMI Failed\n", __func__);
10081 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10082 __func__,
10083 cmd->rx_antenna,
10084 ret);
10085 wmi_buf_free(buf);
10086 }
10087
10088 return ret;
10089}
10090
10091/**
10092 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10093 * @wmi_handle: wmi handle
10094 * @param: pointer to hold ctl table param
10095 *
10096 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10097 */
10098static QDF_STATUS
10099send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10100 struct ctl_table_params *param)
10101{
10102 uint16_t len, ctl_tlv_len;
10103 uint8_t *buf_ptr;
10104 wmi_buf_t buf;
10105 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10106 uint32_t *ctl_array;
10107
10108 if (!param->ctl_array)
10109 return QDF_STATUS_E_FAILURE;
10110
10111 if (param->ctl_cmd_len !=
10112 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
10113 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
10114 qdf_print("CTL array len not correct\n");
10115 return QDF_STATUS_E_FAILURE;
10116 }
10117
10118 ctl_tlv_len = WMI_TLV_HDR_SIZE +
10119 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
10120 len = sizeof(*cmd) + ctl_tlv_len;
10121
10122 buf = wmi_buf_alloc(wmi_handle, len);
10123 if (!buf) {
10124 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10125 return QDF_STATUS_E_FAILURE;
10126 }
10127
10128 buf_ptr = wmi_buf_data(buf);
10129 qdf_mem_zero(buf_ptr, len);
10130
10131 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10132
10133 WMITLV_SET_HDR(&cmd->tlv_header,
10134 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10135 WMITLV_GET_STRUCT_TLVLEN(
10136 wmi_pdev_set_ctl_table_cmd_fixed_param));
10137 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010138 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10139 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010140
10141 buf_ptr += sizeof(*cmd);
10142 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10143 (cmd->ctl_len));
10144 buf_ptr += WMI_TLV_HDR_SIZE;
10145 ctl_array = (uint32_t *)buf_ptr;
10146
10147 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10148 sizeof(param->ctl_band));
10149 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10150 param->ctl_cmd_len -
10151 sizeof(param->ctl_band));
10152
10153 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10154 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10155 WMI_LOGE("%s:Failed to send command\n", __func__);
10156 wmi_buf_free(buf);
10157 return QDF_STATUS_E_FAILURE;
10158 }
10159
10160 return QDF_STATUS_SUCCESS;
10161}
10162
10163/**
10164 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10165 * @wmi_handle: wmi handle
10166 * @param: pointer to hold mimogain table param
10167 *
10168 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10169 */
10170static QDF_STATUS
10171send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10172 struct mimogain_table_params *param)
10173{
10174 uint16_t len, table_tlv_len;
10175 wmi_buf_t buf;
10176 uint8_t *buf_ptr;
10177 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10178 uint32_t *gain_table;
10179
10180 if (!param->array_gain)
10181 return QDF_STATUS_E_FAILURE;
10182
10183 /* len must be multiple of a single array gain table */
10184 if (param->tbl_len %
10185 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10186 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10187 WMI_LOGE("Array gain table len not correct\n");
10188 return QDF_STATUS_E_FAILURE;
10189 }
10190
10191 table_tlv_len = WMI_TLV_HDR_SIZE +
10192 roundup(param->tbl_len, sizeof(uint32_t));
10193 len = sizeof(*cmd) + table_tlv_len;
10194
10195 buf = wmi_buf_alloc(wmi_handle, len);
10196 if (!buf) {
10197 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10198 return QDF_STATUS_E_FAILURE;
10199 }
10200
10201 buf_ptr = wmi_buf_data(buf);
10202 qdf_mem_zero(buf_ptr, len);
10203
10204 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10205
10206 WMITLV_SET_HDR(&cmd->tlv_header,
10207 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10208 WMITLV_GET_STRUCT_TLVLEN(
10209 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10210
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010211 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10212 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010213 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10214 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10215 param->multichain_gain_bypass);
10216
10217 buf_ptr += sizeof(*cmd);
10218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10219 (param->tbl_len));
10220 buf_ptr += WMI_TLV_HDR_SIZE;
10221 gain_table = (uint32_t *)buf_ptr;
10222
10223 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10224 param->array_gain,
10225 param->tbl_len);
10226
10227 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10228 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10229 return QDF_STATUS_E_FAILURE;
10230 }
10231
10232 return QDF_STATUS_SUCCESS;
10233}
10234
10235/**
10236 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10237 * info to fw
10238 * @wmi_handle: wmi handle
10239 * @param: pointer to hold packet power info param
10240 *
10241 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10242 */
10243static QDF_STATUS
10244send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10245 struct packet_power_info_params *param)
10246{
10247 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10248 wmi_buf_t wmibuf;
10249 uint8_t *buf_ptr;
10250 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10251
10252 wmibuf = wmi_buf_alloc(wmi_handle, len);
10253 if (wmibuf == NULL)
10254 return QDF_STATUS_E_NOMEM;
10255
10256 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10257
10258 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10259 WMITLV_SET_HDR(&cmd->tlv_header,
10260 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10261 WMITLV_GET_STRUCT_TLVLEN(
10262 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010263 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10264 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010265 cmd->rate_flags = param->rate_flags;
10266 cmd->nss = param->nss;
10267 cmd->preamble = param->preamble;
10268 cmd->hw_rate = param->hw_rate;
10269 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
10270 __func__,
10271 __LINE__,
10272 WMI_PDEV_GET_TPC_CMDID,
10273 *((u_int32_t *)cmd));
10274 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10275 WMI_PDEV_GET_TPC_CMDID)) {
10276 WMI_LOGE(FL("Failed to get tpc command\n"));
10277 wmi_buf_free(wmibuf);
10278 return QDF_STATUS_E_FAILURE;
10279 }
10280
10281 return QDF_STATUS_SUCCESS;
10282}
10283
10284/**
10285 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10286 * @wmi_handle: wmi handle
10287 * @param: pointer to hold config ratemask params
10288 *
10289 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10290 */
10291static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10292 struct config_ratemask_params *param)
10293{
10294 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10295 wmi_buf_t buf;
10296 int32_t len = sizeof(*cmd);
10297
10298 buf = wmi_buf_alloc(wmi_handle, len);
10299 if (!buf) {
10300 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10301 return QDF_STATUS_E_FAILURE;
10302 }
10303 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10304 WMITLV_SET_HDR(&cmd->tlv_header,
10305 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10306 WMITLV_GET_STRUCT_TLVLEN(
10307 wmi_vdev_config_ratemask_cmd_fixed_param));
10308 cmd->vdev_id = param->vdev_id;
10309 cmd->type = param->type;
10310 cmd->mask_lower32 = param->lower32;
10311 cmd->mask_higher32 = param->higher32;
10312 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10313 param->vdev_id, param->type, param->lower32, param->higher32);
10314
10315 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10316 WMI_VDEV_RATEMASK_CMDID)) {
10317 WMI_LOGE("Seting vdev ratemask failed\n");
10318 wmi_buf_free(buf);
10319 return QDF_STATUS_E_FAILURE;
10320 }
10321
10322 return QDF_STATUS_SUCCESS;
10323}
10324
10325/**
10326 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10327 * @wmi_handle: wmi handle
10328 * @param: pointer to hold vap dscp tid map param
10329 *
10330 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10331 */
10332static QDF_STATUS
10333send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10334 struct vap_dscp_tid_map_params *param)
10335{
10336 wmi_buf_t buf;
10337 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10338 int32_t len = sizeof(*cmd);
10339
10340 buf = wmi_buf_alloc(wmi_handle, len);
10341 if (!buf) {
10342 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10343 return QDF_STATUS_E_FAILURE;
10344 }
10345
10346 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10347 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
10348 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
10349
10350 cmd->vdev_id = param->vdev_id;
10351 cmd->enable_override = 0;
10352
10353 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10354 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10355 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10356 WMI_LOGE("Failed to set dscp cmd\n");
10357 wmi_buf_free(buf);
10358 return QDF_STATUS_E_FAILURE;
10359 }
10360
10361 return QDF_STATUS_SUCCESS;
10362}
10363
10364/**
10365 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10366 * @wmi_handle: wmi handle
10367 * @macaddr: vdev mac address
10368 * @param: pointer to hold neigbour rx param
10369 *
10370 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10371 */
10372static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10373 uint8_t macaddr[IEEE80211_ADDR_LEN],
10374 struct set_neighbour_rx_params *param)
10375{
10376 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10377 wmi_buf_t buf;
10378 int32_t len = sizeof(*cmd);
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 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10386 WMITLV_SET_HDR(&cmd->tlv_header,
10387 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10388 WMITLV_GET_STRUCT_TLVLEN(
10389 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10390 cmd->vdev_id = param->vdev_id;
10391 cmd->bssid_idx = param->idx;
10392 cmd->action = param->action;
10393 cmd->type = param->type;
10394 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10395 cmd->flag = 0;
10396
10397 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10398 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10399 WMI_LOGE("Failed to set neighbour rx param\n");
10400 wmi_buf_free(buf);
10401 return QDF_STATUS_E_FAILURE;
10402 }
10403
10404 return QDF_STATUS_SUCCESS;
10405}
10406
10407/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010408 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010409 * @param wmi_handle : handle to WMI.
10410 * @param macaddr : vdev mac address
10411 * @param param : pointer to tx antenna param
10412 *
10413 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10414 */
10415static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10416 uint8_t macaddr[IEEE80211_ADDR_LEN],
10417 struct smart_ant_tx_ant_params *param)
10418{
10419 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10420 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10421 wmi_buf_t buf;
10422 int32_t len = 0;
10423 int i;
10424 uint8_t *buf_ptr;
10425 QDF_STATUS ret;
10426
10427 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10428 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10429 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10430 buf = wmi_buf_alloc(wmi_handle, len);
10431
10432 if (!buf) {
10433 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10434 return QDF_STATUS_E_NOMEM;
10435 }
10436
10437 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10438 qdf_mem_zero(buf_ptr, len);
10439 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10440
10441 WMITLV_SET_HDR(&cmd->tlv_header,
10442 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10443 WMITLV_GET_STRUCT_TLVLEN(
10444 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10445
10446 cmd->vdev_id = param->vdev_id;
10447 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10448
10449 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10451 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10452 buf_ptr += WMI_TLV_HDR_SIZE;
10453 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10454
10455 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10456 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10457 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10458 WMITLV_GET_STRUCT_TLVLEN(
10459 wmi_peer_smart_ant_set_tx_antenna_series));
10460 ant_tx_series->antenna_series = param->antenna_array[i];
10461 ant_tx_series++;
10462 }
10463
10464 ret = wmi_unified_cmd_send(wmi_handle,
10465 buf,
10466 len,
10467 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10468
10469 if (ret != 0) {
10470 WMI_LOGE(" %s :WMI Failed\n", __func__);
10471 wmi_buf_free(buf);
10472 }
10473
10474 return ret;
10475}
10476
Sathish Kumar02c3b542017-02-22 17:24:45 +053010477/**
10478 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10479 * @wmi_handle: wmi handle
10480 * @param: pointer to hold ant switch tbl param
10481 *
10482 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10483 */
10484static QDF_STATUS
10485send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10486 struct ant_switch_tbl_params *param)
10487{
10488 uint8_t len;
10489 wmi_buf_t buf;
10490 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10491 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10492 uint8_t *buf_ptr;
10493
10494 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10495 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10496 buf = wmi_buf_alloc(wmi_handle, len);
10497
10498 if (!buf) {
10499 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10500 return QDF_STATUS_E_NOMEM;
10501 }
10502
10503 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10504 qdf_mem_zero(buf_ptr, len);
10505 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10506
10507 WMITLV_SET_HDR(&cmd->tlv_header,
10508 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10509 WMITLV_GET_STRUCT_TLVLEN(
10510 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10511
10512 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10513 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010514 cmd->mac_id =
10515 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010516
10517 /* TLV indicating array of structures to follow */
10518 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10520 sizeof(wmi_pdev_set_ant_ctrl_chain));
10521 buf_ptr += WMI_TLV_HDR_SIZE;
10522 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10523
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010524 ctrl_chain->pdev_id =
10525 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010526 ctrl_chain->antCtrlChain = param->antCtrlChain;
10527
10528 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10529 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10530 wmi_buf_free(buf);
10531 return QDF_STATUS_E_FAILURE;
10532 }
10533
10534 return QDF_STATUS_SUCCESS;
10535}
10536
10537/**
10538 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10539 * training information function
10540 * @param wmi_handle : handle to WMI.
10541 * @macaddr : vdev mac address
10542 * @param param : pointer to tx antenna param
10543 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10544 */
10545static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10546 wmi_unified_t wmi_handle,
10547 uint8_t macaddr[IEEE80211_ADDR_LEN],
10548 struct smart_ant_training_info_params *param)
10549{
10550 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10551 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10552 wmi_buf_t buf;
10553 uint8_t *buf_ptr;
10554 int32_t len = 0;
10555 QDF_STATUS ret;
10556 int loop;
10557
10558 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10559 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10560 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10561 buf = wmi_buf_alloc(wmi_handle, len);
10562
10563 if (!buf) {
10564 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10565 return QDF_STATUS_E_NOMEM;
10566 }
10567
10568 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10569 qdf_mem_zero(buf_ptr, len);
10570 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10571
10572 WMITLV_SET_HDR(&cmd->tlv_header,
10573 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10574 WMITLV_GET_STRUCT_TLVLEN(
10575 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10576
10577 cmd->vdev_id = param->vdev_id;
10578 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10579 cmd->num_pkts = param->numpkts;
10580
10581 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10582 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10583 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10584 WMI_SMART_ANT_MAX_RATE_SERIES);
10585
10586 buf_ptr += WMI_TLV_HDR_SIZE;
10587 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10588
10589 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10590 WMITLV_SET_HDR(&train_param->tlv_header,
10591 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10592 WMITLV_GET_STRUCT_TLVLEN(
10593 wmi_peer_smart_ant_set_train_antenna_param));
10594 train_param->train_rate_series = param->rate_array[loop];
10595 train_param->train_antenna_series = param->antenna_array[loop];
10596 train_param->rc_flags = 0;
10597 WMI_LOGI(FL("Series number:%d\n"), loop);
10598 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10599 train_param->train_rate_series,
10600 train_param->train_antenna_series);
10601 train_param++;
10602 }
10603
10604 ret = wmi_unified_cmd_send(wmi_handle,
10605 buf,
10606 len,
10607 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10608
10609 if (ret != 0) {
10610 WMI_LOGE(" %s :WMI Failed\n", __func__);
10611 wmi_buf_free(buf);
10612 return QDF_STATUS_E_FAILURE;
10613 }
10614
10615 return ret;
10616}
10617
10618/**
10619 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10620 * configuration function
10621 * @param wmi_handle : handle to WMI.
10622 * @macaddr : vdev mad address
10623 * @param param : pointer to tx antenna param
10624 *
10625 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10626 */
10627static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10628 wmi_unified_t wmi_handle,
10629 uint8_t macaddr[IEEE80211_ADDR_LEN],
10630 struct smart_ant_node_config_params *param)
10631{
10632 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10633 wmi_buf_t buf;
10634 uint8_t *buf_ptr;
10635 int32_t len = 0, args_tlv_len;
10636 int ret;
10637 int i = 0;
10638 A_UINT32 *node_config_args;
10639
10640 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10641 len = sizeof(*cmd) + args_tlv_len;
10642
10643 if ((param->args_count == 0)) {
10644 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10645 __func__, param->args_count);
10646 return QDF_STATUS_E_FAILURE;
10647 }
10648
10649 buf = wmi_buf_alloc(wmi_handle, len);
10650 if (!buf) {
10651 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10652 return QDF_STATUS_E_NOMEM;
10653 }
10654
10655 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10656 wmi_buf_data(buf);
10657 buf_ptr = (uint8_t *)cmd;
10658 WMITLV_SET_HDR(&cmd->tlv_header,
10659 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10660 WMITLV_GET_STRUCT_TLVLEN(
10661 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10662 cmd->vdev_id = param->vdev_id;
10663 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10664 cmd->cmd_id = param->cmd_id;
10665 cmd->args_count = param->args_count;
10666 buf_ptr += sizeof(
10667 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10669 (cmd->args_count * sizeof(A_UINT32)));
10670 buf_ptr += WMI_TLV_HDR_SIZE;
10671 node_config_args = (A_UINT32 *)buf_ptr;
10672
10673 for (i = 0; i < param->args_count; i++) {
10674 node_config_args[i] = param->args_arr[i];
10675 WMI_LOGI("%d", param->args_arr[i]);
10676 }
10677
10678 ret = wmi_unified_cmd_send(wmi_handle,
10679 buf,
10680 len,
10681 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10682
10683 if (ret != 0) {
10684 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10685 __func__, param->cmd_id, macaddr[0],
10686 macaddr[1], macaddr[2], macaddr[3],
10687 macaddr[4], macaddr[5], ret);
10688 wmi_buf_free(buf);
10689 }
10690
10691 return ret;
10692}
10693
10694/**
10695 * send_set_atf_cmd_tlv() - send set atf command to fw
10696 * @wmi_handle: wmi handle
10697 * @param: pointer to set atf param
10698 *
10699 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10700 */
10701static QDF_STATUS
10702send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10703 struct set_atf_params *param)
10704{
10705 wmi_atf_peer_info *peer_info;
10706 wmi_peer_atf_request_fixed_param *cmd;
10707 wmi_buf_t buf;
10708 uint8_t *buf_ptr;
10709 int i;
10710 int32_t len = 0;
10711 QDF_STATUS retval;
10712
10713 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10714 len += param->num_peers * sizeof(wmi_atf_peer_info);
10715 buf = wmi_buf_alloc(wmi_handle, len);
10716 if (!buf) {
10717 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10718 return QDF_STATUS_E_FAILURE;
10719 }
10720 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10721 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10722 WMITLV_SET_HDR(&cmd->tlv_header,
10723 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10724 WMITLV_GET_STRUCT_TLVLEN(
10725 wmi_peer_atf_request_fixed_param));
10726 cmd->num_peers = param->num_peers;
10727
10728 buf_ptr += sizeof(*cmd);
10729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10730 sizeof(wmi_atf_peer_info) *
10731 cmd->num_peers);
10732 buf_ptr += WMI_TLV_HDR_SIZE;
10733 peer_info = (wmi_atf_peer_info *)buf_ptr;
10734
10735 for (i = 0; i < cmd->num_peers; i++) {
10736 WMITLV_SET_HDR(&peer_info->tlv_header,
10737 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10738 WMITLV_GET_STRUCT_TLVLEN(
10739 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010740 qdf_mem_copy(&(peer_info->peer_macaddr),
10741 &(param->peer_info[i].peer_macaddr),
10742 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010743 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010744 peer_info->vdev_id = param->peer_info[i].vdev_id;
10745 peer_info->pdev_id =
10746 wmi_handle->ops->convert_pdev_id_host_to_target(
10747 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010748 /*
10749 * TLV definition for peer atf request fixed param combines
10750 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10751 * stats and atf extension stats as two different
10752 * implementations.
10753 * Need to discuss with FW on this.
10754 *
10755 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10756 * peer_info->atf_units_reserved =
10757 * param->peer_ext_info[i].atf_index_reserved;
10758 */
10759 peer_info++;
10760 }
10761
10762 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10763 WMI_PEER_ATF_REQUEST_CMDID);
10764
10765 if (retval != QDF_STATUS_SUCCESS) {
10766 WMI_LOGE("%s : WMI Failed\n", __func__);
10767 wmi_buf_free(buf);
10768 }
10769
10770 return retval;
10771}
10772
10773/**
10774 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10775 * @wmi_handle: wmi handle
10776 * @param: pointer to hold fwtest param
10777 *
10778 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10779 */
10780static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10781 struct set_fwtest_params *param)
10782{
10783 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10784 wmi_buf_t buf;
10785 int32_t len = sizeof(*cmd);
10786
10787 buf = wmi_buf_alloc(wmi_handle, len);
10788
10789 if (!buf) {
10790 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10791 return QDF_STATUS_E_FAILURE;
10792 }
10793
10794 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10795 WMITLV_SET_HDR(&cmd->tlv_header,
10796 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10797 WMITLV_GET_STRUCT_TLVLEN(
10798 wmi_fwtest_set_param_cmd_fixed_param));
10799 cmd->param_id = param->arg;
10800 cmd->param_value = param->value;
10801
10802 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10803 WMI_LOGE("Setting FW test param failed\n");
10804 wmi_buf_free(buf);
10805 return QDF_STATUS_E_FAILURE;
10806 }
10807
10808 return QDF_STATUS_SUCCESS;
10809}
10810
10811/**
10812 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10813 * @wmi_handle: wmi handle
10814 * @param: pointer to qboost params
10815 * @macaddr: vdev mac address
10816 *
10817 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10818 */
10819static QDF_STATUS
10820send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10821 uint8_t macaddr[IEEE80211_ADDR_LEN],
10822 struct set_qboost_params *param)
10823{
10824 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10825 wmi_buf_t buf;
10826 int32_t len;
10827 QDF_STATUS ret;
10828
10829 len = sizeof(*cmd);
10830
10831 buf = wmi_buf_alloc(wmi_handle, len);
10832 if (!buf) {
10833 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10834 return QDF_STATUS_E_FAILURE;
10835 }
10836
10837 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10838 WMITLV_SET_HDR(&cmd->tlv_header,
10839 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10840 WMITLV_GET_STRUCT_TLVLEN(
10841 WMI_QBOOST_CFG_CMD_fixed_param));
10842 cmd->vdev_id = param->vdev_id;
10843 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10844 cmd->qb_enable = param->value;
10845
10846 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10847 WMI_QBOOST_CFG_CMDID);
10848
10849 if (ret != 0) {
10850 WMI_LOGE("Setting qboost cmd failed\n");
10851 wmi_buf_free(buf);
10852 }
10853
10854 return ret;
10855}
10856
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010857/**
10858 * send_gpio_config_cmd_tlv() - send gpio config to fw
10859 * @wmi_handle: wmi handle
10860 * @param: pointer to hold gpio config param
10861 *
10862 * Return: 0 for success or error code
10863 */
10864static QDF_STATUS
10865send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10866 struct gpio_config_params *param)
10867{
10868 wmi_gpio_config_cmd_fixed_param *cmd;
10869 wmi_buf_t buf;
10870 int32_t len;
10871 QDF_STATUS ret;
10872
10873 len = sizeof(*cmd);
10874
10875 /* Sanity Checks */
10876 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10877 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10878 return QDF_STATUS_E_FAILURE;
10879 }
10880
10881 buf = wmi_buf_alloc(wmi_handle, len);
10882 if (!buf) {
10883 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10884 return QDF_STATUS_E_FAILURE;
10885 }
10886
10887 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10888 WMITLV_SET_HDR(&cmd->tlv_header,
10889 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10890 WMITLV_GET_STRUCT_TLVLEN(
10891 wmi_gpio_config_cmd_fixed_param));
10892 cmd->gpio_num = param->gpio_num;
10893 cmd->input = param->input;
10894 cmd->pull_type = param->pull_type;
10895 cmd->intr_mode = param->intr_mode;
10896
10897 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10898 WMI_GPIO_CONFIG_CMDID);
10899
10900 if (ret != 0) {
10901 WMI_LOGE("Sending GPIO config cmd failed\n");
10902 wmi_buf_free(buf);
10903 }
10904
10905 return ret;
10906}
10907
10908/**
10909 * send_gpio_output_cmd_tlv() - send gpio output to fw
10910 * @wmi_handle: wmi handle
10911 * @param: pointer to hold gpio output param
10912 *
10913 * Return: 0 for success or error code
10914 */
10915static QDF_STATUS
10916send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10917 struct gpio_output_params *param)
10918{
10919 wmi_gpio_output_cmd_fixed_param *cmd;
10920 wmi_buf_t buf;
10921 int32_t len;
10922 QDF_STATUS ret;
10923
10924 len = sizeof(*cmd);
10925
10926 buf = wmi_buf_alloc(wmi_handle, len);
10927 if (!buf) {
10928 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10929 return QDF_STATUS_E_FAILURE;
10930 }
10931
10932 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10933 WMITLV_SET_HDR(&cmd->tlv_header,
10934 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10935 WMITLV_GET_STRUCT_TLVLEN(
10936 wmi_gpio_output_cmd_fixed_param));
10937 cmd->gpio_num = param->gpio_num;
10938 cmd->set = param->set;
10939
10940 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10941 WMI_GPIO_OUTPUT_CMDID);
10942
10943 if (ret != 0) {
10944 WMI_LOGE("Sending GPIO output cmd failed\n");
10945 wmi_buf_free(buf);
10946 }
10947
10948 return ret;
10949
10950}
10951
10952/**
10953 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10954 *
10955 * @param wmi_handle : handle to WMI.
10956 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10957 */
10958static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10959{
10960 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10961 wmi_buf_t buf;
10962 QDF_STATUS ret;
10963 int32_t len;
10964
10965 len = sizeof(*cmd);
10966
10967 buf = wmi_buf_alloc(wmi_handle, len);
10968 if (!buf) {
10969 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10970 return QDF_STATUS_E_FAILURE;
10971 }
10972
10973 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10974 WMITLV_SET_HDR(&cmd->tlv_header,
10975 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10976 WMITLV_GET_STRUCT_TLVLEN(
10977 wmi_pdev_dfs_disable_cmd_fixed_param));
10978 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010979 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10980 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010981
10982 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10983 WMI_PDEV_DFS_DISABLE_CMDID);
10984
10985 if (ret != 0) {
10986 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10987 wmi_buf_free(buf);
10988 }
10989
10990 return ret;
10991}
10992
10993/**
10994 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10995 *
10996 * @param wmi_handle : handle to WMI.
10997 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10998 */
10999static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11000{
11001 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11002 wmi_buf_t buf;
11003 QDF_STATUS ret;
11004 int32_t len;
11005
11006 len = sizeof(*cmd);
11007
11008 buf = wmi_buf_alloc(wmi_handle, len);
11009 if (!buf) {
11010 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11011 return QDF_STATUS_E_FAILURE;
11012 }
11013
11014 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11015 WMITLV_SET_HDR(&cmd->tlv_header,
11016 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11017 WMITLV_GET_STRUCT_TLVLEN(
11018 wmi_pdev_dfs_enable_cmd_fixed_param));
11019 /* Reserved for future use */
11020 cmd->reserved0 = 0;
11021
11022 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11023 WMI_PDEV_DFS_ENABLE_CMDID);
11024
11025 if (ret != 0) {
11026 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11027 wmi_buf_free(buf);
11028 }
11029
11030 return ret;
11031}
11032
11033/**
11034 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11035 * @wmi_handle: wmi handle
11036 *
11037 * Return: 0 for success or error code
11038 */
11039static QDF_STATUS
11040send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
11041{
11042 wmi_buf_t buf;
11043 QDF_STATUS ret;
11044
11045 buf = wmi_buf_alloc(wmi_handle, 0);
11046 if (buf == NULL)
11047 return QDF_STATUS_E_NOMEM;
11048
11049 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
11050 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11051 if (ret != 0) {
11052 WMI_LOGE("Sending get nfcal power cmd failed\n");
11053 wmi_buf_free(buf);
11054 }
11055
11056 return ret;
11057}
11058
11059/**
11060 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11061 * @wmi_handle: wmi handle
11062 * @param: pointer to ht ie param
11063 *
11064 * Return: 0 for success or error code
11065 */
11066static QDF_STATUS
11067send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11068 struct ht_ie_params *param)
11069{
11070 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11071 wmi_buf_t buf;
11072 QDF_STATUS ret;
11073 int32_t len;
11074 uint8_t *buf_ptr;
11075
11076 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11077 roundup(param->ie_len, sizeof(uint32_t));
11078
11079 buf = wmi_buf_alloc(wmi_handle, len);
11080 if (!buf) {
11081 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11082 return QDF_STATUS_E_FAILURE;
11083 }
11084
11085 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11086 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11087 WMITLV_SET_HDR(&cmd->tlv_header,
11088 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11089 WMITLV_GET_STRUCT_TLVLEN(
11090 wmi_pdev_set_ht_ie_cmd_fixed_param));
11091 cmd->reserved0 = 0;
11092 cmd->ie_len = param->ie_len;
11093 cmd->tx_streams = param->tx_streams;
11094 cmd->rx_streams = param->rx_streams;
11095
11096 buf_ptr += sizeof(*cmd);
11097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11098 buf_ptr += WMI_TLV_HDR_SIZE;
11099 if (param->ie_len)
11100 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11101 cmd->ie_len);
11102
11103 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11104 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11105
11106 if (ret != 0) {
11107 WMI_LOGE("Sending set ht ie cmd failed\n");
11108 wmi_buf_free(buf);
11109 }
11110
11111 return ret;
11112}
11113
11114/**
11115 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11116 * @wmi_handle: wmi handle
11117 * @param: pointer to vht ie param
11118 *
11119 * Return: 0 for success or error code
11120 */
11121static QDF_STATUS
11122send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11123 struct vht_ie_params *param)
11124{
11125 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11126 wmi_buf_t buf;
11127 QDF_STATUS ret;
11128 int32_t len;
11129 uint8_t *buf_ptr;
11130
11131 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11132 roundup(param->ie_len, sizeof(uint32_t));
11133
11134 buf = wmi_buf_alloc(wmi_handle, len);
11135 if (!buf) {
11136 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11137 return QDF_STATUS_E_FAILURE;
11138 }
11139
11140 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11141 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11142 WMITLV_SET_HDR(&cmd->tlv_header,
11143 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11144 WMITLV_GET_STRUCT_TLVLEN(
11145 wmi_pdev_set_vht_ie_cmd_fixed_param));
11146 cmd->reserved0 = 0;
11147 cmd->ie_len = param->ie_len;
11148 cmd->tx_streams = param->tx_streams;
11149 cmd->rx_streams = param->rx_streams;
11150
11151 buf_ptr += sizeof(*cmd);
11152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11153 buf_ptr += WMI_TLV_HDR_SIZE;
11154 if (param->ie_len)
11155 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11156 cmd->ie_len);
11157
11158 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11159 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11160
11161 if (ret != 0) {
11162 WMI_LOGE("Sending set vht ie cmd failed\n");
11163 wmi_buf_free(buf);
11164 }
11165
11166 return ret;
11167}
11168
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011169/**
11170 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11171 * @wmi_handle: wmi handle
11172 * @param: pointer to quiet mode params
11173 *
11174 * Return: 0 for success or error code
11175 */
11176static QDF_STATUS
11177send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11178 struct set_quiet_mode_params *param)
11179{
11180 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11181 wmi_buf_t buf;
11182 QDF_STATUS ret;
11183 int32_t len;
11184
11185 len = sizeof(*quiet_cmd);
11186 buf = wmi_buf_alloc(wmi_handle, len);
11187 if (!buf) {
11188 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11189 return QDF_STATUS_E_FAILURE;
11190 }
11191
11192 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11193 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11194 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11195 WMITLV_GET_STRUCT_TLVLEN(
11196 wmi_pdev_set_quiet_cmd_fixed_param));
11197 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11198 quiet_cmd->enabled = param->enabled;
11199 quiet_cmd->period = (param->period)*(param->intval);
11200 quiet_cmd->duration = param->duration;
11201 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011202 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11203 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011204
11205 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11206 WMI_PDEV_SET_QUIET_MODE_CMDID);
11207
11208 if (ret != 0) {
11209 WMI_LOGE("Sending set quiet cmd failed\n");
11210 wmi_buf_free(buf);
11211 }
11212
11213 return ret;
11214}
11215
11216/**
11217 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11218 * @wmi_handle: wmi handle
11219 * @param: pointer to set bwf param
11220 *
11221 * Return: 0 for success or error code
11222 */
11223static QDF_STATUS
11224send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11225 struct set_bwf_params *param)
11226{
11227 wmi_bwf_peer_info *peer_info;
11228 wmi_peer_bwf_request_fixed_param *cmd;
11229 wmi_buf_t buf;
11230 QDF_STATUS retval;
11231 int32_t len;
11232 uint8_t *buf_ptr;
11233 int i;
11234
11235 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11236 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11237 buf = wmi_buf_alloc(wmi_handle, len);
11238 if (!buf) {
11239 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11240 return QDF_STATUS_E_FAILURE;
11241 }
11242 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11243 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11244 WMITLV_SET_HDR(&cmd->tlv_header,
11245 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11246 WMITLV_GET_STRUCT_TLVLEN(
11247 wmi_peer_bwf_request_fixed_param));
11248 cmd->num_peers = param->num_peers;
11249
11250 buf_ptr += sizeof(*cmd);
11251 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11252 sizeof(wmi_bwf_peer_info) *
11253 cmd->num_peers);
11254 buf_ptr += WMI_TLV_HDR_SIZE;
11255 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11256
11257 for (i = 0; i < cmd->num_peers; i++) {
11258 WMITLV_SET_HDR(&peer_info->tlv_header,
11259 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11260 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11261 peer_info->bwf_guaranteed_bandwidth =
11262 param->peer_info[i].throughput;
11263 peer_info->bwf_max_airtime =
11264 param->peer_info[i].max_airtime;
11265 peer_info->bwf_peer_priority =
11266 param->peer_info[i].priority;
11267 qdf_mem_copy(&peer_info->peer_macaddr,
11268 &param->peer_info[i].peer_macaddr,
11269 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011270 peer_info->vdev_id =
11271 param->peer_info[i].vdev_id;
11272 peer_info->pdev_id =
11273 wmi_handle->ops->convert_pdev_id_host_to_target(
11274 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011275 peer_info++;
11276 }
11277
11278 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11279 WMI_PEER_BWF_REQUEST_CMDID);
11280
11281 if (retval != QDF_STATUS_SUCCESS) {
11282 WMI_LOGE("%s : WMI Failed\n", __func__);
11283 wmi_buf_free(buf);
11284 }
11285
11286 return retval;
11287}
11288
11289/**
11290 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11291 * @wmi_handle: wmi handle
11292 * @param: pointer to hold mcast update param
11293 *
11294 * Return: 0 for success or error code
11295 */
11296static QDF_STATUS
11297send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11298 struct mcast_group_update_params *param)
11299{
11300 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11301 wmi_buf_t buf;
11302 QDF_STATUS ret;
11303 int32_t len;
11304 int offset = 0;
11305 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11306
11307 len = sizeof(*cmd);
11308 buf = wmi_buf_alloc(wmi_handle, len);
11309 if (!buf) {
11310 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11311 return QDF_STATUS_E_FAILURE;
11312 }
11313 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11314 WMITLV_SET_HDR(&cmd->tlv_header,
11315 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11316 WMITLV_GET_STRUCT_TLVLEN(
11317 wmi_peer_mcast_group_cmd_fixed_param));
11318 /* confirm the buffer is 4-byte aligned */
11319 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11320 qdf_mem_zero(cmd, sizeof(*cmd));
11321
11322 cmd->vdev_id = param->vap_id;
11323 /* construct the message assuming our endianness matches the target */
11324 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11325 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11326 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11327 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11328 if (param->is_action_delete)
11329 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11330
11331 if (param->is_mcast_addr_len)
11332 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11333
11334 if (param->is_filter_mode_snoop)
11335 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11336
11337 /* unicast address spec only applies for non-wildcard cases */
11338 if (!param->wildcard && param->ucast_mac_addr) {
11339 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11340 &cmd->ucast_mac_addr);
11341 }
11342 if (param->mcast_ip_addr) {
11343 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11344 sizeof(cmd->mcast_ip_addr));
11345 offset = sizeof(cmd->mcast_ip_addr) -
11346 param->mcast_ip_addr_bytes;
11347 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11348 param->mcast_ip_addr,
11349 param->mcast_ip_addr_bytes);
11350 }
11351 if (!param->mask)
11352 param->mask = &dummymask[0];
11353
11354 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11355 param->mask,
11356 param->mcast_ip_addr_bytes);
11357
11358 if (param->srcs && param->nsrcs) {
11359 cmd->num_filter_addr = param->nsrcs;
11360 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11361 sizeof(cmd->filter_addr));
11362
11363 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11364 param->nsrcs * param->mcast_ip_addr_bytes);
11365 }
11366
11367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11368 WMI_PEER_MCAST_GROUP_CMDID);
11369
11370 if (ret != QDF_STATUS_SUCCESS) {
11371 WMI_LOGE("%s : WMI Failed\n", __func__);
11372 wmi_buf_free(buf);
11373 }
11374
11375 return ret;
11376}
11377
11378/**
11379 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
11380 * command to fw
11381 * @wmi_handle: wmi handle
11382 * @param: pointer to hold spectral config parameter
11383 *
11384 * Return: 0 for success or error code
11385 */
11386static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
11387 struct vdev_spectral_configure_params *param)
11388{
11389 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
11390 wmi_buf_t buf;
11391 QDF_STATUS ret;
11392 int32_t len;
11393
11394 len = sizeof(*cmd);
11395 buf = wmi_buf_alloc(wmi_handle, len);
11396 if (!buf) {
11397 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11398 return QDF_STATUS_E_FAILURE;
11399 }
11400
11401 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
11402 WMITLV_SET_HDR(&cmd->tlv_header,
11403 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11404 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011405 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011406
11407 cmd->vdev_id = param->vdev_id;
11408 cmd->spectral_scan_count = param->count;
11409 cmd->spectral_scan_period = param->period;
11410 cmd->spectral_scan_priority = param->spectral_pri;
11411 cmd->spectral_scan_fft_size = param->fft_size;
11412 cmd->spectral_scan_gc_ena = param->gc_enable;
11413 cmd->spectral_scan_restart_ena = param->restart_enable;
11414 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11415 cmd->spectral_scan_init_delay = param->init_delay;
11416 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11417 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11418 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11419 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11420 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11421 cmd->spectral_scan_pwr_format = param->pwr_format;
11422 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11423 cmd->spectral_scan_bin_scale = param->bin_scale;
11424 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11425 cmd->spectral_scan_chn_mask = param->chn_mask;
11426
11427 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11428 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11429
11430 if (ret != 0) {
11431 WMI_LOGE("Sending set quiet cmd failed\n");
11432 wmi_buf_free(buf);
11433 }
11434
11435 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11436 __func__);
11437
11438 WMI_LOGI("vdev_id = %u\n"
11439 "spectral_scan_count = %u\n"
11440 "spectral_scan_period = %u\n"
11441 "spectral_scan_priority = %u\n"
11442 "spectral_scan_fft_size = %u\n"
11443 "spectral_scan_gc_ena = %u\n"
11444 "spectral_scan_restart_ena = %u\n"
11445 "spectral_scan_noise_floor_ref = %u\n"
11446 "spectral_scan_init_delay = %u\n"
11447 "spectral_scan_nb_tone_thr = %u\n"
11448 "spectral_scan_str_bin_thr = %u\n"
11449 "spectral_scan_wb_rpt_mode = %u\n"
11450 "spectral_scan_rssi_rpt_mode = %u\n"
11451 "spectral_scan_rssi_thr = %u\n"
11452 "spectral_scan_pwr_format = %u\n"
11453 "spectral_scan_rpt_mode = %u\n"
11454 "spectral_scan_bin_scale = %u\n"
11455 "spectral_scan_dBm_adj = %u\n"
11456 "spectral_scan_chn_mask = %u\n",
11457 param->vdev_id,
11458 param->count,
11459 param->period,
11460 param->spectral_pri,
11461 param->fft_size,
11462 param->gc_enable,
11463 param->restart_enable,
11464 param->noise_floor_ref,
11465 param->init_delay,
11466 param->nb_tone_thr,
11467 param->str_bin_thr,
11468 param->wb_rpt_mode,
11469 param->rssi_rpt_mode,
11470 param->rssi_thr,
11471 param->pwr_format,
11472 param->rpt_mode,
11473 param->bin_scale,
11474 param->dBm_adj,
11475 param->chn_mask);
11476 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11477
11478 return ret;
11479}
11480
11481/**
11482 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11483 * command to fw
11484 * @wmi_handle: wmi handle
11485 * @param: pointer to hold spectral enable parameter
11486 *
11487 * Return: 0 for success or error code
11488 */
11489static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11490 struct vdev_spectral_enable_params *param)
11491{
11492 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11493 wmi_buf_t buf;
11494 QDF_STATUS ret;
11495 int32_t len;
11496
11497 len = sizeof(*cmd);
11498 buf = wmi_buf_alloc(wmi_handle, len);
11499 if (!buf) {
11500 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11501 return QDF_STATUS_E_FAILURE;
11502 }
11503
11504 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11505 WMITLV_SET_HDR(&cmd->tlv_header,
11506 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11507 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053011508 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011509
11510 cmd->vdev_id = param->vdev_id;
11511
11512 if (param->active_valid) {
11513 cmd->trigger_cmd = param->active ? 1 : 2;
11514 /* 1: Trigger, 2: Clear Trigger */
11515 } else {
11516 cmd->trigger_cmd = 0; /* 0: Ignore */
11517 }
11518
11519 if (param->enabled_valid) {
11520 cmd->enable_cmd = param->enabled ? 1 : 2;
11521 /* 1: Enable 2: Disable */
11522 } else {
11523 cmd->enable_cmd = 0; /* 0: Ignore */
11524 }
11525
11526 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11527 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11528
11529 if (ret != 0) {
11530 WMI_LOGE("Sending scan enable CMD failed\n");
11531 wmi_buf_free(buf);
11532 }
11533
11534 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11535
11536 WMI_LOGI("vdev_id = %u\n"
11537 "trigger_cmd = %u\n"
11538 "enable_cmd = %u\n",
11539 cmd->vdev_id,
11540 cmd->trigger_cmd,
11541 cmd->enable_cmd);
11542
11543 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11544
11545 return ret;
11546}
11547
11548/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011549 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11550 * @param wmi_handle : handle to WMI.
11551 * @param param : pointer to hold thermal mitigation param
11552 *
11553 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11554 */
11555static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11556 wmi_unified_t wmi_handle,
11557 struct thermal_mitigation_params *param)
11558{
11559 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11560 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11561 wmi_buf_t buf = NULL;
11562 uint8_t *buf_ptr = NULL;
11563 int error;
11564 int32_t len;
11565 int i;
11566
11567 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11568 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11569
11570 buf = wmi_buf_alloc(wmi_handle, len);
11571 if (!buf) {
11572 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11573 return QDF_STATUS_E_NOMEM;
11574 }
11575 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11576
11577 /* init fixed params */
11578 WMITLV_SET_HDR(tt_conf,
11579 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11580 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11581
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011582 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11583 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011584 tt_conf->enable = param->enable;
11585 tt_conf->dc = param->dc;
11586 tt_conf->dc_per_event = param->dc_per_event;
11587 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11588
11589 buf_ptr = (uint8_t *) ++tt_conf;
11590 /* init TLV params */
11591 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11592 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11593
11594 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11595 for (i = 0; i < THERMAL_LEVELS; i++) {
11596 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11597 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11598 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11599 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11600 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11601 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11602 lvl_conf->prio = param->levelconf[i].priority;
11603 lvl_conf++;
11604 }
11605
11606 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11607 WMI_THERM_THROT_SET_CONF_CMDID);
11608 if (QDF_IS_STATUS_ERROR(error)) {
11609 wmi_buf_free(buf);
11610 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11611 }
11612
11613 return error;
11614}
11615
11616/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011617 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11618 * @wmi_handle: wmi handle
11619 * @param: pointer to pdev_qvit_params
11620 *
11621 * Return: 0 for success or error code
11622 */
11623static QDF_STATUS
11624send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11625 struct pdev_qvit_params *param)
11626{
11627 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011628 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011629 uint8_t *cmd;
11630 static uint8_t msgref = 1;
11631 uint8_t segnumber = 0, seginfo, numsegments;
11632 uint16_t chunk_len, total_bytes;
11633 uint8_t *bufpos;
11634 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11635
11636 bufpos = param->utf_payload;
11637 total_bytes = param->len;
11638 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11639 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11640 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11641
11642 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11643 numsegments++;
11644
11645 while (param->len) {
11646 if (param->len > MAX_WMI_QVIT_LEN)
11647 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11648 else
11649 chunk_len = param->len;
11650
11651 buf = wmi_buf_alloc(wmi_handle,
11652 (chunk_len + sizeof(seghdrinfo) +
11653 WMI_TLV_HDR_SIZE));
11654 if (!buf) {
11655 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11656 return QDF_STATUS_E_NOMEM;
11657 }
11658
11659 cmd = (uint8_t *) wmi_buf_data(buf);
11660
11661 seghdrinfo.len = total_bytes;
11662 seghdrinfo.msgref = msgref;
11663 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11664 seghdrinfo.segmentInfo = seginfo;
11665
11666 segnumber++;
11667
11668 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11669 (chunk_len + sizeof(seghdrinfo)));
11670 cmd += WMI_TLV_HDR_SIZE;
11671 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11672 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11673
11674 ret = wmi_unified_cmd_send(wmi_handle, buf,
11675 (chunk_len + sizeof(seghdrinfo) +
11676 WMI_TLV_HDR_SIZE),
11677 WMI_PDEV_QVIT_CMDID);
11678
11679 if (ret != 0) {
11680 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11681 wmi_buf_free(buf);
11682 break;
11683 }
11684
11685 param->len -= chunk_len;
11686 bufpos += chunk_len;
11687 }
11688 msgref++;
11689
11690 return ret;
11691}
11692
11693/**
11694 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11695 * @wmi_handle: wmi handle
11696 * @param: pointer to wmm update param
11697 *
11698 * Return: 0 for success or error code
11699 */
11700static QDF_STATUS
11701send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11702 struct wmm_update_params *param)
11703{
11704 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11705 wmi_wmm_params *wmm_param;
11706 wmi_buf_t buf;
11707 QDF_STATUS ret;
11708 int32_t len;
11709 int ac = 0;
11710 struct wmi_host_wmeParams *wmep;
11711 uint8_t *buf_ptr;
11712
11713 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11714 buf = wmi_buf_alloc(wmi_handle, len);
11715 if (!buf) {
11716 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11717 return QDF_STATUS_E_FAILURE;
11718 }
11719
11720 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11721 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11722 WMITLV_SET_HDR(&cmd->tlv_header,
11723 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11724 WMITLV_GET_STRUCT_TLVLEN
11725 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11726
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011727 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011728
11729 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11730
11731 for (ac = 0; ac < WME_NUM_AC; ac++) {
11732 wmep = &param->wmep_array[ac];
11733 wmm_param = (wmi_wmm_params *)buf_ptr;
11734 WMITLV_SET_HDR(&wmm_param->tlv_header,
11735 WMITLV_TAG_STRUC_wmi_wmm_params,
11736 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11737 wmm_param->aifs = wmep->wmep_aifsn;
11738 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11739 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11740 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11741 wmm_param->acm = wmep->wmep_acm;
11742 wmm_param->no_ack = wmep->wmep_noackPolicy;
11743 buf_ptr += sizeof(wmi_wmm_params);
11744 }
11745 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11746 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11747
11748 if (ret != 0) {
11749 WMI_LOGE("Sending WMM update CMD failed\n");
11750 wmi_buf_free(buf);
11751 }
11752
11753 return ret;
11754}
11755
Sathish Kumar80f4f382017-04-24 11:36:00 +053011756/**
11757 * send_coex_config_cmd_tlv() - send coex config command to fw
11758 * @wmi_handle: wmi handle
11759 * @param: pointer to coex config param
11760 *
11761 * Return: 0 for success or error code
11762 */
11763static QDF_STATUS
11764send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
11765 struct coex_config_params *param)
11766{
11767 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
11768 wmi_buf_t buf;
11769 QDF_STATUS ret;
11770 int32_t len;
11771
11772 len = sizeof(*cmd);
11773 buf = wmi_buf_alloc(wmi_handle, len);
11774 if (!buf) {
11775 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11776 return QDF_STATUS_E_FAILURE;
11777 }
11778
11779 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
11780 WMITLV_SET_HDR(&cmd->tlv_header,
11781 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
11782 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053011783 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053011784
11785 cmd->vdev_id = param->vdev_id;
11786 cmd->config_type = param->config_type;
11787 cmd->config_arg1 = param->config_arg1;
11788 cmd->config_arg2 = param->config_arg2;
11789 cmd->config_arg3 = param->config_arg3;
11790 cmd->config_arg4 = param->config_arg4;
11791 cmd->config_arg5 = param->config_arg5;
11792 cmd->config_arg6 = param->config_arg6;
11793
11794 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11795 WMI_COEX_CONFIG_CMDID);
11796
11797 if (ret != 0) {
11798 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
11799 wmi_buf_free(buf);
11800 }
11801
11802 return ret;
11803}
11804
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011805static
Govind Singh9ddd5162016-03-07 16:30:32 +053011806void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011807 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011808{
Govind Singhe7f2f342016-05-23 12:12:52 +053011809 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011810 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11811 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11812 resource_cfg->num_offload_reorder_buffs =
11813 tgt_res_cfg->num_offload_reorder_buffs;
11814 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11815 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11816 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11817 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11818 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11819 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11820 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11821 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11822 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11823 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11824 resource_cfg->scan_max_pending_req =
11825 tgt_res_cfg->scan_max_pending_req;
11826 resource_cfg->bmiss_offload_max_vdev =
11827 tgt_res_cfg->bmiss_offload_max_vdev;
11828 resource_cfg->roam_offload_max_vdev =
11829 tgt_res_cfg->roam_offload_max_vdev;
11830 resource_cfg->roam_offload_max_ap_profiles =
11831 tgt_res_cfg->roam_offload_max_ap_profiles;
11832 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11833 resource_cfg->num_mcast_table_elems =
11834 tgt_res_cfg->num_mcast_table_elems;
11835 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11836 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11837 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11838 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11839 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11840 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11841 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11842 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11843 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11844 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11845 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11846 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11847 resource_cfg->num_tdls_conn_table_entries =
11848 tgt_res_cfg->num_tdls_conn_table_entries;
11849 resource_cfg->beacon_tx_offload_max_vdev =
11850 tgt_res_cfg->beacon_tx_offload_max_vdev;
11851 resource_cfg->num_multicast_filter_entries =
11852 tgt_res_cfg->num_multicast_filter_entries;
11853 resource_cfg->num_wow_filters =
11854 tgt_res_cfg->num_wow_filters;
11855 resource_cfg->num_keep_alive_pattern =
11856 tgt_res_cfg->num_keep_alive_pattern;
11857 resource_cfg->keep_alive_pattern_size =
11858 tgt_res_cfg->keep_alive_pattern_size;
11859 resource_cfg->max_tdls_concurrent_sleep_sta =
11860 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11861 resource_cfg->max_tdls_concurrent_buffer_sta =
11862 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11863 resource_cfg->wmi_send_separate =
11864 tgt_res_cfg->wmi_send_separate;
11865 resource_cfg->num_ocb_vdevs =
11866 tgt_res_cfg->num_ocb_vdevs;
11867 resource_cfg->num_ocb_channels =
11868 tgt_res_cfg->num_ocb_channels;
11869 resource_cfg->num_ocb_schedules =
11870 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011871 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11872 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11873 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011874
11875 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
11876 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053011877}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011878#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011879/**
11880 * send_init_cmd_tlv() - wmi init command
11881 * @wmi_handle: pointer to wmi handle
11882 * @res_cfg: resource config
11883 * @num_mem_chunks: no of mem chunck
11884 * @mem_chunk: pointer to mem chunck structure
11885 *
11886 * This function sends IE information to firmware
11887 *
Govind Singhb53420c2016-03-09 14:32:57 +053011888 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011889 *
11890 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011891static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011892 wmi_resource_config *tgt_res_cfg,
11893 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11894 bool action)
11895{
11896 wmi_buf_t buf;
11897 wmi_init_cmd_fixed_param *cmd;
11898 wmi_abi_version my_vers;
11899 int num_whitelist;
11900 uint8_t *buf_ptr;
11901 wmi_resource_config *resource_cfg;
11902 wlan_host_memory_chunk *host_mem_chunks;
11903 uint32_t mem_chunk_len = 0;
11904 uint16_t idx;
11905 int len;
11906 int ret;
11907
11908 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11909 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11910 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011912 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11913 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011914 }
11915
11916 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11917 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11918 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11919
11920 host_mem_chunks = (wlan_host_memory_chunk *)
11921 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11922 + WMI_TLV_HDR_SIZE);
11923
11924 WMITLV_SET_HDR(&cmd->tlv_header,
11925 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11926 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11927
Govind Singhb53420c2016-03-09 14:32:57 +053011928 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011929 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11930 WMITLV_TAG_STRUC_wmi_resource_config,
11931 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11932
11933 for (idx = 0; idx < num_mem_chunks; ++idx) {
11934 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11935 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11936 WMITLV_GET_STRUCT_TLVLEN
11937 (wlan_host_memory_chunk));
11938 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11939 host_mem_chunks[idx].size = mem_chunks[idx].len;
11940 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011941 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011942 idx, host_mem_chunks[idx].size,
11943 host_mem_chunks[idx].ptr);
11944 }
11945 cmd->num_host_mem_chunks = num_mem_chunks;
11946 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11947 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11948 WMITLV_TAG_ARRAY_STRUC,
11949 (sizeof(wlan_host_memory_chunk) *
11950 num_mem_chunks));
11951
11952 num_whitelist = sizeof(version_whitelist) /
11953 sizeof(wmi_whitelist_version_info);
11954 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11955 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11956 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11957 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11958 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11959 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011960#ifdef CONFIG_MCL
11961 /* This needs to be enabled for WIN Lithium after removing dependency
11962 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011963 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11964 &my_vers,
11965 &wmi_handle->fw_abi_version,
11966 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011967#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011968 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011969 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11970 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11971 cmd->host_abi_vers.abi_version_ns_0,
11972 cmd->host_abi_vers.abi_version_ns_1,
11973 cmd->host_abi_vers.abi_version_ns_2,
11974 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011975#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011976 /* Save version sent from host -
11977 * Will be used to check ready event
11978 */
Govind Singhb53420c2016-03-09 14:32:57 +053011979 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011980 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011981#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011982 if (action) {
11983 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11984 WMI_INIT_CMDID);
11985 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011986 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011987 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011988 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011989 }
11990 } else {
11991 wmi_handle->saved_wmi_init_cmd.buf = buf;
11992 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11993 }
11994
Govind Singhb53420c2016-03-09 14:32:57 +053011995 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011996
11997}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011998#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011999/**
12000 * send_saved_init_cmd_tlv() - wmi init command
12001 * @wmi_handle: pointer to wmi handle
12002 *
12003 * This function sends IE information to firmware
12004 *
Govind Singhb53420c2016-03-09 14:32:57 +053012005 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012006 *
12007 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012008static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053012009{
12010 int status;
12011
12012 if (!wmi_handle->saved_wmi_init_cmd.buf ||
12013 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053012014 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
12015 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012016 }
12017 status = wmi_unified_cmd_send(wmi_handle,
12018 wmi_handle->saved_wmi_init_cmd.buf,
12019 wmi_handle->saved_wmi_init_cmd.buf_len,
12020 WMI_INIT_CMDID);
12021 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053012022 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053012023 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012024 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012025 }
12026 wmi_handle->saved_wmi_init_cmd.buf = NULL;
12027 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
12028
Govind Singhb53420c2016-03-09 14:32:57 +053012029 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012030}
12031
Sathish Kumarfd347372017-02-13 12:29:09 +053012032static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012033{
12034 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12035 wmi_service_ready_event_fixed_param *ev;
12036
12037
12038 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12039
12040 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12041 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012042 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012043
Govind Singh87542482016-06-08 19:40:11 +053012044#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012045 /*Save fw version from service ready message */
12046 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012047 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012048 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012049#endif
Govind Singhb53420c2016-03-09 14:32:57 +053012050 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012051}
12052
12053/**
12054 * wmi_unified_save_fw_version_cmd() - save fw version
12055 * @wmi_handle: pointer to wmi handle
12056 * @res_cfg: resource config
12057 * @num_mem_chunks: no of mem chunck
12058 * @mem_chunk: pointer to mem chunck structure
12059 *
12060 * This function sends IE information to firmware
12061 *
Govind Singhb53420c2016-03-09 14:32:57 +053012062 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012063 *
12064 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012065static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012066 void *evt_buf)
12067{
12068 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12069 wmi_ready_event_fixed_param *ev = NULL;
12070
12071 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12072 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053012073#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053012074 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
12075 &ev->fw_abi_vers)) {
12076 /*
12077 * Error: Our host version and the given firmware version
12078 * are incompatible.
12079 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012080 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012081 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12082 __func__,
12083 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12084 abi_version_0),
12085 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12086 abi_version_0),
12087 wmi_handle->final_abi_vers.abi_version_ns_0,
12088 wmi_handle->final_abi_vers.abi_version_ns_1,
12089 wmi_handle->final_abi_vers.abi_version_ns_2,
12090 wmi_handle->final_abi_vers.abi_version_ns_3,
12091 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12092 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12093 ev->fw_abi_vers.abi_version_ns_0,
12094 ev->fw_abi_vers.abi_version_ns_1,
12095 ev->fw_abi_vers.abi_version_ns_2,
12096 ev->fw_abi_vers.abi_version_ns_3);
12097
Govind Singhb53420c2016-03-09 14:32:57 +053012098 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012099 }
Govind Singhb53420c2016-03-09 14:32:57 +053012100 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012101 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012102 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012103 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053012104#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053012105
Govind Singhb53420c2016-03-09 14:32:57 +053012106 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012107}
Govind Singha4836fd2016-03-07 16:45:38 +053012108
12109/**
12110 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12111 * @wmi_handle: wmi handle
12112 * @custom_addr: base mac address
12113 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012114 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012115 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012116static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012117 uint8_t *custom_addr)
12118{
12119 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12120 wmi_buf_t buf;
12121 int err;
12122
12123 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12124 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012125 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012126 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012127 }
12128
12129 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012130 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012131
12132 WMITLV_SET_HDR(&cmd->tlv_header,
12133 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12134 WMITLV_GET_STRUCT_TLVLEN
12135 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12136 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012137 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12138 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012139 err = wmi_unified_cmd_send(wmi_handle, buf,
12140 sizeof(*cmd),
12141 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12142 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012143 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012144 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012145 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012146 }
12147
12148 return 0;
12149}
12150
12151/**
12152 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12153 * @handle: wmi handle
12154 * @event: Event received from FW
12155 * @len: Length of the event
12156 *
12157 * Enables the low frequency events and disables the high frequency
12158 * events. Bit 17 indicates if the event if low/high frequency.
12159 * 1 - high frequency, 0 - low frequency
12160 *
12161 * Return: 0 on successfully enabling/disabling the events
12162 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012163static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012164 uint8_t *event,
12165 uint32_t len)
12166{
12167 uint32_t num_of_diag_events_logs;
12168 wmi_diag_event_log_config_fixed_param *cmd;
12169 wmi_buf_t buf;
12170 uint8_t *buf_ptr;
12171 uint32_t *cmd_args, *evt_args;
12172 uint32_t buf_len, i;
12173
12174 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12175 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12176
Govind Singhb53420c2016-03-09 14:32:57 +053012177 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012178
12179 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12180 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012181 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012182 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012183 }
12184 wmi_event = param_buf->fixed_param;
12185 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
12186 evt_args = param_buf->diag_events_logs_list;
12187 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012188 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012189 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012190 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012191 }
12192
Govind Singhb53420c2016-03-09 14:32:57 +053012193 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012194 __func__, num_of_diag_events_logs);
12195
12196 /* Free any previous allocation */
12197 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012198 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012199
12200 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012201 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012202 sizeof(uint32_t));
12203 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012204 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012205 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012206 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012207 }
12208 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12209
12210 /* Prepare the send buffer */
12211 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12212 (num_of_diag_events_logs * sizeof(uint32_t));
12213
12214 buf = wmi_buf_alloc(wmi_handle, buf_len);
12215 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012216 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12217 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012218 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012219 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012220 }
12221
12222 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12223 buf_ptr = (uint8_t *) cmd;
12224
12225 WMITLV_SET_HDR(&cmd->tlv_header,
12226 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12227 WMITLV_GET_STRUCT_TLVLEN(
12228 wmi_diag_event_log_config_fixed_param));
12229
12230 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12231
12232 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12233
12234 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12235 (num_of_diag_events_logs * sizeof(uint32_t)));
12236
12237 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12238
12239 /* Populate the events */
12240 for (i = 0; i < num_of_diag_events_logs; i++) {
12241 /* Low freq (0) - Enable (1) the event
12242 * High freq (1) - Disable (0) the event
12243 */
12244 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12245 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12246 /* Set the event ID */
12247 WMI_DIAG_ID_SET(cmd_args[i],
12248 WMI_DIAG_ID_GET(evt_args[i]));
12249 /* Set the type */
12250 WMI_DIAG_TYPE_SET(cmd_args[i],
12251 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012252 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012253 wmi_handle->events_logs_list[i] = evt_args[i];
12254 }
12255
12256 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12257 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012258 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012259 __func__);
12260 wmi_buf_free(buf);
12261 /* Not clearing events_logs_list, though wmi cmd failed.
12262 * Host can still have this list
12263 */
Govind Singh67922e82016-04-01 16:48:57 +053012264 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012265 }
12266
12267 return 0;
12268}
12269
12270/**
12271 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12272 * @wmi_handle: wmi handle
12273 * @start_log: Start logging related parameters
12274 *
12275 * Send the command to the FW based on which specific logging of diag
12276 * event/log id can be started/stopped
12277 *
12278 * Return: None
12279 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012280static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012281 struct wmi_wifi_start_log *start_log)
12282{
12283 wmi_diag_event_log_config_fixed_param *cmd;
12284 wmi_buf_t buf;
12285 uint8_t *buf_ptr;
12286 uint32_t len, count, log_level, i;
12287 uint32_t *cmd_args;
12288 uint32_t total_len;
12289 count = 0;
12290
12291 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012292 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012293 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012294 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012295 }
12296 /* total_len stores the number of events where BITS 17 and 18 are set.
12297 * i.e., events of high frequency (17) and for extended debugging (18)
12298 */
12299 total_len = 0;
12300 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12301 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12302 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12303 total_len++;
12304 }
12305
12306 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12307 (total_len * sizeof(uint32_t));
12308
12309 buf = wmi_buf_alloc(wmi_handle, len);
12310 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012311 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012312 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012313 }
12314 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12315 buf_ptr = (uint8_t *) cmd;
12316
12317 WMITLV_SET_HDR(&cmd->tlv_header,
12318 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12319 WMITLV_GET_STRUCT_TLVLEN(
12320 wmi_diag_event_log_config_fixed_param));
12321
12322 cmd->num_of_diag_events_logs = total_len;
12323
12324 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12325
12326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12327 (total_len * sizeof(uint32_t)));
12328
12329 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12330
Govind Singh224a7312016-06-21 14:33:26 +053012331 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012332 log_level = 1;
12333 else
12334 log_level = 0;
12335
Govind Singhb53420c2016-03-09 14:32:57 +053012336 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012337 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12338 uint32_t val = wmi_handle->events_logs_list[i];
12339 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12340 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12341
12342 WMI_DIAG_ID_SET(cmd_args[count],
12343 WMI_DIAG_ID_GET(val));
12344 WMI_DIAG_TYPE_SET(cmd_args[count],
12345 WMI_DIAG_TYPE_GET(val));
12346 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12347 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012348 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012349 count++;
12350 }
12351 }
12352
12353 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12354 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012355 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012356 __func__);
12357 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012358 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012359 }
12360
Govind Singhb53420c2016-03-09 14:32:57 +053012361 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012362}
12363
12364/**
12365 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12366 * @wmi_handle: WMI handle
12367 *
12368 * This function is used to send the flush command to the FW,
12369 * that will flush the fw logs that are residue in the FW
12370 *
12371 * Return: None
12372 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012373static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012374{
12375 wmi_debug_mesg_flush_fixed_param *cmd;
12376 wmi_buf_t buf;
12377 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012378 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012379
12380 buf = wmi_buf_alloc(wmi_handle, len);
12381 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012382 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012383 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012384 }
12385
12386 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12387 WMITLV_SET_HDR(&cmd->tlv_header,
12388 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
12389 WMITLV_GET_STRUCT_TLVLEN(
12390 wmi_debug_mesg_flush_fixed_param));
12391 cmd->reserved0 = 0;
12392
12393 ret = wmi_unified_cmd_send(wmi_handle,
12394 buf,
12395 len,
12396 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053012397 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012398 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053012399 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012400 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012401 }
Govind Singhb53420c2016-03-09 14:32:57 +053012402 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012403
Govind Singh67922e82016-04-01 16:48:57 +053012404 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012405}
12406
12407/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012408 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012409 * @wmi_handle: wmi handle
12410 * @msg: PCL structure containing the PCL and the number of channels
12411 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012412 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012413 * firmware. The DBS Manager is the consumer of this information in the WLAN
12414 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12415 * to migrate to a new channel without host driver involvement. An example of
12416 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12417 * manage the channel selection without firmware involvement.
12418 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012419 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12420 * channel list. The weights corresponds to the channels sent in
12421 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12422 * weightage compared to the non PCL channels.
12423 *
Govind Singha4836fd2016-03-07 16:45:38 +053012424 * Return: Success if the cmd is sent successfully to the firmware
12425 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012426static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012427 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012428{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012429 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012430 wmi_buf_t buf;
12431 uint8_t *buf_ptr;
12432 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012433 uint32_t chan_len;
12434
12435 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012436
12437 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012438 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012439
12440 buf = wmi_buf_alloc(wmi_handle, len);
12441 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012442 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12443 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012444 }
12445
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012446 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012447 buf_ptr = (uint8_t *) cmd;
12448 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012449 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12450 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012451
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012452 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12453 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012454 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012455 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012456
12457 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012458 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012459 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012460 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012461 for (i = 0; i < chan_len ; i++) {
12462 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080012463 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012464 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012465 }
12466 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012467 WMI_PDEV_SET_PCL_CMDID)) {
12468 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012469 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012470 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012471 }
Govind Singhb53420c2016-03-09 14:32:57 +053012472 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012473}
12474
12475/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012476 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012477 * @wmi_handle: wmi handle
12478 * @msg: Structure containing the following parameters
12479 *
12480 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12481 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12482 *
12483 * Provides notification to the WLAN firmware that host driver is requesting a
12484 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12485 * configurations that include the Dual Band Simultaneous (DBS) feature.
12486 *
12487 * Return: Success if the cmd is sent successfully to the firmware
12488 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012489static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012490 uint32_t hw_mode_index)
12491{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012492 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012493 wmi_buf_t buf;
12494 uint32_t len;
12495
12496 len = sizeof(*cmd);
12497
12498 buf = wmi_buf_alloc(wmi_handle, len);
12499 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012500 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12501 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012502 }
12503
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012504 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012505 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012506 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12507 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12508
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012509 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12510 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012511 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012512 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012513
12514 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012515 WMI_PDEV_SET_HW_MODE_CMDID)) {
12516 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012517 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012518 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012519 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012520 }
12521
Govind Singhb53420c2016-03-09 14:32:57 +053012522 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012523}
12524
12525/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012526 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012527 * @wmi_handle: wmi handle
12528 * @msg: Dual MAC config parameters
12529 *
12530 * Configures WLAN firmware with the dual MAC features
12531 *
Govind Singhb53420c2016-03-09 14:32:57 +053012532 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012533 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012534static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012535QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012536 struct wmi_dual_mac_config *msg)
12537{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012538 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012539 wmi_buf_t buf;
12540 uint32_t len;
12541
12542 len = sizeof(*cmd);
12543
12544 buf = wmi_buf_alloc(wmi_handle, len);
12545 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012546 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12547 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012548 }
12549
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012550 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012551 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012552 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012553 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012554 wmi_pdev_set_mac_config_cmd_fixed_param));
12555
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012556 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12557 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012558 cmd->concurrent_scan_config_bits = msg->scan_config;
12559 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012560 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012561 __func__, msg->scan_config, msg->fw_mode_config);
12562
12563 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012564 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12565 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012566 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012567 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012568 }
Govind Singhb53420c2016-03-09 14:32:57 +053012569 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012570}
12571
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012572#ifdef BIG_ENDIAN_HOST
12573/**
12574* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12575* @param data_len - data length
12576* @param data - pointer to data
12577*
12578* Return: QDF_STATUS - success or error status
12579*/
12580static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12581 struct fips_params *param)
12582{
12583 unsigned char *key_unaligned, *data_unaligned;
12584 int c;
12585 u_int8_t *key_aligned = NULL;
12586 u_int8_t *data_aligned = NULL;
12587
12588 /* Assigning unaligned space to copy the key */
12589 key_unaligned = qdf_mem_malloc(
12590 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12591 data_unaligned = qdf_mem_malloc(
12592 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12593
12594 /* Checking if kmalloc is succesful to allocate space */
12595 if (key_unaligned == NULL)
12596 return QDF_STATUS_SUCCESS;
12597 /* Checking if space is aligned */
12598 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12599 /* align to 4 */
12600 key_aligned =
12601 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12602 FIPS_ALIGN);
12603 } else {
12604 key_aligned = (u_int8_t *)key_unaligned;
12605 }
12606
12607 /* memset and copy content from key to key aligned */
12608 OS_MEMSET(key_aligned, 0, param->key_len);
12609 OS_MEMCPY(key_aligned, param->key, param->key_len);
12610
12611 /* print a hexdump for host debug */
12612 print_hex_dump(KERN_DEBUG,
12613 "\t Aligned and Copied Key:@@@@ ",
12614 DUMP_PREFIX_NONE,
12615 16, 1, key_aligned, param->key_len, true);
12616
12617 /* Checking if kmalloc is succesful to allocate space */
12618 if (data_unaligned == NULL)
12619 return QDF_STATUS_SUCCESS;
12620 /* Checking of space is aligned */
12621 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12622 /* align to 4 */
12623 data_aligned =
12624 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12625 FIPS_ALIGN);
12626 } else {
12627 data_aligned = (u_int8_t *)data_unaligned;
12628 }
12629
12630 /* memset and copy content from data to data aligned */
12631 OS_MEMSET(data_aligned, 0, param->data_len);
12632 OS_MEMCPY(data_aligned, param->data, param->data_len);
12633
12634 /* print a hexdump for host debug */
12635 print_hex_dump(KERN_DEBUG,
12636 "\t Properly Aligned and Copied Data:@@@@ ",
12637 DUMP_PREFIX_NONE,
12638 16, 1, data_aligned, param->data_len, true);
12639
12640 /* converting to little Endian both key_aligned and
12641 * data_aligned*/
12642 for (c = 0; c < param->key_len/4; c++) {
12643 *((u_int32_t *)key_aligned+c) =
12644 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12645 }
12646 for (c = 0; c < param->data_len/4; c++) {
12647 *((u_int32_t *)data_aligned+c) =
12648 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12649 }
12650
12651 /* update endian data to key and data vectors */
12652 OS_MEMCPY(param->key, key_aligned, param->key_len);
12653 OS_MEMCPY(param->data, data_aligned, param->data_len);
12654
12655 /* clean up allocated spaces */
12656 qdf_mem_free(key_unaligned);
12657 key_unaligned = NULL;
12658 key_aligned = NULL;
12659
12660 qdf_mem_free(data_unaligned);
12661 data_unaligned = NULL;
12662 data_aligned = NULL;
12663
12664 return QDF_STATUS_SUCCESS;
12665}
12666#else
12667/**
12668* fips_align_data_be() - DUMMY for LE platform
12669*
12670* Return: QDF_STATUS - success
12671*/
12672static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12673 struct fips_params *param)
12674{
12675 return QDF_STATUS_SUCCESS;
12676}
12677#endif
12678
12679
12680/**
12681 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12682 * @wmi_handle: wmi handle
12683 * @param: pointer to hold pdev fips param
12684 *
12685 * Return: 0 for success or error code
12686 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012687static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012688send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12689 struct fips_params *param)
12690{
12691 wmi_pdev_fips_cmd_fixed_param *cmd;
12692 wmi_buf_t buf;
12693 uint8_t *buf_ptr;
12694 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12695 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12696
12697 /* Length TLV placeholder for array of bytes */
12698 len += WMI_TLV_HDR_SIZE;
12699 if (param->data_len)
12700 len += (param->data_len*sizeof(uint8_t));
12701
12702 /*
12703 * Data length must be multiples of 16 bytes - checked against 0xF -
12704 * and must be less than WMI_SVC_MSG_SIZE - static size of
12705 * wmi_pdev_fips_cmd structure
12706 */
12707
12708 /* do sanity on the input */
12709 if (!(((param->data_len & 0xF) == 0) &&
12710 ((param->data_len > 0) &&
12711 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12712 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12713 return QDF_STATUS_E_INVAL;
12714 }
12715
12716 buf = wmi_buf_alloc(wmi_handle, len);
12717 if (!buf) {
12718 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12719 return QDF_STATUS_E_FAILURE;
12720 }
12721
12722 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12723 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12724 WMITLV_SET_HDR(&cmd->tlv_header,
12725 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12726 WMITLV_GET_STRUCT_TLVLEN
12727 (wmi_pdev_fips_cmd_fixed_param));
12728
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012729 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12730 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012731 if (param->key != NULL && param->data != NULL) {
12732 cmd->key_len = param->key_len;
12733 cmd->data_len = param->data_len;
12734 cmd->fips_cmd = !!(param->op);
12735
12736 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12737 return QDF_STATUS_E_FAILURE;
12738
12739 qdf_mem_copy(cmd->key, param->key, param->key_len);
12740
12741 if (param->mode == FIPS_ENGINE_AES_CTR ||
12742 param->mode == FIPS_ENGINE_AES_MIC) {
12743 cmd->mode = param->mode;
12744 } else {
12745 cmd->mode = FIPS_ENGINE_AES_CTR;
12746 }
12747 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12748 cmd->key_len, cmd->data_len);
12749
12750 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12751 cmd->key, cmd->key_len, true);
12752 buf_ptr += sizeof(*cmd);
12753
12754 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12755
12756 buf_ptr += WMI_TLV_HDR_SIZE;
12757 if (param->data_len)
12758 qdf_mem_copy(buf_ptr,
12759 (uint8_t *) param->data, param->data_len);
12760
12761 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12762 16, 1, buf_ptr, cmd->data_len, true);
12763
12764 buf_ptr += param->data_len;
12765
12766 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12767 WMI_PDEV_FIPS_CMDID);
12768 qdf_print("%s return value %d\n", __func__, retval);
12769 } else {
12770 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12771 wmi_buf_free(buf);
12772 retval = -QDF_STATUS_E_BADMSG;
12773 }
12774
12775 return retval;
12776}
12777
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012778#ifdef WLAN_PMO_ENABLE
12779/**
12780 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12781 * @wmi_handle: wmi handle
12782 * @vdev_id: vdev id
12783 * @bitmap: Event bitmap
12784 * @enable: enable/disable
12785 *
12786 * Return: CDF status
12787 */
12788static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12789 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012790 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012791 bool enable)
12792{
12793 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12794 uint16_t len;
12795 wmi_buf_t buf;
12796 int ret;
12797
12798 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12799 buf = wmi_buf_alloc(wmi_handle, len);
12800 if (!buf) {
12801 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12802 return QDF_STATUS_E_NOMEM;
12803 }
12804 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12805 WMITLV_SET_HDR(&cmd->tlv_header,
12806 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12807 WMITLV_GET_STRUCT_TLVLEN
12808 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12809 cmd->vdev_id = vdev_id;
12810 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053012811 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
12812 WMI_WOW_MAX_EVENT_BM_LEN);
12813
12814 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
12815 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
12816 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012817
12818 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12819 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12820 if (ret) {
12821 WMI_LOGE("Failed to config wow wakeup event");
12822 wmi_buf_free(buf);
12823 return QDF_STATUS_E_FAILURE;
12824 }
12825
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012826 return QDF_STATUS_SUCCESS;
12827}
12828
12829/**
12830 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12831 * @wmi_handle: wmi handle
12832 * @vdev_id: vdev id
12833 * @ptrn_id: pattern id
12834 * @ptrn: pattern
12835 * @ptrn_len: pattern length
12836 * @ptrn_offset: pattern offset
12837 * @mask: mask
12838 * @mask_len: mask length
12839 * @user: true for user configured pattern and false for default pattern
12840 * @default_patterns: default patterns
12841 *
12842 * Return: CDF status
12843 */
12844static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12845 uint8_t vdev_id, uint8_t ptrn_id,
12846 const uint8_t *ptrn, uint8_t ptrn_len,
12847 uint8_t ptrn_offset, const uint8_t *mask,
12848 uint8_t mask_len, bool user,
12849 uint8_t default_patterns)
12850{
12851 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12852 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12853 wmi_buf_t buf;
12854 uint8_t *buf_ptr;
12855 int32_t len;
12856 int ret;
12857
12858 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12859 WMI_TLV_HDR_SIZE +
12860 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12861 WMI_TLV_HDR_SIZE +
12862 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12863 WMI_TLV_HDR_SIZE +
12864 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12865 WMI_TLV_HDR_SIZE +
12866 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12867 WMI_TLV_HDR_SIZE +
12868 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12869
12870 buf = wmi_buf_alloc(wmi_handle, len);
12871 if (!buf) {
12872 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12873 return QDF_STATUS_E_NOMEM;
12874 }
12875
12876 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12877 buf_ptr = (uint8_t *) cmd;
12878
12879 WMITLV_SET_HDR(&cmd->tlv_header,
12880 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12881 WMITLV_GET_STRUCT_TLVLEN
12882 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12883 cmd->vdev_id = vdev_id;
12884 cmd->pattern_id = ptrn_id;
12885
12886 cmd->pattern_type = WOW_BITMAP_PATTERN;
12887 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12888
12889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12890 sizeof(WOW_BITMAP_PATTERN_T));
12891 buf_ptr += WMI_TLV_HDR_SIZE;
12892 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12893
12894 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12895 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12896 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12897
12898 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12899 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12900
12901 bitmap_pattern->pattern_offset = ptrn_offset;
12902 bitmap_pattern->pattern_len = ptrn_len;
12903
12904 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12905 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12906
12907 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12908 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12909
12910 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12911 bitmap_pattern->pattern_id = ptrn_id;
12912
12913 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12914 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12915 bitmap_pattern->pattern_offset, user);
12916 WMI_LOGI("Pattern : ");
12917 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12918 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12919
12920 WMI_LOGI("Mask : ");
12921 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12922 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12923
12924 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12925
12926 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12928 buf_ptr += WMI_TLV_HDR_SIZE;
12929
12930 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12931 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12932 buf_ptr += WMI_TLV_HDR_SIZE;
12933
12934 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12935 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12936 buf_ptr += WMI_TLV_HDR_SIZE;
12937
12938 /* Fill TLV for pattern_info_timeout but no data. */
12939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12940 buf_ptr += WMI_TLV_HDR_SIZE;
12941
12942 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12943 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12944 buf_ptr += WMI_TLV_HDR_SIZE;
12945 *(A_UINT32 *) buf_ptr = 0;
12946
12947 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12948 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12949 if (ret) {
12950 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12951 wmi_buf_free(buf);
12952 return QDF_STATUS_E_FAILURE;
12953 }
12954
12955 return QDF_STATUS_SUCCESS;
12956}
12957
Govind Singha4836fd2016-03-07 16:45:38 +053012958/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012959 * fill_arp_offload_params_tlv() - Fill ARP offload data
12960 * @wmi_handle: wmi handle
12961 * @offload_req: offload request
12962 * @buf_ptr: buffer pointer
12963 *
12964 * To fill ARP offload data to firmware
12965 * when target goes to wow mode.
12966 *
12967 * Return: None
12968 */
12969static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012970 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012971{
12972
12973 int i;
12974 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012975 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012976
12977 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12978 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12979 *buf_ptr += WMI_TLV_HDR_SIZE;
12980 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12981 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12982 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12983 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12984 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12985
12986 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012987 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012988 /* Copy the target ip addr and flags */
12989 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12990 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012991 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012992 WMI_IPV4_ADDR_LEN);
12993 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012994 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012995 }
12996 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12997 }
12998}
12999
13000#ifdef WLAN_NS_OFFLOAD
13001/**
13002 * fill_ns_offload_params_tlv() - Fill NS offload data
13003 * @wmi|_handle: wmi handle
13004 * @offload_req: offload request
13005 * @buf_ptr: buffer pointer
13006 *
13007 * To fill NS offload data to firmware
13008 * when target goes to wow mode.
13009 *
13010 * Return: None
13011 */
13012static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013013 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013014{
13015
13016 int i;
13017 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013018
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013019 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13020 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13021 *buf_ptr += WMI_TLV_HDR_SIZE;
13022 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13023 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13024 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13025 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13026 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13027
13028 /*
13029 * Fill data only for NS offload in the first ARP tuple for LA
13030 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013031 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013032 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13033 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013034 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013035 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013036 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013037 sizeof(WMI_IPV6_ADDR));
13038 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013039 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013040 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013041 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013042 ns_tuple->flags |=
13043 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13044 }
13045 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013046 i, &ns_req->self_ipv6_addr[i],
13047 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013048
13049 /* target MAC is optional, check if it is valid,
13050 * if this is not valid, the target will use the known
13051 * local MAC address rather than the tuple
13052 */
13053 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013054 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013055 &ns_tuple->target_mac);
13056 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13057 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13058 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13059 }
13060 }
13061 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13062 }
13063}
13064
13065
13066/**
13067 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13068 * @wmi: wmi handle
13069 * @offload_req: offload request
13070 * @buf_ptr: buffer pointer
13071 *
13072 * To fill extended NS offload extended data to firmware
13073 * when target goes to wow mode.
13074 *
13075 * Return: None
13076 */
13077static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013078 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013079{
13080 int i;
13081 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13082 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013083
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013084 count = ns_req->num_ns_offload_count;
13085 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013086 WMI_MAX_NS_OFFLOADS;
13087
13088 /* Populate extended NS offload tuples */
13089 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13090 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13091 *buf_ptr += WMI_TLV_HDR_SIZE;
13092 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13093 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13094 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13095 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13096 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13097
13098 /*
13099 * Fill data only for NS offload in the first ARP tuple for LA
13100 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013101 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013102 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13103 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013104 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013105 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013106 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013107 sizeof(WMI_IPV6_ADDR));
13108 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013109 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013110 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013111 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013112 ns_tuple->flags |=
13113 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13114 }
13115 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013116 i, &ns_req->self_ipv6_addr[i],
13117 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013118
13119 /* target MAC is optional, check if it is valid,
13120 * if this is not valid, the target will use the
13121 * known local MAC address rather than the tuple
13122 */
13123 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013124 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013125 &ns_tuple->target_mac);
13126 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13127 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13128 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13129 }
13130 }
13131 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13132 }
13133}
13134#else
13135static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013136 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013137{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013138}
13139
13140static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013141 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013142{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013143}
13144#endif
13145
13146/**
Govind Singha4836fd2016-03-07 16:45:38 +053013147 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13148 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013149 * @arp_offload_req: arp offload request
13150 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013151 * @arp_only: flag
13152 *
13153 * To configure ARP NS off load data to firmware
13154 * when target goes to wow mode.
13155 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013156 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013157 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013158static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013159 struct pmo_arp_offload_params *arp_offload_req,
13160 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013161 uint8_t vdev_id)
13162{
Govind Singha4836fd2016-03-07 16:45:38 +053013163 int32_t res;
13164 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013165 A_UINT8 *buf_ptr;
13166 wmi_buf_t buf;
13167 int32_t len;
13168 uint32_t count = 0, num_ns_ext_tuples = 0;
13169
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013170 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013171
Govind Singha4836fd2016-03-07 16:45:38 +053013172 /*
13173 * TLV place holder size for array of NS tuples
13174 * TLV place holder size for array of ARP tuples
13175 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013176 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13177 WMI_TLV_HDR_SIZE +
13178 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13179 WMI_TLV_HDR_SIZE +
13180 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013181
13182 /*
13183 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13184 * extra length for extended NS offload tuples which follows ARP offload
13185 * tuples. Host needs to fill this structure in following format:
13186 * 2 NS ofload tuples
13187 * 2 ARP offload tuples
13188 * N numbers of extended NS offload tuples if HDD has given more than
13189 * 2 NS offload addresses
13190 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013191 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013192 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013193 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13194 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013195 }
13196
13197 buf = wmi_buf_alloc(wmi_handle, len);
13198 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013199 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013200 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013201 }
13202
13203 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13204 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13205 WMITLV_SET_HDR(&cmd->tlv_header,
13206 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13207 WMITLV_GET_STRUCT_TLVLEN
13208 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13209 cmd->flags = 0;
13210 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013211 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013212
Govind Singhb53420c2016-03-09 14:32:57 +053013213 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013214
Govind Singha4836fd2016-03-07 16:45:38 +053013215 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013216 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13217 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13218 if (num_ns_ext_tuples)
13219 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013220
13221 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13222 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13223 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013224 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013226 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013227 }
13228
Govind Singhb53420c2016-03-09 14:32:57 +053013229 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013230}
13231
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013232/**
13233 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13234 * @wmi_handle: wmi handle
13235 * @vdev_id: vdev id
13236 * @action: true for enable else false
13237 *
13238 * To enable enhance multicast offload to firmware
13239 * when target goes to wow mode.
13240 *
13241 * Return: QDF Status
13242 */
13243
13244static
13245QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13246 wmi_unified_t wmi_handle,
13247 uint8_t vdev_id, bool action)
13248{
13249 QDF_STATUS status;
13250 wmi_buf_t buf;
13251 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13252
13253 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13254 if (!buf) {
13255 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13256 return QDF_STATUS_E_NOMEM;
13257 }
13258
13259 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13260 wmi_buf_data(buf);
13261
13262 WMITLV_SET_HDR(&cmd->tlv_header,
13263 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13264 WMITLV_GET_STRUCT_TLVLEN(
13265 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13266
13267 cmd->vdev_id = vdev_id;
13268 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13269 ENHANCED_MCAST_FILTER_ENABLED);
13270 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13271 __func__, action, vdev_id);
13272 status = wmi_unified_cmd_send(wmi_handle, buf,
13273 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13274 if (status != QDF_STATUS_SUCCESS) {
13275 qdf_nbuf_free(buf);
13276 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13277 __func__);
13278 }
13279
13280 return status;
13281}
13282
13283/**
13284 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13285 * @wmi_handle: wmi handle
13286 * @param evt_buf: pointer to event buffer
13287 * @param hdr: Pointer to hold header
13288 * @param bufp: Pointer to hold pointer to rx param buffer
13289 *
13290 * Return: QDF_STATUS_SUCCESS for success or error code
13291 */
13292static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13293 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13294{
13295 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13296 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13297
13298 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13299 if (!param_buf) {
13300 WMI_LOGE("gtk param_buf is NULL");
13301 return QDF_STATUS_E_INVAL;
13302 }
13303
13304 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13305 WMI_LOGE("Invalid length for GTK status");
13306 return QDF_STATUS_E_INVAL;
13307 }
13308
13309 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13310 param_buf->fixed_param;
13311 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13312 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13313 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13314 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13315 &fixed_param->replay_counter,
13316 GTK_REPLAY_COUNTER_BYTES);
13317
13318 return QDF_STATUS_SUCCESS;
13319
13320}
13321
13322#ifdef FEATURE_WLAN_RA_FILTERING
13323/**
13324 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13325 * @wmi_handle: wmi handle
13326 * @vdev_id: vdev id
13327 *
13328 * Return: CDF status
13329 */
13330static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13331 uint8_t vdev_id, uint8_t default_pattern,
13332 uint16_t rate_limit_interval)
13333{
13334
13335 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13336 wmi_buf_t buf;
13337 uint8_t *buf_ptr;
13338 int32_t len;
13339 int ret;
13340
13341 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13342 WMI_TLV_HDR_SIZE +
13343 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13344 WMI_TLV_HDR_SIZE +
13345 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13346 WMI_TLV_HDR_SIZE +
13347 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13348 WMI_TLV_HDR_SIZE +
13349 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13350 WMI_TLV_HDR_SIZE +
13351 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
13352
13353 buf = wmi_buf_alloc(wmi_handle, len);
13354 if (!buf) {
13355 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13356 return QDF_STATUS_E_NOMEM;
13357 }
13358
13359 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13360 buf_ptr = (uint8_t *) cmd;
13361
13362 WMITLV_SET_HDR(&cmd->tlv_header,
13363 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13364 WMITLV_GET_STRUCT_TLVLEN
13365 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13366 cmd->vdev_id = vdev_id;
13367 cmd->pattern_id = default_pattern,
13368 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13369 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13370
13371 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13373 buf_ptr += WMI_TLV_HDR_SIZE;
13374
13375 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13377 buf_ptr += WMI_TLV_HDR_SIZE;
13378
13379 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13381 buf_ptr += WMI_TLV_HDR_SIZE;
13382
13383 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13384 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13385 buf_ptr += WMI_TLV_HDR_SIZE;
13386
13387 /* Fill TLV for pattern_info_timeout but no data. */
13388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13389 buf_ptr += WMI_TLV_HDR_SIZE;
13390
13391 /* Fill TLV for ra_ratelimit_interval. */
13392 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
13393 buf_ptr += WMI_TLV_HDR_SIZE;
13394
13395 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
13396
13397 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
13398 rate_limit_interval, vdev_id);
13399
13400 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13401 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13402 if (ret) {
13403 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
13404 wmi_buf_free(buf);
13405 return QDF_STATUS_E_FAILURE;
13406 }
13407
13408 return QDF_STATUS_SUCCESS;
13409
13410}
13411#endif /* FEATURE_WLAN_RA_FILTERING */
13412
13413/**
13414 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13415 * @wmi_handle: wmi handle
13416 * @vdev_id: vdev id
13417 * @multicastAddr: mcast address
13418 * @clearList: clear list flag
13419 *
13420 * Return: QDF_STATUS_SUCCESS for success or error code
13421 */
13422static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13423 uint8_t vdev_id,
13424 struct qdf_mac_addr multicast_addr,
13425 bool clearList)
13426{
13427 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13428 wmi_buf_t buf;
13429 int err;
13430
13431 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13432 if (!buf) {
13433 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13434 return QDF_STATUS_E_NOMEM;
13435 }
13436
13437 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13438 qdf_mem_zero(cmd, sizeof(*cmd));
13439
13440 WMITLV_SET_HDR(&cmd->tlv_header,
13441 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13442 WMITLV_GET_STRUCT_TLVLEN
13443 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13444 cmd->action =
13445 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13446 cmd->vdev_id = vdev_id;
13447 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13448
13449 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13450 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13451
13452 err = wmi_unified_cmd_send(wmi_handle, buf,
13453 sizeof(*cmd),
13454 WMI_SET_MCASTBCAST_FILTER_CMDID);
13455 if (err) {
13456 WMI_LOGE("Failed to send set_param cmd");
13457 wmi_buf_free(buf);
13458 return QDF_STATUS_E_FAILURE;
13459 }
13460
13461 return QDF_STATUS_SUCCESS;
13462}
13463
13464/**
13465 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13466 * @wmi_handle: wmi handle
13467 * @vdev_id: vdev id
13468 * @params: GTK offload parameters
13469 *
13470 * Return: CDF status
13471 */
13472static
13473QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13474 struct pmo_gtk_req *params,
13475 bool enable_offload,
13476 uint32_t gtk_offload_opcode)
13477{
13478 int len;
13479 wmi_buf_t buf;
13480 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13481 QDF_STATUS status = QDF_STATUS_SUCCESS;
13482
13483 WMI_LOGD("%s Enter", __func__);
13484
13485 len = sizeof(*cmd);
13486
13487 /* alloc wmi buffer */
13488 buf = wmi_buf_alloc(wmi_handle, len);
13489 if (!buf) {
13490 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13491 status = QDF_STATUS_E_NOMEM;
13492 goto out;
13493 }
13494
13495 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13496 WMITLV_SET_HDR(&cmd->tlv_header,
13497 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13498 WMITLV_GET_STRUCT_TLVLEN
13499 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13500
13501 cmd->vdev_id = vdev_id;
13502
13503 /* Request target to enable GTK offload */
13504 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13505 cmd->flags = gtk_offload_opcode;
13506
13507 /* Copy the keys and replay counter */
13508 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13509 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13510 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13511 GTK_REPLAY_COUNTER_BYTES);
13512 } else {
13513 cmd->flags = gtk_offload_opcode;
13514 }
13515
13516 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13517
13518 /* send the wmi command */
13519 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13520 WMI_GTK_OFFLOAD_CMDID)) {
13521 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13522 wmi_buf_free(buf);
13523 status = QDF_STATUS_E_FAILURE;
13524 }
13525
13526out:
13527 WMI_LOGD("%s Exit", __func__);
13528 return status;
13529}
13530
13531/**
13532 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13533 * @wmi_handle: wmi handle
13534 * @params: GTK offload params
13535 *
13536 * Return: CDF status
13537 */
13538static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13539 wmi_unified_t wmi_handle,
13540 uint8_t vdev_id,
13541 uint64_t offload_req_opcode)
13542{
13543 int len;
13544 wmi_buf_t buf;
13545 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13546 QDF_STATUS status = QDF_STATUS_SUCCESS;
13547
13548 len = sizeof(*cmd);
13549
13550 /* alloc wmi buffer */
13551 buf = wmi_buf_alloc(wmi_handle, len);
13552 if (!buf) {
13553 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13554 status = QDF_STATUS_E_NOMEM;
13555 goto out;
13556 }
13557
13558 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13559 WMITLV_SET_HDR(&cmd->tlv_header,
13560 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13561 WMITLV_GET_STRUCT_TLVLEN
13562 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13563
13564 /* Request for GTK offload status */
13565 cmd->flags = offload_req_opcode;
13566 cmd->vdev_id = vdev_id;
13567
13568 /* send the wmi command */
13569 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13570 WMI_GTK_OFFLOAD_CMDID)) {
13571 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13572 wmi_buf_free(buf);
13573 status = QDF_STATUS_E_FAILURE;
13574 }
13575
13576out:
13577 return status;
13578}
13579
13580/**
13581 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13582 * @wmi_handle: wmi handler
13583 * @action_params: pointer to action_params
13584 *
13585 * Return: 0 for success, otherwise appropriate error code
13586 */
13587static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13588 struct pmo_action_wakeup_set_params *action_params)
13589{
13590 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13591 wmi_buf_t buf;
13592 int i;
13593 int32_t err;
13594
13595 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13596 if (!buf) {
13597 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13598 return QDF_STATUS_E_NOMEM;
13599 }
13600 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13601 WMITLV_SET_HDR(&cmd->tlv_header,
13602 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13603 WMITLV_GET_STRUCT_TLVLEN(
13604 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13605
13606 cmd->vdev_id = action_params->vdev_id;
13607 cmd->operation = action_params->operation;
13608
13609 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13610 cmd->action_category_map[i] =
13611 action_params->action_category_map[i];
13612
13613 err = wmi_unified_cmd_send(wmi_handle, buf,
13614 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13615 if (err) {
13616 WMI_LOGE("Failed to send ap_ps_egap cmd");
13617 wmi_buf_free(buf);
13618 return QDF_STATUS_E_FAILURE;
13619 }
13620
13621 return QDF_STATUS_SUCCESS;
13622}
13623
13624#ifdef FEATURE_WLAN_LPHB
13625
13626/**
13627 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13628 * @wmi_handle: wmi handle
13629 * @lphb_conf_req: configuration info
13630 *
13631 * Return: CDF status
13632 */
13633static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13634 wmi_hb_set_enable_cmd_fixed_param *params)
13635{
13636 QDF_STATUS status;
13637 wmi_buf_t buf = NULL;
13638 uint8_t *buf_ptr;
13639 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13640 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13641
13642
13643 buf = wmi_buf_alloc(wmi_handle, len);
13644 if (!buf) {
13645 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13646 return QDF_STATUS_E_NOMEM;
13647 }
13648
13649 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13650 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13651 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13652 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13653 WMITLV_GET_STRUCT_TLVLEN
13654 (wmi_hb_set_enable_cmd_fixed_param));
13655
13656 /* fill in values */
13657 hb_enable_fp->vdev_id = params->session;
13658 hb_enable_fp->enable = params->enable;
13659 hb_enable_fp->item = params->item;
13660 hb_enable_fp->session = params->session;
13661
13662 status = wmi_unified_cmd_send(wmi_handle, buf,
13663 len, WMI_HB_SET_ENABLE_CMDID);
13664 if (QDF_IS_STATUS_ERROR(status)) {
13665 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13666 status);
13667 wmi_buf_free(buf);
13668 }
13669
13670 return status;
13671}
13672
13673/**
13674 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13675 * @wmi_handle: wmi handle
13676 * @lphb_conf_req: lphb config request
13677 *
13678 * Return: CDF status
13679 */
13680static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13681 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13682{
13683 QDF_STATUS status;
13684 wmi_buf_t buf = NULL;
13685 uint8_t *buf_ptr;
13686 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13687 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13688
13689 buf = wmi_buf_alloc(wmi_handle, len);
13690 if (!buf) {
13691 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13692 return QDF_STATUS_E_NOMEM;
13693 }
13694
13695 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13696 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13697 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13698 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13699 WMITLV_GET_STRUCT_TLVLEN
13700 (wmi_hb_set_tcp_params_cmd_fixed_param));
13701
13702 /* fill in values */
13703 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13704 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13705 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13706 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13707 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13708 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13709 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13710 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13711 hb_tcp_params_fp->session = lphb_conf_req->session;
13712 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13713 &lphb_conf_req->gateway_mac,
13714 sizeof(hb_tcp_params_fp->gateway_mac));
13715
13716 status = wmi_unified_cmd_send(wmi_handle, buf,
13717 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13718 if (QDF_IS_STATUS_ERROR(status)) {
13719 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13720 status);
13721 wmi_buf_free(buf);
13722 }
13723
13724 return status;
13725}
13726
13727/**
13728 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13729 * @wmi_handle: wmi handle
13730 * @lphb_conf_req: lphb config request
13731 *
13732 * Return: CDF status
13733 */
13734static
13735QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13736 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13737{
13738 QDF_STATUS status;
13739 wmi_buf_t buf = NULL;
13740 uint8_t *buf_ptr;
13741 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13742 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13743
13744 buf = wmi_buf_alloc(wmi_handle, len);
13745 if (!buf) {
13746 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13747 return QDF_STATUS_E_NOMEM;
13748 }
13749
13750 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13751 hb_tcp_filter_fp =
13752 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13753 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13754 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13755 WMITLV_GET_STRUCT_TLVLEN
13756 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13757
13758 /* fill in values */
13759 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13760 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13761 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13762 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13763 memcpy((void *)&hb_tcp_filter_fp->filter,
13764 (void *)&g_hb_tcp_filter_fp->filter,
13765 WMI_WLAN_HB_MAX_FILTER_SIZE);
13766
13767 status = wmi_unified_cmd_send(wmi_handle, buf,
13768 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13769 if (QDF_IS_STATUS_ERROR(status)) {
13770 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13771 status);
13772 wmi_buf_free(buf);
13773 }
13774
13775 return status;
13776}
13777
13778/**
13779 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13780 * @wmi_handle: wmi handle
13781 * @lphb_conf_req: lphb config request
13782 *
13783 * Return: CDF status
13784 */
13785static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13786 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13787{
13788 QDF_STATUS status;
13789 wmi_buf_t buf = NULL;
13790 uint8_t *buf_ptr;
13791 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13792 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13793
13794 buf = wmi_buf_alloc(wmi_handle, len);
13795 if (!buf) {
13796 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13797 return QDF_STATUS_E_NOMEM;
13798 }
13799
13800 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13801 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13802 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13803 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13804 WMITLV_GET_STRUCT_TLVLEN
13805 (wmi_hb_set_udp_params_cmd_fixed_param));
13806
13807 /* fill in values */
13808 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13809 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13810 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13811 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13812 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13813 hb_udp_params_fp->interval = lphb_conf_req->interval;
13814 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13815 hb_udp_params_fp->session = lphb_conf_req->session;
13816 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13817 &lphb_conf_req->gateway_mac,
13818 sizeof(lphb_conf_req->gateway_mac));
13819
13820 status = wmi_unified_cmd_send(wmi_handle, buf,
13821 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13822 if (QDF_IS_STATUS_ERROR(status)) {
13823 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13824 status);
13825 wmi_buf_free(buf);
13826 }
13827
13828 return status;
13829}
13830
13831/**
13832 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13833 * @wmi_handle: wmi handle
13834 * @lphb_conf_req: lphb config request
13835 *
13836 * Return: CDF status
13837 */
13838static
13839QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13840 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13841{
13842 QDF_STATUS status;
13843 wmi_buf_t buf = NULL;
13844 uint8_t *buf_ptr;
13845 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13846 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13847
13848 buf = wmi_buf_alloc(wmi_handle, len);
13849 if (!buf) {
13850 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13851 return QDF_STATUS_E_NOMEM;
13852 }
13853
13854 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13855 hb_udp_filter_fp =
13856 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13857 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13858 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13859 WMITLV_GET_STRUCT_TLVLEN
13860 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13861
13862 /* fill in values */
13863 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13864 hb_udp_filter_fp->length = lphb_conf_req->length;
13865 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13866 hb_udp_filter_fp->session = lphb_conf_req->session;
13867 memcpy((void *)&hb_udp_filter_fp->filter,
13868 (void *)&lphb_conf_req->filter,
13869 WMI_WLAN_HB_MAX_FILTER_SIZE);
13870
13871 status = wmi_unified_cmd_send(wmi_handle, buf,
13872 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13873 if (QDF_IS_STATUS_ERROR(status)) {
13874 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13875 status);
13876 wmi_buf_free(buf);
13877 }
13878
13879 return status;
13880}
13881#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013882
Dustin Brownf31f88b2017-05-12 14:01:44 -070013883static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
13884 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013885{
Dustin Brownf31f88b2017-05-12 14:01:44 -070013886 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013887 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070013888 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013889
Dustin Brownf31f88b2017-05-12 14:01:44 -070013890 if (!req) {
13891 WMI_LOGE("req is null");
13892 return QDF_STATUS_E_INVAL;
13893 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013894
Dustin Brownf31f88b2017-05-12 14:01:44 -070013895 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
13896 if (!wmi_buf) {
13897 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013898 return QDF_STATUS_E_NOMEM;
13899 }
13900
Dustin Brownf31f88b2017-05-12 14:01:44 -070013901 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013902 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070013903 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13904 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
13905 cmd->vdev_id = req->vdev_id;
13906 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
13907 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013908
Dustin Brownf31f88b2017-05-12 14:01:44 -070013909 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
13910 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013911
Dustin Brownf31f88b2017-05-12 14:01:44 -070013912 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
13913 WMI_HW_DATA_FILTER_CMDID);
13914 if (QDF_IS_STATUS_ERROR(status)) {
13915 WMI_LOGE("Failed to configure hw filter");
13916 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013917 }
13918
Dustin Brownf31f88b2017-05-12 14:01:44 -070013919 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013920}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053013921
13922/**
13923 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
13924 * @wmi_handle: wmi handle
13925 * @vdev_id: vdev id
13926 * @enable: Flag to enable/disable packet filter
13927 *
13928 * Return: QDF_STATUS_SUCCESS for success or error code
13929 */
13930static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
13931 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
13932{
13933 int32_t len;
13934 int ret = 0;
13935 wmi_buf_t buf;
13936 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
13937
13938 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
13939
13940 buf = wmi_buf_alloc(wmi_handle, len);
13941 if (!buf) {
13942 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13943 return QDF_STATUS_E_NOMEM;
13944 }
13945
13946 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
13947 WMITLV_SET_HDR(&cmd->tlv_header,
13948 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
13949 WMITLV_GET_STRUCT_TLVLEN(
13950 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
13951
13952 cmd->vdev_id = vdev_id;
13953 if (enable)
13954 cmd->enable = PACKET_FILTER_SET_ENABLE;
13955 else
13956 cmd->enable = PACKET_FILTER_SET_DISABLE;
13957
13958 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
13959 __func__, cmd->enable, vdev_id);
13960
13961 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13962 WMI_PACKET_FILTER_ENABLE_CMDID);
13963 if (ret) {
13964 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
13965 wmi_buf_free(buf);
13966 }
13967
13968 return ret;
13969}
13970
13971/**
13972 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
13973 * @wmi_handle: wmi handle
13974 * @vdev_id: vdev id
13975 * @rcv_filter_param: Packet filter parameters
13976 * @filter_id: Filter id
13977 * @enable: Flag to add/delete packet filter configuration
13978 *
13979 * Return: QDF_STATUS_SUCCESS for success or error code
13980 */
13981static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
13982 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
13983 uint8_t filter_id, bool enable)
13984{
13985 int len, i;
13986 int err = 0;
13987 wmi_buf_t buf;
13988 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
13989
13990
13991 /* allocate the memory */
13992 len = sizeof(*cmd);
13993 buf = wmi_buf_alloc(wmi_handle, len);
13994 if (!buf) {
13995 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13996 return QDF_STATUS_E_NOMEM;
13997 }
13998
13999 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14000 WMITLV_SET_HDR(&cmd->tlv_header,
14001 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14002 WMITLV_GET_STRUCT_TLVLEN
14003 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14004
14005 cmd->vdev_id = vdev_id;
14006 cmd->filter_id = filter_id;
14007 if (enable)
14008 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14009 else
14010 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14011
14012 if (enable) {
14013 cmd->num_params = QDF_MIN(
14014 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14015 rcv_filter_param->num_params);
14016 cmd->filter_type = rcv_filter_param->filter_type;
14017 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14018
14019 for (i = 0; i < cmd->num_params; i++) {
14020 cmd->paramsData[i].proto_type =
14021 rcv_filter_param->params_data[i].protocol_layer;
14022 cmd->paramsData[i].cmp_type =
14023 rcv_filter_param->params_data[i].compare_flag;
14024 cmd->paramsData[i].data_length =
14025 rcv_filter_param->params_data[i].data_length;
14026 cmd->paramsData[i].data_offset =
14027 rcv_filter_param->params_data[i].data_offset;
14028 memcpy(&cmd->paramsData[i].compareData,
14029 rcv_filter_param->params_data[i].compare_data,
14030 sizeof(cmd->paramsData[i].compareData));
14031 memcpy(&cmd->paramsData[i].dataMask,
14032 rcv_filter_param->params_data[i].data_mask,
14033 sizeof(cmd->paramsData[i].dataMask));
14034 }
14035 }
14036
14037 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14038 cmd->filter_action, cmd->filter_id, cmd->num_params);
14039 /* send the command along with data */
14040 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14041 WMI_PACKET_FILTER_CONFIG_CMDID);
14042 if (err) {
14043 WMI_LOGE("Failed to send pkt_filter cmd");
14044 wmi_buf_free(buf);
14045 return QDF_STATUS_E_FAILURE;
14046 }
14047
14048 return QDF_STATUS_SUCCESS;
14049}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053014050#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014051
Govind Singha4836fd2016-03-07 16:45:38 +053014052/**
14053 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14054 * @wmi_handle: wmi handle
14055 * @request: SSID hotlist set request
14056 *
Govind Singhb53420c2016-03-09 14:32:57 +053014057 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014058 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014059static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014060send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14061 struct ssid_hotlist_request_params *request)
14062{
14063 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14064 wmi_buf_t wmi_buf;
14065 uint32_t len;
14066 uint32_t array_size;
14067 uint8_t *buf_ptr;
14068
14069 /* length of fixed portion */
14070 len = sizeof(*cmd);
14071
14072 /* length of variable portion */
14073 array_size =
14074 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14075 len += WMI_TLV_HDR_SIZE + array_size;
14076
14077 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14078 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014079 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14080 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014081 }
14082
14083 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14084 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14085 buf_ptr;
14086 WMITLV_SET_HDR
14087 (&cmd->tlv_header,
14088 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14089 WMITLV_GET_STRUCT_TLVLEN
14090 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14091
14092 cmd->request_id = request->request_id;
14093 cmd->requestor_id = 0;
14094 cmd->vdev_id = request->session_id;
14095 cmd->table_id = 0;
14096 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14097 cmd->total_entries = request->ssid_count;
14098 cmd->num_entries_in_page = request->ssid_count;
14099 cmd->first_entry_index = 0;
14100
14101 buf_ptr += sizeof(*cmd);
14102 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14103
14104 if (request->ssid_count) {
14105 wmi_extscan_hotlist_ssid_entry *entry;
14106 int i;
14107
14108 buf_ptr += WMI_TLV_HDR_SIZE;
14109 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14110 for (i = 0; i < request->ssid_count; i++) {
14111 WMITLV_SET_HDR
14112 (entry,
14113 WMITLV_TAG_ARRAY_STRUC,
14114 WMITLV_GET_STRUCT_TLVLEN
14115 (wmi_extscan_hotlist_ssid_entry));
14116 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014117 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014118 request->ssids[i].ssid.mac_ssid,
14119 request->ssids[i].ssid.length);
14120 entry->band = request->ssids[i].band;
14121 entry->min_rssi = request->ssids[i].rssi_low;
14122 entry->max_rssi = request->ssids[i].rssi_high;
14123 entry++;
14124 }
14125 cmd->mode = WMI_EXTSCAN_MODE_START;
14126 } else {
14127 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14128 }
14129
14130 if (wmi_unified_cmd_send
14131 (wmi_handle, wmi_buf, len,
14132 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014133 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014134 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014135 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014136 }
14137
Govind Singhb53420c2016-03-09 14:32:57 +053014138 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014139}
14140
14141/**
14142 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14143 * @wmi_handle: wmi handle
14144 * @vdev_id: vdev id
14145 *
14146 * This function sends roam synch complete event to fw.
14147 *
14148 * Return: CDF STATUS
14149 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014150static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014151 uint8_t vdev_id)
14152{
14153 wmi_roam_synch_complete_fixed_param *cmd;
14154 wmi_buf_t wmi_buf;
14155 uint8_t *buf_ptr;
14156 uint16_t len;
14157 len = sizeof(wmi_roam_synch_complete_fixed_param);
14158
14159 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14160 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014161 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14162 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014163 }
14164 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14165 buf_ptr = (uint8_t *) cmd;
14166 WMITLV_SET_HDR(&cmd->tlv_header,
14167 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14168 WMITLV_GET_STRUCT_TLVLEN
14169 (wmi_roam_synch_complete_fixed_param));
14170 cmd->vdev_id = vdev_id;
14171 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14172 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014173 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014174 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014175 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014176 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014177 }
14178
Govind Singhb53420c2016-03-09 14:32:57 +053014179 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014180}
14181
14182/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014183 * send_fw_test_cmd_tlv() - send fw test command to fw.
14184 * @wmi_handle: wmi handle
14185 * @wmi_fwtest: fw test command
14186 *
14187 * This function sends fw test command to fw.
14188 *
14189 * Return: CDF STATUS
14190 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014191static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014192QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14193 struct set_fwtest_params *wmi_fwtest)
14194{
14195 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14196 wmi_buf_t wmi_buf;
14197 uint16_t len;
14198
14199 len = sizeof(*cmd);
14200
14201 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14202 if (!wmi_buf) {
14203 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14204 return QDF_STATUS_E_NOMEM;
14205 }
14206
14207 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14208 WMITLV_SET_HDR(&cmd->tlv_header,
14209 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14210 WMITLV_GET_STRUCT_TLVLEN(
14211 wmi_fwtest_set_param_cmd_fixed_param));
14212 cmd->param_id = wmi_fwtest->arg;
14213 cmd->param_value = wmi_fwtest->value;
14214
14215 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14216 WMI_FWTEST_CMDID)) {
14217 WMI_LOGP("%s: failed to send fw test command", __func__);
14218 qdf_nbuf_free(wmi_buf);
14219 return QDF_STATUS_E_FAILURE;
14220 }
14221
14222 return QDF_STATUS_SUCCESS;
14223}
14224
14225/**
Govind Singha4836fd2016-03-07 16:45:38 +053014226 * send_unit_test_cmd_tlv() - send unit test command to fw.
14227 * @wmi_handle: wmi handle
14228 * @wmi_utest: unit test command
14229 *
14230 * This function send unit test command to fw.
14231 *
14232 * Return: CDF STATUS
14233 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014234static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014235 struct wmi_unit_test_cmd *wmi_utest)
14236{
14237 wmi_unit_test_cmd_fixed_param *cmd;
14238 wmi_buf_t wmi_buf;
14239 uint8_t *buf_ptr;
14240 int i;
14241 uint16_t len, args_tlv_len;
14242 A_UINT32 *unit_test_cmd_args;
14243
14244 args_tlv_len =
14245 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
14246 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14247
14248 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14249 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014250 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14251 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014252 }
14253
14254 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14255 buf_ptr = (uint8_t *) cmd;
14256 WMITLV_SET_HDR(&cmd->tlv_header,
14257 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14258 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14259 cmd->vdev_id = wmi_utest->vdev_id;
14260 cmd->module_id = wmi_utest->module_id;
14261 cmd->num_args = wmi_utest->num_args;
14262 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14263 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14264 (wmi_utest->num_args * sizeof(uint32_t)));
14265 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014266 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053014267 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14268 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014269 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014270 }
14271 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14272 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014273 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014274 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014275 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014276 }
14277
Govind Singhb53420c2016-03-09 14:32:57 +053014278 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014279}
14280
14281/**
14282 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
14283 * @wmi_handle: wma handle
14284 * @roaminvoke: roam invoke command
14285 *
14286 * Send roam invoke command to fw for fastreassoc.
14287 *
14288 * Return: CDF STATUS
14289 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014290static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014291 struct wmi_roam_invoke_cmd *roaminvoke,
14292 uint32_t ch_hz)
14293{
14294 wmi_roam_invoke_cmd_fixed_param *cmd;
14295 wmi_buf_t wmi_buf;
14296 u_int8_t *buf_ptr;
14297 u_int16_t len, args_tlv_len;
14298 A_UINT32 *channel_list;
14299 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080014300 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053014301
14302 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080014303 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
14304 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
14305 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053014306 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
14307 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14308 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014309 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14310 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014311 }
14312
14313 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
14314 buf_ptr = (u_int8_t *) cmd;
14315 WMITLV_SET_HDR(&cmd->tlv_header,
14316 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
14317 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
14318 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080014319 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Naveen Rawat77797922017-01-20 17:00:07 -080014320
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014321 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080014322 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014323 /* packing 1 beacon/probe_rsp frame with WMI cmd */
14324 cmd->num_buf = 1;
14325 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080014326 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014327 cmd->num_buf = 0;
14328 }
Naveen Rawat77797922017-01-20 17:00:07 -080014329
Govind Singha4836fd2016-03-07 16:45:38 +053014330 cmd->roam_ap_sel_mode = 0;
14331 cmd->roam_delay = 0;
14332 cmd->num_chan = 1;
14333 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080014334
Govind Singha4836fd2016-03-07 16:45:38 +053014335 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
14336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14337 (sizeof(u_int32_t)));
14338 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
14339 *channel_list = ch_hz;
14340 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
14341 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14342 (sizeof(wmi_mac_addr)));
14343 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
14344 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080014345
14346 /* move to next tlv i.e. bcn_prb_buf_list */
14347 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
14348
14349 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14350 sizeof(wmi_tlv_buf_len_param));
14351
14352 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
14353 buf_len_tlv->buf_len = roaminvoke->frame_len;
14354
14355 /* move to next tlv i.e. bcn_prb_frm */
14356 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
14357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
14358 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
14359
14360 /* copy frame after the header */
14361 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
14362 roaminvoke->frame_buf,
14363 roaminvoke->frame_len);
14364
14365 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
14366 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
14367 buf_ptr + WMI_TLV_HDR_SIZE,
14368 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070014369 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
14370 cmd->flags, cmd->roam_scan_mode,
14371 cmd->roam_ap_sel_mode, cmd->roam_delay,
14372 cmd->num_chan, cmd->num_bssid);
14373 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080014374
Govind Singha4836fd2016-03-07 16:45:38 +053014375 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14376 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014377 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014378 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014379 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014380 }
14381
Govind Singhb53420c2016-03-09 14:32:57 +053014382 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014383}
14384
14385/**
14386 * send_roam_scan_offload_cmd_tlv() - set roam offload command
14387 * @wmi_handle: wmi handle
14388 * @command: command
14389 * @vdev_id: vdev id
14390 *
14391 * This function set roam offload command to fw.
14392 *
14393 * Return: CDF status
14394 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014395static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014396 uint32_t command, uint32_t vdev_id)
14397{
Govind Singh67922e82016-04-01 16:48:57 +053014398 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014399 wmi_roam_scan_cmd_fixed_param *cmd_fp;
14400 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014401 int len;
14402 uint8_t *buf_ptr;
14403
14404 len = sizeof(wmi_roam_scan_cmd_fixed_param);
14405 buf = wmi_buf_alloc(wmi_handle, len);
14406 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014407 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14408 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014409 }
14410
14411 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14412
14413 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14414 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14415 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14416 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14417 cmd_fp->vdev_id = vdev_id;
14418 cmd_fp->command_arg = command;
14419
14420 status = wmi_unified_cmd_send(wmi_handle, buf,
14421 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014422 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014423 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014424 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014425 goto error;
14426 }
14427
Govind Singhb53420c2016-03-09 14:32:57 +053014428 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14429 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014430
14431error:
14432 wmi_buf_free(buf);
14433
Govind Singh67922e82016-04-01 16:48:57 +053014434 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014435}
14436
14437/**
14438 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14439 * @wmi_handle: wmi handle
14440 * @ap_profile_p: ap profile
14441 * @vdev_id: vdev id
14442 *
14443 * Send WMI_ROAM_AP_PROFILE to firmware
14444 *
14445 * Return: CDF status
14446 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014447static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014448 wmi_ap_profile *ap_profile_p,
14449 uint32_t vdev_id)
14450{
Govind Singha4836fd2016-03-07 16:45:38 +053014451 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014452 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014453 int len;
14454 uint8_t *buf_ptr;
14455 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14456
14457 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14458
14459 buf = wmi_buf_alloc(wmi_handle, len);
14460 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014461 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14462 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014463 }
14464
14465 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14466 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14467 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14468 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14469 WMITLV_GET_STRUCT_TLVLEN
14470 (wmi_roam_ap_profile_fixed_param));
14471 /* fill in threshold values */
14472 roam_ap_profile_fp->vdev_id = vdev_id;
14473 roam_ap_profile_fp->id = 0;
14474 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14475
Govind Singhb53420c2016-03-09 14:32:57 +053014476 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014477 WMITLV_SET_HDR(buf_ptr,
14478 WMITLV_TAG_STRUC_wmi_ap_profile,
14479 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14480 status = wmi_unified_cmd_send(wmi_handle, buf,
14481 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014482 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014483 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014484 status);
Govind Singh67922e82016-04-01 16:48:57 +053014485 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014486 }
14487
Govind Singhb53420c2016-03-09 14:32:57 +053014488 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014489
Govind Singh67922e82016-04-01 16:48:57 +053014490 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014491}
14492
14493/**
14494 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14495 * @wmi_handle: wmi handle
14496 * @scan_period: scan period
14497 * @scan_age: scan age
14498 * @vdev_id: vdev id
14499 *
14500 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14501 *
14502 * Return: CDF status
14503 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014504static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014505 uint32_t scan_period,
14506 uint32_t scan_age,
14507 uint32_t vdev_id)
14508{
Govind Singh67922e82016-04-01 16:48:57 +053014509 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014510 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014511 int len;
14512 uint8_t *buf_ptr;
14513 wmi_roam_scan_period_fixed_param *scan_period_fp;
14514
14515 /* Send scan period values */
14516 len = sizeof(wmi_roam_scan_period_fixed_param);
14517 buf = wmi_buf_alloc(wmi_handle, len);
14518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014519 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14520 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014521 }
14522
14523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14524 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14525 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14526 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14527 WMITLV_GET_STRUCT_TLVLEN
14528 (wmi_roam_scan_period_fixed_param));
14529 /* fill in scan period values */
14530 scan_period_fp->vdev_id = vdev_id;
14531 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14532 scan_period_fp->roam_scan_age = scan_age;
14533
14534 status = wmi_unified_cmd_send(wmi_handle, buf,
14535 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014536 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014537 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014538 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014539 goto error;
14540 }
14541
Govind Singhb53420c2016-03-09 14:32:57 +053014542 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014543 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014544 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014545error:
14546 wmi_buf_free(buf);
14547
Govind Singh67922e82016-04-01 16:48:57 +053014548 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014549}
14550
14551/**
14552 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14553 * @wmi_handle: wmi handle
14554 * @chan_count: channel count
14555 * @chan_list: channel list
14556 * @list_type: list type
14557 * @vdev_id: vdev id
14558 *
14559 * Set roam offload channel list.
14560 *
14561 * Return: CDF status
14562 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014563static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014564 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014565 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014566 uint8_t list_type, uint32_t vdev_id)
14567{
Govind Singha4836fd2016-03-07 16:45:38 +053014568 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014569 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014570 int len, list_tlv_len;
14571 int i;
14572 uint8_t *buf_ptr;
14573 wmi_roam_chan_list_fixed_param *chan_list_fp;
14574 A_UINT32 *roam_chan_list_array;
14575
14576 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014577 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014578 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014579 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014580 }
14581 /* Channel list is a table of 2 TLV's */
14582 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14583 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14584 buf = wmi_buf_alloc(wmi_handle, len);
14585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014586 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14587 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014588 }
14589
14590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14591 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14592 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14593 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14594 WMITLV_GET_STRUCT_TLVLEN
14595 (wmi_roam_chan_list_fixed_param));
14596 chan_list_fp->vdev_id = vdev_id;
14597 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014598 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014599 /* external app is controlling channel list */
14600 chan_list_fp->chan_list_type =
14601 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14602 } else {
14603 /* umac supplied occupied channel list in LFR */
14604 chan_list_fp->chan_list_type =
14605 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14606 }
14607
14608 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14609 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14610 (chan_list_fp->num_chan * sizeof(uint32_t)));
14611 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014612 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014613 for (i = 0; ((i < chan_list_fp->num_chan) &&
14614 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14615 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014616 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014617 }
14618
14619 status = wmi_unified_cmd_send(wmi_handle, buf,
14620 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014621 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014622 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014623 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014624 goto error;
14625 }
14626
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014627 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014628 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014629error:
14630 wmi_buf_free(buf);
14631
Govind Singh67922e82016-04-01 16:48:57 +053014632 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014633}
14634
14635/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014636 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14637 * @wmi_handle: wmi handle
14638 * @req_buf: per roam config buffer
14639 *
14640 * Return: QDF status
14641 */
14642static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14643 struct wmi_per_roam_config_req *req_buf)
14644{
14645 wmi_buf_t buf = NULL;
14646 QDF_STATUS status;
14647 int len;
14648 uint8_t *buf_ptr;
14649 wmi_roam_per_config_fixed_param *wmi_per_config;
14650
14651 len = sizeof(wmi_roam_per_config_fixed_param);
14652 buf = wmi_buf_alloc(wmi_handle, len);
14653 if (!buf) {
14654 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14655 return QDF_STATUS_E_NOMEM;
14656 }
14657
14658 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14659 wmi_per_config =
14660 (wmi_roam_per_config_fixed_param *) buf_ptr;
14661 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14662 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14663 WMITLV_GET_STRUCT_TLVLEN
14664 (wmi_roam_per_config_fixed_param));
14665
14666 /* fill in per roam config values */
14667 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014668
14669 wmi_per_config->enable = req_buf->per_config.enable;
14670 wmi_per_config->high_rate_thresh =
14671 (req_buf->per_config.tx_high_rate_thresh << 16) |
14672 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14673 wmi_per_config->low_rate_thresh =
14674 (req_buf->per_config.tx_low_rate_thresh << 16) |
14675 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14676 wmi_per_config->pkt_err_rate_thresh_pct =
14677 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14678 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14679 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014680 wmi_per_config->pkt_err_rate_mon_time =
14681 (req_buf->per_config.tx_per_mon_time << 16) |
14682 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053014683 wmi_per_config->min_candidate_rssi =
14684 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014685
14686 /* Send per roam config parameters */
14687 status = wmi_unified_cmd_send(wmi_handle, buf,
14688 len, WMI_ROAM_PER_CONFIG_CMDID);
14689 if (QDF_IS_STATUS_ERROR(status)) {
14690 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14691 status);
14692 wmi_buf_free(buf);
14693 return status;
14694 }
14695
14696 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14697 req_buf->per_config.enable, req_buf->vdev_id);
14698 return QDF_STATUS_SUCCESS;
14699}
14700
14701/**
Govind Singha4836fd2016-03-07 16:45:38 +053014702 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14703 * @wmi_handle: wmi handle
14704 * @rssi_change_thresh: RSSI Change threshold
14705 * @bcn_rssi_weight: beacon RSSI weight
14706 * @vdev_id: vdev id
14707 *
14708 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14709 *
14710 * Return: CDF status
14711 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014712static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014713 uint32_t vdev_id,
14714 int32_t rssi_change_thresh,
14715 uint32_t bcn_rssi_weight,
14716 uint32_t hirssi_delay_btw_scans)
14717{
Govind Singha4836fd2016-03-07 16:45:38 +053014718 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014719 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014720 int len;
14721 uint8_t *buf_ptr;
14722 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14723
14724 /* Send rssi change parameters */
14725 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14726 buf = wmi_buf_alloc(wmi_handle, len);
14727 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014728 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14729 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014730 }
14731
14732 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14733 rssi_change_fp =
14734 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14735 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14736 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14737 WMITLV_GET_STRUCT_TLVLEN
14738 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14739 /* fill in rssi change threshold (hysteresis) values */
14740 rssi_change_fp->vdev_id = vdev_id;
14741 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14742 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14743 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14744
14745 status = wmi_unified_cmd_send(wmi_handle, buf,
14746 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014747 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014748 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014749 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014750 goto error;
14751 }
14752
Govind Singhb53420c2016-03-09 14:32:57 +053014753 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014754 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014755 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14756 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014757error:
14758 wmi_buf_free(buf);
14759
Govind Singh67922e82016-04-01 16:48:57 +053014760 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014761}
14762
14763/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14764 * @wmi_handle: wmi handle.
14765 * @cmd: size of command structure.
14766 * @per_entry_size: per entry size.
14767 *
14768 * This utility function calculates how many hotlist entries can
14769 * fit in one page.
14770 *
14771 * Return: number of entries
14772 */
14773static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14774 size_t cmd_size,
14775 size_t per_entry_size)
14776{
14777 uint32_t avail_space = 0;
14778 int num_entries = 0;
14779 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14780
14781 /* Calculate number of hotlist entries that can
14782 * be passed in wma message request.
14783 */
14784 avail_space = max_msg_len - cmd_size;
14785 num_entries = avail_space / per_entry_size;
14786 return num_entries;
14787}
14788
14789/**
14790 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14791 * @wmi_handle: wmi handle
14792 * @photlist: hotlist command params
14793 * @buf_len: buffer length
14794 *
14795 * This function fills individual elements for hotlist request and
14796 * TLV for bssid entries
14797 *
14798 * Return: CDF Status.
14799 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014800static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014801 struct ext_scan_setbssi_hotlist_params *
14802 photlist, int *buf_len)
14803{
14804 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14805 wmi_extscan_hotlist_entry *dest_hotlist;
14806 struct ap_threshold_params *src_ap = photlist->ap;
14807 wmi_buf_t buf;
14808 uint8_t *buf_ptr;
14809
14810 int j, index = 0;
14811 int cmd_len = 0;
14812 int num_entries;
14813 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014814 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014815 int len = sizeof(*cmd);
14816
14817 len += WMI_TLV_HDR_SIZE;
14818 cmd_len = len;
14819
14820 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14821 cmd_len,
14822 sizeof(*dest_hotlist));
14823 /* setbssid hotlist expects the bssid list
14824 * to be non zero value
14825 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014826 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014827 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014828 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014829 }
14830
14831 /* Split the hot list entry pages and send multiple command
14832 * requests if the buffer reaches the maximum request size
14833 */
14834 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014835 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014836 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14837 buf = wmi_buf_alloc(wmi_handle, len);
14838 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014839 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14840 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014841 }
14842 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14843 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14844 buf_ptr;
14845 WMITLV_SET_HDR(&cmd->tlv_header,
14846 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14847 WMITLV_GET_STRUCT_TLVLEN
14848 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14849
14850 /* Multiple requests are sent until the num_entries_in_page
14851 * matches the total_entries
14852 */
14853 cmd->request_id = photlist->requestId;
14854 cmd->vdev_id = photlist->sessionId;
14855 cmd->total_entries = numap;
14856 cmd->mode = 1;
14857 cmd->num_entries_in_page = min_entries;
14858 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14859 cmd->first_entry_index = index;
14860
Govind Singhb53420c2016-03-09 14:32:57 +053014861 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014862 __func__, cmd->vdev_id, cmd->total_entries,
14863 cmd->num_entries_in_page,
14864 cmd->lost_ap_scan_count);
14865
14866 buf_ptr += sizeof(*cmd);
14867 WMITLV_SET_HDR(buf_ptr,
14868 WMITLV_TAG_ARRAY_STRUC,
14869 min_entries * sizeof(wmi_extscan_hotlist_entry));
14870 dest_hotlist = (wmi_extscan_hotlist_entry *)
14871 (buf_ptr + WMI_TLV_HDR_SIZE);
14872
14873 /* Populate bssid, channel info and rssi
14874 * for the bssid's that are sent as hotlists.
14875 */
14876 for (j = 0; j < min_entries; j++) {
14877 WMITLV_SET_HDR(dest_hotlist,
14878 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14879 WMITLV_GET_STRUCT_TLVLEN
14880 (wmi_extscan_hotlist_entry));
14881
14882 dest_hotlist->min_rssi = src_ap->low;
14883 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14884 &dest_hotlist->bssid);
14885
Govind Singhb53420c2016-03-09 14:32:57 +053014886 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014887 __func__, dest_hotlist->channel,
14888 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014889 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014890 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14891 __func__, dest_hotlist->bssid.mac_addr31to0,
14892 dest_hotlist->bssid.mac_addr47to32);
14893 dest_hotlist++;
14894 src_ap++;
14895 }
14896 buf_ptr += WMI_TLV_HDR_SIZE +
14897 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14898
14899 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14900 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014901 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014902 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014903 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014904 }
14905 index = index + min_entries;
14906 num_entries = numap - min_entries;
14907 len = cmd_len;
14908 }
Govind Singhb53420c2016-03-09 14:32:57 +053014909 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014910}
14911
Govind Singhbca3b1b2016-05-02 17:59:24 +053014912/**
Dustin Brown4423f632017-01-13 15:24:07 -080014913 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14914 * @wmi_handle: the WMI handle
14915 * @vdev_id: the Id of the vdev to apply the configuration to
14916 * @ucast_mode: the active BPF mode to configure for unicast packets
14917 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14918 * packets
14919 *
14920 * Return: QDF status
14921 */
14922static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14923 uint8_t vdev_id,
14924 enum wmi_host_active_bpf_mode ucast_mode,
14925 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14926{
14927 const WMITLV_TAG_ID tag_id =
14928 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14929 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14930 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14931 QDF_STATUS status;
14932 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14933 wmi_buf_t buf;
14934
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014935 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080014936 vdev_id, ucast_mode, mcast_bcast_mode);
14937
14938 /* allocate command buffer */
14939 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14940 if (!buf) {
14941 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14942 return QDF_STATUS_E_NOMEM;
14943 }
14944
14945 /* set TLV header */
14946 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14947 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14948
14949 /* populate data */
14950 cmd->vdev_id = vdev_id;
14951 cmd->uc_mode = ucast_mode;
14952 cmd->mcbc_mode = mcast_bcast_mode;
14953
14954 /* send to FW */
14955 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14956 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14957 if (QDF_IS_STATUS_ERROR(status)) {
14958 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14959 status);
14960 wmi_buf_free(buf);
14961 return status;
14962 }
14963
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080014964 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080014965
14966 return QDF_STATUS_SUCCESS;
14967}
14968
14969/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014970 * send_power_dbg_cmd_tlv() - send power debug commands
14971 * @wmi_handle: wmi handle
14972 * @param: wmi power debug parameter
14973 *
14974 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14975 *
14976 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14977 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014978static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14979 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014980{
14981 wmi_buf_t buf = NULL;
14982 QDF_STATUS status;
14983 int len, args_tlv_len;
14984 uint8_t *buf_ptr;
14985 uint8_t i;
14986 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14987 uint32_t *cmd_args;
14988
14989 /* Prepare and send power debug cmd parameters */
14990 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14991 len = sizeof(*cmd) + args_tlv_len;
14992 buf = wmi_buf_alloc(wmi_handle, len);
14993 if (!buf) {
14994 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14995 return QDF_STATUS_E_NOMEM;
14996 }
14997
14998 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14999 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15000 WMITLV_SET_HDR(&cmd->tlv_header,
15001 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15002 WMITLV_GET_STRUCT_TLVLEN
15003 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15004
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015005 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15006 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015007 cmd->module_id = param->module_id;
15008 cmd->num_args = param->num_args;
15009 buf_ptr += sizeof(*cmd);
15010 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15011 (param->num_args * sizeof(uint32_t)));
15012 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15013 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
15014 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
15015 cmd_args[i] = param->args[i];
15016 WMI_LOGI("%d,", param->args[i]);
15017 }
15018
15019 status = wmi_unified_cmd_send(wmi_handle, buf,
15020 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15021 if (QDF_IS_STATUS_ERROR(status)) {
15022 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15023 status);
15024 goto error;
15025 }
15026
15027 return QDF_STATUS_SUCCESS;
15028error:
15029 wmi_buf_free(buf);
15030
15031 return status;
15032}
15033
Kiran Venkatappa26117052016-12-23 19:58:54 +053015034/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015035 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015036 * @buf_ptr: pointer to current position in init command buffer
15037 * @len: pointer to length. This will be updated with current lenght of cmd
15038 * @param: point host parameters for init command
15039 *
15040 * Return: Updated pointer of buf_ptr.
15041 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015042static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
15043 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053015044{
15045 uint16_t idx;
15046
15047 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
15048 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
15049 wmi_pdev_band_to_mac *band_to_mac;
15050
15051 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
15052 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
15053 sizeof(wmi_resource_config) +
15054 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
15055 sizeof(wlan_host_memory_chunk)));
15056
15057 WMITLV_SET_HDR(&hw_mode->tlv_header,
15058 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
15059 (WMITLV_GET_STRUCT_TLVLEN
15060 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
15061
15062 hw_mode->hw_mode_index = param->hw_mode_id;
15063 hw_mode->num_band_to_mac = param->num_band_to_mac;
15064
15065 buf_ptr = (uint8_t *) (hw_mode + 1);
15066 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
15067 WMI_TLV_HDR_SIZE);
15068 for (idx = 0; idx < param->num_band_to_mac; idx++) {
15069 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
15070 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
15071 WMITLV_GET_STRUCT_TLVLEN
15072 (wmi_pdev_band_to_mac));
15073 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015074 wmi_handle->ops->convert_pdev_id_host_to_target(
15075 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015076 band_to_mac[idx].start_freq =
15077 param->band_to_mac[idx].start_freq;
15078 band_to_mac[idx].end_freq =
15079 param->band_to_mac[idx].end_freq;
15080 }
15081 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15082 (param->num_band_to_mac *
15083 sizeof(wmi_pdev_band_to_mac)) +
15084 WMI_TLV_HDR_SIZE;
15085
15086 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
15087 (param->num_band_to_mac *
15088 sizeof(wmi_pdev_band_to_mac)));
15089 }
15090
15091 return buf_ptr;
15092}
15093
Govind Singhe7f2f342016-05-23 12:12:52 +053015094/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015095 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15096 * @wmi_handle: wmi handle
15097 * @param: wmi multiple vdev restart req param
15098 *
15099 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15100 *
15101 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15102 */
15103static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15104 wmi_unified_t wmi_handle,
15105 struct multiple_vdev_restart_params *param)
15106{
15107 wmi_buf_t buf;
15108 QDF_STATUS qdf_status;
15109 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15110 int i;
15111 uint8_t *buf_ptr;
15112 uint32_t *vdev_ids;
15113 wmi_channel *chan_info;
15114 struct channel_param *tchan_info;
15115 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15116
15117 len += sizeof(wmi_channel);
15118 if (param->num_vdevs)
15119 len += sizeof(uint32_t) * param->num_vdevs;
15120
15121 buf = wmi_buf_alloc(wmi_handle, len);
15122 if (!buf) {
15123 WMI_LOGE("Failed to allocate memory\n");
15124 qdf_status = QDF_STATUS_E_NOMEM;
15125 goto end;
15126 }
15127
15128 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15129 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15130 buf_ptr;
15131
15132 WMITLV_SET_HDR(&cmd->tlv_header,
15133 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15134 WMITLV_GET_STRUCT_TLVLEN
15135 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015136 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15137 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015138 cmd->requestor_id = param->requestor_id;
15139 cmd->disable_hw_ack = param->disable_hw_ack;
15140 cmd->cac_duration_ms = param->cac_duration_ms;
15141 cmd->num_vdevs = param->num_vdevs;
15142
15143 buf_ptr += sizeof(*cmd);
15144
15145 WMITLV_SET_HDR(buf_ptr,
15146 WMITLV_TAG_ARRAY_UINT32,
15147 sizeof(A_UINT32) * param->num_vdevs);
15148 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15149 for (i = 0; i < param->num_vdevs; i++) {
15150 vdev_ids[i] = param->vdev_ids[i];
15151 }
15152
15153 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
15154
15155 WMITLV_SET_HDR(buf_ptr,
15156 WMITLV_TAG_STRUC_wmi_channel,
15157 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015158 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015159 tchan_info = &(param->ch_param);
15160 chan_info->mhz = tchan_info->mhz;
15161 chan_info->band_center_freq1 = tchan_info->cfreq1;
15162 chan_info->band_center_freq2 = tchan_info->cfreq2;
15163 if (tchan_info->is_chan_passive)
15164 WMI_SET_CHANNEL_FLAG(chan_info,
15165 WMI_CHAN_FLAG_PASSIVE);
15166 if (tchan_info->allow_vht)
15167 WMI_SET_CHANNEL_FLAG(chan_info,
15168 WMI_CHAN_FLAG_ALLOW_VHT);
15169 else if (tchan_info->allow_ht)
15170 WMI_SET_CHANNEL_FLAG(chan_info,
15171 WMI_CHAN_FLAG_ALLOW_HT);
15172 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15173 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15174 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15175 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15176 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15177 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
15178
15179 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15180 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15181
15182 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15183 WMI_LOGE("%s: Failed to send\n", __func__);
15184 wmi_buf_free(buf);
15185 }
15186
15187end:
15188 return qdf_status;
15189}
15190
15191/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015192 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15193 * @wmi_handle: wmi handle
15194 * @pdev_id: pdev id
15195 *
15196 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15197 *
15198 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15199 */
15200static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15201 uint32_t pdev_id)
15202{
15203 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15204 wmi_buf_t buf;
15205 uint16_t len;
15206 QDF_STATUS ret;
15207
15208 len = sizeof(*cmd);
15209 buf = wmi_buf_alloc(wmi_handle, len);
15210
15211 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15212
15213 if (!buf) {
15214 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15215 return QDF_STATUS_E_NOMEM;
15216 }
15217
15218 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15219 wmi_buf_data(buf);
15220
15221 WMITLV_SET_HDR(&cmd->tlv_header,
15222 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15223 WMITLV_GET_STRUCT_TLVLEN(
15224 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15225
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015226 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015227 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15228 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15229 if (QDF_IS_STATUS_ERROR(ret)) {
15230 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15231 __func__, ret, pdev_id);
15232 wmi_buf_free(buf);
15233 return QDF_STATUS_E_FAILURE;
15234 }
15235
15236 return QDF_STATUS_SUCCESS;
15237}
15238
15239/**
15240 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15241 * @wmi_handle: wmi handle
15242 * @pdev_id: pdev id
15243 *
15244 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15245 *
15246 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15247 */
15248static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15249 uint32_t pdev_id)
15250{
15251 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15252 wmi_buf_t buf;
15253 uint16_t len;
15254 QDF_STATUS ret;
15255
15256 len = sizeof(*cmd);
15257 buf = wmi_buf_alloc(wmi_handle, len);
15258
15259 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15260
15261 if (!buf) {
15262 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15263 return QDF_STATUS_E_NOMEM;
15264 }
15265
15266 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15267 wmi_buf_data(buf);
15268
15269 WMITLV_SET_HDR(&cmd->tlv_header,
15270 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15271 WMITLV_GET_STRUCT_TLVLEN(
15272 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15273
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015274 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015275 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15276 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15277 if (QDF_IS_STATUS_ERROR(ret)) {
15278 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15279 __func__, ret, pdev_id);
15280 wmi_buf_free(buf);
15281 return QDF_STATUS_E_FAILURE;
15282 }
15283
15284 return QDF_STATUS_SUCCESS;
15285}
15286
15287/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015288 * init_cmd_send_tlv() - send initialization cmd to fw
15289 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015290 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015291 *
15292 * Return: QDF_STATUS_SUCCESS for success or error code
15293 */
15294static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015295 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015296{
15297 wmi_buf_t buf;
15298 wmi_init_cmd_fixed_param *cmd;
15299 wmi_abi_version my_vers;
15300 int num_whitelist;
15301 uint8_t *buf_ptr;
15302 wmi_resource_config *resource_cfg;
15303 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015304 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015305 uint16_t idx;
15306 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015307 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015308
Kiran Venkatappa26117052016-12-23 19:58:54 +053015309 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15310 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015311 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015312
15313 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15314 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15315 WMI_TLV_HDR_SIZE +
15316 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15317
15318 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015319 if (!buf) {
15320 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15321 return QDF_STATUS_E_FAILURE;
15322 }
15323
15324 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15325 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15326 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15327
15328 host_mem_chunks = (wlan_host_memory_chunk *)
15329 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15330 + WMI_TLV_HDR_SIZE);
15331
15332 WMITLV_SET_HDR(&cmd->tlv_header,
15333 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15334 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15335
Kiran Venkatappa26117052016-12-23 19:58:54 +053015336 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015337 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15338 WMITLV_TAG_STRUC_wmi_resource_config,
15339 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15340
Kiran Venkatappa26117052016-12-23 19:58:54 +053015341 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015342 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15343 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15344 WMITLV_GET_STRUCT_TLVLEN
15345 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015346 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15347 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15348 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015349 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15350 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015351 idx, host_mem_chunks[idx].size,
15352 host_mem_chunks[idx].ptr);
15353 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015354 cmd->num_host_mem_chunks = param->num_mem_chunks;
15355 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15356
Govind Singhe7f2f342016-05-23 12:12:52 +053015357 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15358 WMITLV_TAG_ARRAY_STRUC,
15359 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015360 param->num_mem_chunks));
15361
15362 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015363 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015364
15365 num_whitelist = sizeof(version_whitelist) /
15366 sizeof(wmi_whitelist_version_info);
15367 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
15368 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
15369 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
15370 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
15371 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
15372 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
15373
Govind Singh87542482016-06-08 19:40:11 +053015374#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015375 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
15376 &my_vers,
15377 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
15378 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053015379#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015380 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
15381 __func__,
15382 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
15383 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
15384 cmd->host_abi_vers.abi_version_ns_0,
15385 cmd->host_abi_vers.abi_version_ns_1,
15386 cmd->host_abi_vers.abi_version_ns_2,
15387 cmd->host_abi_vers.abi_version_ns_3);
15388
15389 /* Save version sent from host -
15390 * Will be used to check ready event
15391 */
Govind Singh87542482016-06-08 19:40:11 +053015392#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015393 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
15394 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015395#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053015396 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15397 if (QDF_IS_STATUS_ERROR(ret)) {
15398 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15399 ret);
15400 wmi_buf_free(buf);
15401 }
15402 return ret;
15403
Govind Singhe7f2f342016-05-23 12:12:52 +053015404}
15405
15406/**
15407 * save_service_bitmap_tlv() - save service bitmap
15408 * @wmi_handle: wmi handle
15409 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080015410 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015411 *
15412 * Return: None
15413 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015414#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015415static
Rajeev Kumar77901472017-02-12 02:12:17 -080015416void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15417 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015418{
15419 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15420 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15421
15422 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15423 param_buf->wmi_service_bitmap,
15424 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015425
15426 if (bitmap_buf)
15427 qdf_mem_copy(bitmap_buf,
15428 param_buf->wmi_service_bitmap,
15429 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015430}
15431#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015432static
Rajeev Kumar77901472017-02-12 02:12:17 -080015433void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15434 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015435{
Rajeev Kumar77901472017-02-12 02:12:17 -080015436 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15437 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015438
Rajeev Kumar77901472017-02-12 02:12:17 -080015439 if (bitmap_buf)
15440 qdf_mem_copy(bitmap_buf,
15441 param_buf->wmi_service_bitmap,
15442 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15443}
Govind Singhe7f2f342016-05-23 12:12:52 +053015444#endif
15445
15446/**
15447 * is_service_enabled_tlv() - Check if service enabled
15448 * @param wmi_handle: wmi handle
15449 * @param service_id: service identifier
15450 *
15451 * Return: 1 enabled, 0 disabled
15452 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015453#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015454static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15455 uint32_t service_id)
15456{
15457 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15458 service_id);
15459}
15460#else
15461static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15462 uint32_t service_id)
15463{
15464 return false;
15465}
15466#endif
15467
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015468static inline void copy_ht_cap_info(uint32_t ev_target_cap,
15469 struct wlan_psoc_target_capability_info *cap)
15470{
15471 /* except LDPC all flags are common betwen legacy and here
15472 * also IBFEER is not defined for TLV
15473 */
15474 cap->ht_cap_info |= ev_target_cap & (
15475 WMI_HT_CAP_ENABLED
15476 | WMI_HT_CAP_HT20_SGI
15477 | WMI_HT_CAP_DYNAMIC_SMPS
15478 | WMI_HT_CAP_TX_STBC
15479 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
15480 | WMI_HT_CAP_RX_STBC
15481 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
15482 | WMI_HT_CAP_LDPC
15483 | WMI_HT_CAP_L_SIG_TXOP_PROT
15484 | WMI_HT_CAP_MPDU_DENSITY
15485 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
15486 | WMI_HT_CAP_HT40_SGI);
15487 if (ev_target_cap & WMI_HT_CAP_LDPC)
15488 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
15489 WMI_HOST_HT_CAP_TX_LDPC;
15490}
Govind Singhe7f2f342016-05-23 12:12:52 +053015491/**
15492 * extract_service_ready_tlv() - extract service ready event
15493 * @wmi_handle: wmi handle
15494 * @param evt_buf: pointer to received event buffer
15495 * @param cap: pointer to hold target capability information extracted from even
15496 *
15497 * Return: QDF_STATUS_SUCCESS for success or error code
15498 */
15499static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015500 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015501{
15502 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15503 wmi_service_ready_event_fixed_param *ev;
15504
15505
15506 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15507
15508 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15509 if (!ev) {
15510 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15511 return QDF_STATUS_E_FAILURE;
15512 }
15513
15514 cap->phy_capability = ev->phy_capability;
15515 cap->max_frag_entry = ev->max_frag_entry;
15516 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053015517 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053015518 cap->vht_cap_info = ev->vht_cap_info;
15519 cap->vht_supp_mcs = ev->vht_supp_mcs;
15520 cap->hw_min_tx_power = ev->hw_min_tx_power;
15521 cap->hw_max_tx_power = ev->hw_max_tx_power;
15522 cap->sys_cap_info = ev->sys_cap_info;
15523 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15524 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15525 cap->max_num_scan_channels = ev->max_num_scan_channels;
15526 cap->max_supported_macs = ev->max_supported_macs;
15527 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15528 cap->txrx_chainmask = ev->txrx_chainmask;
15529 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15530 cap->num_msdu_desc = ev->num_msdu_desc;
15531
15532 return QDF_STATUS_SUCCESS;
15533}
15534
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015535/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15536 * to host internal WMI_HOST_REGDMN_MODE values.
15537 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15538 * host currently. Add this in the future if required.
15539 * 11AX (Phase II) : 11ax related values are not currently
15540 * advertised separately by FW. As part of phase II regulatory bring-up,
15541 * finalize the advertisement mechanism.
15542 * @target_wireless_mode: target wireless mode received in message
15543 *
15544 * Return: returns the host internal wireless mode.
15545 */
15546static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15547{
15548
15549 uint32_t wireless_modes = 0;
15550
15551 if (target_wireless_mode & REGDMN_MODE_11A)
15552 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15553
15554 if (target_wireless_mode & REGDMN_MODE_TURBO)
15555 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15556
15557 if (target_wireless_mode & REGDMN_MODE_11B)
15558 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15559
15560 if (target_wireless_mode & REGDMN_MODE_PUREG)
15561 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15562
15563 if (target_wireless_mode & REGDMN_MODE_11G)
15564 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15565
15566 if (target_wireless_mode & REGDMN_MODE_108G)
15567 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15568
15569 if (target_wireless_mode & REGDMN_MODE_108A)
15570 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15571
15572 if (target_wireless_mode & REGDMN_MODE_XR)
15573 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15574
15575 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15576 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15577
15578 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15579 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15580
15581 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15582 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15583
15584 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15585 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15586
15587 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15588 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15589
15590 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15591 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15592
15593 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15594 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15595
15596 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15597 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15598
15599 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15600 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15601
15602 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15603 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15604
15605 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15606 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15607
15608 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15609 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15610
15611 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15612 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15613
15614 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15615 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15616
15617 return wireless_modes;
15618}
15619
Govind Singhe7f2f342016-05-23 12:12:52 +053015620/**
15621 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15622 * @wmi_handle: wmi handle
15623 * @param evt_buf: Pointer to event buffer
15624 * @param cap: pointer to hold HAL reg capabilities
15625 *
15626 * Return: QDF_STATUS_SUCCESS for success or error code
15627 */
15628static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015629 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015630{
15631 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15632
15633 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15634
15635 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15636 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015637 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015638
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015639 cap->wireless_modes = convert_wireless_modes_tlv(
15640 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015641
Govind Singhe7f2f342016-05-23 12:12:52 +053015642 return QDF_STATUS_SUCCESS;
15643}
15644
15645/**
15646 * extract_host_mem_req_tlv() - Extract host memory request event
15647 * @wmi_handle: wmi handle
15648 * @param evt_buf: pointer to event buffer
15649 * @param num_entries: pointer to hold number of entries requested
15650 *
15651 * Return: Number of entries requested
15652 */
15653static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15654 void *evt_buf, uint8_t *num_entries)
15655{
15656 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15657 wmi_service_ready_event_fixed_param *ev;
15658
15659 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15660
15661 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15662 if (!ev) {
15663 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15664 return NULL;
15665 }
15666
15667 *num_entries = ev->num_mem_reqs;
15668
15669 return (host_mem_req *)param_buf->mem_reqs;
15670}
15671
15672/**
15673 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15674 * ready function
15675 * @wmi_handle: wmi handle
15676 * @param evt_buf: pointer to event buffer
15677 *
15678 * Return: QDF_STATUS_SUCCESS for success or error code
15679 */
15680static QDF_STATUS
15681save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15682{
15683 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15684 wmi_service_ready_event_fixed_param *ev;
15685
15686
15687 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15688
15689 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15690 if (!ev) {
15691 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15692 return QDF_STATUS_E_FAILURE;
15693 }
15694
Govind Singh87542482016-06-08 19:40:11 +053015695#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015696 /*Save fw version from service ready message */
15697 /*This will be used while sending INIT message */
15698 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15699 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015700#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015701 return QDF_STATUS_SUCCESS;
15702}
15703
15704/**
15705 * ready_extract_init_status_tlv() - Extract init status from ready event
15706 * @wmi_handle: wmi handle
15707 * @param evt_buf: Pointer to event buffer
15708 *
15709 * Return: ready status
15710 */
15711static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15712 void *evt_buf)
15713{
15714 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15715 wmi_ready_event_fixed_param *ev = NULL;
15716
15717
15718 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15719 ev = param_buf->fixed_param;
15720
15721 qdf_print("%s:%d\n", __func__, ev->status);
15722
15723 return ev->status;
15724}
15725
15726/**
15727 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15728 * @wmi_handle: wmi handle
15729 * @param evt_buf: pointer to event buffer
15730 * @param macaddr: Pointer to hold MAC address
15731 *
15732 * Return: QDF_STATUS_SUCCESS for success or error code
15733 */
15734static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15735 void *evt_buf, uint8_t *macaddr)
15736{
15737 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15738 wmi_ready_event_fixed_param *ev = NULL;
15739
15740
15741 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15742 ev = param_buf->fixed_param;
15743
15744 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15745
15746 return QDF_STATUS_SUCCESS;
15747}
15748
15749/**
15750 * extract_dbglog_data_len_tlv() - extract debuglog data length
15751 * @wmi_handle: wmi handle
15752 * @param evt_buf: pointer to event buffer
15753 *
15754 * Return: length
15755 */
15756static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015757 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015758{
15759 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15760
15761 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15762
15763 *len = param_buf->num_bufp;
15764
15765 return param_buf->bufp;
15766}
15767
15768/**
15769 * extract_vdev_start_resp_tlv() - extract vdev start response
15770 * @wmi_handle: wmi handle
15771 * @param evt_buf: pointer to event buffer
15772 * @param vdev_rsp: Pointer to hold vdev response
15773 *
15774 * Return: QDF_STATUS_SUCCESS for success or error code
15775 */
15776static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15777 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15778{
15779 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15780 wmi_vdev_start_response_event_fixed_param *ev;
15781
15782 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15783 if (!param_buf) {
15784 qdf_print("Invalid start response event buffer\n");
15785 return QDF_STATUS_E_INVAL;
15786 }
15787
15788 ev = param_buf->fixed_param;
15789 if (!ev) {
15790 qdf_print("Invalid start response event buffer\n");
15791 return QDF_STATUS_E_INVAL;
15792 }
15793
15794 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15795
15796 vdev_rsp->vdev_id = ev->vdev_id;
15797 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070015798 switch (ev->resp_type) {
15799 case WMI_VDEV_START_RESP_EVENT:
15800 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
15801 break;
15802 case WMI_VDEV_RESTART_RESP_EVENT:
15803 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
15804 break;
15805 default:
15806 qdf_print("Invalid start response event buffer\n");
15807 break;
15808 };
Govind Singhe7f2f342016-05-23 12:12:52 +053015809 vdev_rsp->status = ev->status;
15810 vdev_rsp->chain_mask = ev->chain_mask;
15811 vdev_rsp->smps_mode = ev->smps_mode;
15812 vdev_rsp->mac_id = ev->mac_id;
15813 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15814 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15815
15816 return QDF_STATUS_SUCCESS;
15817}
15818
15819/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015820 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053015821 * @wmi_handle: wmi handle
15822 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015823 * @param num_vdevs: Pointer to hold num vdev
15824 *
15825 * Return: QDF_STATUS_SUCCESS for success or error code
15826 */
15827static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15828 void *evt_buf, uint32_t *num_vdevs)
15829{
15830 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15831 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15832 uint32_t vdev_map;
15833
15834 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
15835 if (!param_buf) {
15836 qdf_print("Invalid tbtt update ext event buffer\n");
15837 return QDF_STATUS_E_INVAL;
15838 }
15839 tbtt_offset_event = param_buf->fixed_param;
15840 vdev_map = tbtt_offset_event->vdev_map;
15841 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
15842
15843 return QDF_STATUS_SUCCESS;
15844}
15845
15846/**
15847 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
15848 * @wmi_handle: wmi handle
15849 * @param evt_buf: pointer to event buffer
15850 * @param num_vdevs: Pointer to hold num vdev
15851 *
15852 * Return: QDF_STATUS_SUCCESS for success or error code
15853 */
15854static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
15855 void *evt_buf, uint32_t *num_vdevs)
15856{
15857 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15858 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
15859
15860 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15861 if (!param_buf) {
15862 qdf_print("Invalid tbtt update ext event buffer\n");
15863 return QDF_STATUS_E_INVAL;
15864 }
15865 tbtt_offset_ext_event = param_buf->fixed_param;
15866
15867 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
15868
15869 return QDF_STATUS_SUCCESS;
15870}
15871
15872/**
15873 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
15874 * @wmi_handle: wmi handle
15875 * @param evt_buf: pointer to event buffer
15876 * @param idx: Index refering to a vdev
15877 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053015878 *
15879 * Return: QDF_STATUS_SUCCESS for success or error code
15880 */
15881static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015882 void *evt_buf, uint8_t idx,
15883 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015884{
15885 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15886 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015887 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053015888
15889 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15890 if (!param_buf) {
15891 qdf_print("Invalid tbtt update event buffer\n");
15892 return QDF_STATUS_E_INVAL;
15893 }
Govind Singhe7f2f342016-05-23 12:12:52 +053015894
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053015895 tbtt_offset_event = param_buf->fixed_param;
15896 vdev_map = tbtt_offset_event->vdev_map;
15897 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
15898 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
15899 return QDF_STATUS_E_INVAL;
15900 tbtt_param->tbttoffset =
15901 param_buf->tbttoffset_list[tbtt_param->vdev_id];
15902
15903 return QDF_STATUS_SUCCESS;
15904}
15905
15906/**
15907 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
15908 * @wmi_handle: wmi handle
15909 * @param evt_buf: pointer to event buffer
15910 * @param idx: Index refering to a vdev
15911 * @param tbtt_param: Pointer to tbttoffset event param
15912 *
15913 * Return: QDF_STATUS_SUCCESS for success or error code
15914 */
15915static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
15916 void *evt_buf, uint8_t idx,
15917 struct tbttoffset_params *tbtt_param)
15918{
15919 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
15920 wmi_tbtt_offset_info *tbtt_offset_info;
15921
15922 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
15923 if (!param_buf) {
15924 qdf_print("Invalid tbtt update event buffer\n");
15925 return QDF_STATUS_E_INVAL;
15926 }
15927 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
15928
15929 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
15930 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053015931
15932 return QDF_STATUS_SUCCESS;
15933}
15934
15935/**
15936 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15937 * @wmi_handle: wmi handle
15938 * @param evt_buf: pointer to event buffer
15939 * @param hdr: Pointer to hold header
15940 * @param bufp: Pointer to hold pointer to rx param buffer
15941 *
15942 * Return: QDF_STATUS_SUCCESS for success or error code
15943 */
15944static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015945 void *evt_buf, struct mgmt_rx_event_params *hdr,
15946 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015947{
15948 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15949 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15950
15951 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15952 if (!param_tlvs) {
15953 WMI_LOGE("Get NULL point message from FW");
15954 return QDF_STATUS_E_INVAL;
15955 }
15956
15957 ev_hdr = param_tlvs->hdr;
15958 if (!hdr) {
15959 WMI_LOGE("Rx event is NULL");
15960 return QDF_STATUS_E_INVAL;
15961 }
15962
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015963 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15964 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015965
15966 hdr->channel = ev_hdr->channel;
15967 hdr->snr = ev_hdr->snr;
15968 hdr->rate = ev_hdr->rate;
15969 hdr->phy_mode = ev_hdr->phy_mode;
15970 hdr->buf_len = ev_hdr->buf_len;
15971 hdr->status = ev_hdr->status;
15972 hdr->flags = ev_hdr->flags;
15973 hdr->rssi = ev_hdr->rssi;
15974 hdr->tsf_delta = ev_hdr->tsf_delta;
15975 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15976
15977 *bufp = param_tlvs->bufp;
15978
15979 return QDF_STATUS_SUCCESS;
15980}
15981
15982/**
15983 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15984 * @wmi_handle: wmi handle
15985 * @param evt_buf: pointer to event buffer
15986 * @param vdev_id: Pointer to hold vdev identifier
15987 *
15988 * Return: QDF_STATUS_SUCCESS for success or error code
15989 */
15990static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15991 void *evt_buf, uint32_t *vdev_id)
15992{
15993 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15994 wmi_vdev_stopped_event_fixed_param *resp_event;
15995
15996 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15997 if (!param_buf) {
15998 WMI_LOGE("Invalid event buffer");
15999 return QDF_STATUS_E_INVAL;
16000 }
16001 resp_event = param_buf->fixed_param;
16002 *vdev_id = resp_event->vdev_id;
16003
16004 return QDF_STATUS_SUCCESS;
16005}
16006
16007/**
16008 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
16009 * @wmi_handle: wmi handle
16010 * @param evt_buf: pointer to event buffer
16011 * @param param: Pointer to hold roam param
16012 *
16013 * Return: QDF_STATUS_SUCCESS for success or error code
16014 */
16015static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
16016 void *evt_buf, wmi_host_roam_event *param)
16017{
16018 WMI_ROAM_EVENTID_param_tlvs *param_buf;
16019 wmi_roam_event_fixed_param *evt;
16020
16021 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
16022 if (!param_buf) {
16023 WMI_LOGE("Invalid roam event buffer");
16024 return QDF_STATUS_E_INVAL;
16025 }
16026
16027 evt = param_buf->fixed_param;
16028 qdf_mem_zero(param, sizeof(*param));
16029
16030 param->vdev_id = evt->vdev_id;
16031 param->reason = evt->reason;
16032 param->rssi = evt->rssi;
16033
16034 return QDF_STATUS_SUCCESS;
16035}
16036
16037/**
16038 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
16039 * @wmi_handle: wmi handle
16040 * @param evt_buf: pointer to event buffer
16041 * @param param: Pointer to hold vdev scan param
16042 *
16043 * Return: QDF_STATUS_SUCCESS for success or error code
16044 */
16045static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016046 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016047{
16048 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
16049 wmi_scan_event_fixed_param *evt = NULL;
16050
16051 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
16052 evt = param_buf->fixed_param;
16053
16054 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016055
Govind Singhe7f2f342016-05-23 12:12:52 +053016056 switch (evt->event) {
16057 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016058 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016059 break;
16060 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016061 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016062 break;
16063 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016064 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016065 break;
16066 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016067 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053016068 break;
16069 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016070 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016071 break;
16072 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016073 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016074 break;
16075 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016076 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016077 break;
16078 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016079 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016080 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053016081 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016082 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016083 break;
16084 case WMI_SCAN_EVENT_MAX:
16085 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016086 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016087 break;
16088 };
16089
16090 switch (evt->reason) {
16091 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016092 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016093 break;
16094 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016095 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016096 break;
16097 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016098 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016099 break;
16100 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016101 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053016102 break;
16103 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016104 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053016105 break;
16106 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016107 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016108 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016109 case WMI_SCAN_REASON_SUSPENDED:
16110 param->reason = SCAN_REASON_SUSPENDED;
16111 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016112 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053016113 param->reason = SCAN_REASON_MAX;
16114 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053016115 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016116 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053016117 break;
16118 };
16119
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053016120 param->chan_freq = evt->channel_freq;
16121 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053016122 param->scan_id = evt->scan_id;
16123 param->vdev_id = evt->vdev_id;
16124
16125 return QDF_STATUS_SUCCESS;
16126}
16127
Frank Liu3d5e9992017-03-15 17:51:43 +080016128#ifdef CONVERGED_TDLS_ENABLE
16129/**
16130 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
16131 * @wmi_handle: wmi handle
16132 * @param evt_buf: pointer to event buffer
16133 * @param param: Pointer to hold vdev tdls param
16134 *
16135 * Return: QDF_STATUS_SUCCESS for success or error code
16136 */
16137static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
16138 void *evt_buf, struct tdls_event_info *param)
16139{
16140 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
16141 wmi_tdls_peer_event_fixed_param *evt;
16142
16143 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
16144 if (!param_buf) {
16145 WMI_LOGE("%s: NULL param_buf", __func__);
16146 return QDF_STATUS_E_NULL_VALUE;
16147 }
16148
16149 evt = param_buf->fixed_param;
16150
16151 qdf_mem_zero(param, sizeof(*param));
16152
16153 param->vdev_id = evt->vdev_id;
16154 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
16155 param->peermac.bytes);
16156 switch (evt->peer_status) {
16157 case WMI_TDLS_SHOULD_DISCOVER:
16158 param->message_type = TDLS_SHOULD_DISCOVER;
16159 break;
16160 case WMI_TDLS_SHOULD_TEARDOWN:
16161 param->message_type = TDLS_SHOULD_TEARDOWN;
16162 break;
16163 case WMI_TDLS_PEER_DISCONNECTED:
16164 param->message_type = TDLS_PEER_DISCONNECTED;
16165 break;
16166 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
16167 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
16168 break;
16169 default:
16170 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
16171 __func__, evt->peer_status);
16172 return QDF_STATUS_E_INVAL;
16173 };
16174
16175 switch (evt->peer_reason) {
16176 case WMI_TDLS_TEARDOWN_REASON_TX:
16177 param->peer_reason = TDLS_TEARDOWN_TX;
16178 break;
16179 case WMI_TDLS_TEARDOWN_REASON_RSSI:
16180 param->peer_reason = TDLS_TEARDOWN_RSSI;
16181 break;
16182 case WMI_TDLS_TEARDOWN_REASON_SCAN:
16183 param->peer_reason = TDLS_TEARDOWN_SCAN;
16184 break;
16185 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
16186 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
16187 break;
16188 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
16189 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
16190 break;
16191 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
16192 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
16193 break;
16194 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
16195 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
16196 break;
16197 case WMI_TDLS_ENTER_BUF_STA:
16198 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
16199 break;
16200 case WMI_TDLS_EXIT_BUF_STA:
16201 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
16202 break;
16203 case WMI_TDLS_ENTER_BT_BUSY_MODE:
16204 param->peer_reason = TDLS_ENTER_BT_BUSY;
16205 break;
16206 case WMI_TDLS_EXIT_BT_BUSY_MODE:
16207 param->peer_reason = TDLS_EXIT_BT_BUSY;
16208 break;
16209 case WMI_TDLS_SCAN_STARTED_EVENT:
16210 param->peer_reason = TDLS_SCAN_STARTED;
16211 break;
16212 case WMI_TDLS_SCAN_COMPLETED_EVENT:
16213 param->peer_reason = TDLS_SCAN_COMPLETED;
16214 break;
16215
16216 default:
16217 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
16218 __func__, evt->peer_reason, evt->peer_status);
16219 return QDF_STATUS_E_INVAL;
16220 };
16221
16222 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
16223 __func__, param->peermac.bytes, param->message_type,
16224 param->peer_reason, param->vdev_id);
16225
16226 return QDF_STATUS_SUCCESS;
16227}
16228#endif
16229
Govind Singhe7f2f342016-05-23 12:12:52 +053016230/**
16231 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
16232 * @wmi_handle: wmi handle
16233 * @param evt_buf: pointer to event buffer
16234 * @param param: Pointer to hold MGMT TX completion params
16235 *
16236 * Return: QDF_STATUS_SUCCESS for success or error code
16237 */
16238static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
16239 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
16240{
16241 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16242 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
16243
16244 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
16245 evt_buf;
16246 if (!param_buf) {
16247 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
16248 return QDF_STATUS_E_INVAL;
16249 }
16250 cmpl_params = param_buf->fixed_param;
16251
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016252 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16253 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053016254 param->desc_id = cmpl_params->desc_id;
16255 param->status = cmpl_params->status;
16256
16257 return QDF_STATUS_SUCCESS;
16258}
16259
16260/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016261 * extract_offchan_data_tx_compl_param_tlv() -
16262 * extract Offchan data tx completion event params
16263 * @wmi_handle: wmi handle
16264 * @param evt_buf: pointer to event buffer
16265 * @param param: Pointer to hold offchan data TX completion params
16266 *
16267 * Return: QDF_STATUS_SUCCESS for success or error code
16268 */
16269static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
16270 wmi_unified_t wmi_handle, void *evt_buf,
16271 struct wmi_host_offchan_data_tx_compl_event *param)
16272{
16273 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
16274 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
16275
16276 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
16277 evt_buf;
16278 if (!param_buf) {
16279 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
16280 return QDF_STATUS_E_INVAL;
16281 }
16282 cmpl_params = param_buf->fixed_param;
16283
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016284 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16285 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016286 param->desc_id = cmpl_params->desc_id;
16287 param->status = cmpl_params->status;
16288
16289 return QDF_STATUS_SUCCESS;
16290}
16291
16292/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016293 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
16294 * status tlv
16295 * @wmi_handle: wmi handle
16296 * @param evt_buf: pointer to event buffer
16297 * @param param: Pointer to hold csa switch count status event param
16298 *
16299 * Return: QDF_STATUS_SUCCESS for success or error code
16300 */
16301static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
16302 wmi_unified_t wmi_handle,
16303 void *evt_buf,
16304 struct pdev_csa_switch_count_status *param)
16305{
16306 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
16307 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
16308
16309 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
16310 evt_buf;
16311 if (!param_buf) {
16312 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
16313 return QDF_STATUS_E_INVAL;
16314 }
16315
16316 csa_status = param_buf->fixed_param;
16317
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016318 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16319 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016320 param->current_switch_count = csa_status->current_switch_count;
16321 param->num_vdevs = csa_status->num_vdevs;
16322 param->vdev_ids = param_buf->vdev_ids;
16323
16324 return QDF_STATUS_SUCCESS;
16325}
16326
16327/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016328 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053016329 * @wmi_handle: wmi handle
16330 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016331 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053016332 *
16333 * Return: QDF_STATUS_SUCCESS for success or error code
16334 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016335static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
16336 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053016337{
16338 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16339 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016340 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053016341
16342 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16343 if (!param_buf) {
16344 WMI_LOGE("Invalid swba event buffer");
16345 return QDF_STATUS_E_INVAL;
16346 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016347
Govind Singhe7f2f342016-05-23 12:12:52 +053016348 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016349 *num_vdevs = swba_event->num_vdevs;
16350 if (!(*num_vdevs)) {
16351 vdev_map = swba_event->vdev_map;
16352 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
16353 }
Govind Singhe7f2f342016-05-23 12:12:52 +053016354
16355 return QDF_STATUS_SUCCESS;
16356}
16357
16358/**
16359 * extract_swba_tim_info_tlv() - extract swba tim info from event
16360 * @wmi_handle: wmi handle
16361 * @param evt_buf: pointer to event buffer
16362 * @param idx: Index to bcn info
16363 * @param tim_info: Pointer to hold tim info
16364 *
16365 * Return: QDF_STATUS_SUCCESS for success or error code
16366 */
16367static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
16368 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
16369{
16370 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16371 wmi_tim_info *tim_info_ev;
16372
16373 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16374 if (!param_buf) {
16375 WMI_LOGE("Invalid swba event buffer");
16376 return QDF_STATUS_E_INVAL;
16377 }
16378
16379 tim_info_ev = &param_buf->tim_info[idx];
16380
16381 tim_info->tim_len = tim_info_ev->tim_len;
16382 tim_info->tim_mcast = tim_info_ev->tim_mcast;
16383 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
16384 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
16385 tim_info->tim_changed = tim_info_ev->tim_changed;
16386 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016387 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016388
16389 return QDF_STATUS_SUCCESS;
16390}
16391
16392/**
16393 * extract_swba_noa_info_tlv() - extract swba NoA information from event
16394 * @wmi_handle: wmi handle
16395 * @param evt_buf: pointer to event buffer
16396 * @param idx: Index to bcn info
16397 * @param p2p_desc: Pointer to hold p2p NoA info
16398 *
16399 * Return: QDF_STATUS_SUCCESS for success or error code
16400 */
16401static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
16402 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
16403{
16404 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
16405 wmi_p2p_noa_info *p2p_noa_info;
16406 uint8_t i = 0;
16407
16408 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
16409 if (!param_buf) {
16410 WMI_LOGE("Invalid swba event buffer");
16411 return QDF_STATUS_E_INVAL;
16412 }
16413
16414 p2p_noa_info = &param_buf->p2p_noa_info[idx];
16415
16416 p2p_desc->modified = false;
16417 p2p_desc->num_descriptors = 0;
16418 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
16419 p2p_desc->modified = true;
16420 p2p_desc->index =
16421 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
16422 p2p_desc->oppPS =
16423 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
16424 p2p_desc->ctwindow =
16425 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
16426 p2p_desc->num_descriptors =
16427 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
16428 (p2p_noa_info);
16429 for (i = 0; i < p2p_desc->num_descriptors; i++) {
16430 p2p_desc->noa_descriptors[i].type_count =
16431 (uint8_t) p2p_noa_info->noa_descriptors[i].
16432 type_count;
16433 p2p_desc->noa_descriptors[i].duration =
16434 p2p_noa_info->noa_descriptors[i].duration;
16435 p2p_desc->noa_descriptors[i].interval =
16436 p2p_noa_info->noa_descriptors[i].interval;
16437 p2p_desc->noa_descriptors[i].start_time =
16438 p2p_noa_info->noa_descriptors[i].start_time;
16439 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053016440 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053016441 }
16442
16443 return QDF_STATUS_SUCCESS;
16444}
16445
Wu Gaocd3a8512017-03-13 20:17:34 +080016446#ifdef CONVERGED_P2P_ENABLE
16447/**
16448 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
16449 * @wmi_handle: wmi handle
16450 * @param evt_buf: pointer to event buffer
16451 * @param param: Pointer to hold p2p noa info
16452 *
16453 * Return: QDF_STATUS_SUCCESS for success or error code
16454 */
16455static QDF_STATUS extract_p2p_noa_ev_param_tlv(
16456 wmi_unified_t wmi_handle, void *evt_buf,
16457 struct p2p_noa_info *param)
16458{
16459 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
16460 wmi_p2p_noa_event_fixed_param *fixed_param;
16461 uint8_t i;
16462 wmi_p2p_noa_info *wmi_noa_info;
16463 uint8_t *buf_ptr;
16464 uint32_t descriptors;
16465
16466 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
16467 if (!param_tlvs) {
16468 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
16469 return QDF_STATUS_E_INVAL;
16470 }
16471
16472 if (!param) {
16473 WMI_LOGE("noa information param is null");
16474 return QDF_STATUS_E_INVAL;
16475 }
16476
16477 fixed_param = param_tlvs->fixed_param;
16478 buf_ptr = (uint8_t *) fixed_param;
16479 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
16480 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
16481
16482 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
16483 WMI_LOGE("%s: noa attr is not modified", __func__);
16484 return QDF_STATUS_E_INVAL;
16485 }
16486
16487 param->vdev_id = fixed_param->vdev_id;
16488 param->index =
16489 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
16490 param->opps_ps =
16491 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
16492 param->ct_window =
16493 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
16494 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
16495 param->num_desc = (uint8_t) descriptors;
16496
16497 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
16498 param->index, param->opps_ps, param->ct_window,
16499 param->num_desc);
16500 for (i = 0; i < param->num_desc; i++) {
16501 param->noa_desc[i].type_count =
16502 (uint8_t) wmi_noa_info->noa_descriptors[i].
16503 type_count;
16504 param->noa_desc[i].duration =
16505 wmi_noa_info->noa_descriptors[i].duration;
16506 param->noa_desc[i].interval =
16507 wmi_noa_info->noa_descriptors[i].interval;
16508 param->noa_desc[i].start_time =
16509 wmi_noa_info->noa_descriptors[i].start_time;
16510 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
16511 __func__, i, param->noa_desc[i].type_count,
16512 param->noa_desc[i].duration,
16513 param->noa_desc[i].interval,
16514 param->noa_desc[i].start_time);
16515 }
16516
16517 return QDF_STATUS_SUCCESS;
16518}
16519
16520/**
16521 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
16522 * information from event
16523 * @wmi_handle: wmi handle
16524 * @param evt_buf: pointer to event buffer
16525 * @param param: Pointer to hold p2p lo stop event information
16526 *
16527 * Return: QDF_STATUS_SUCCESS for success or error code
16528 */
16529static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
16530 wmi_unified_t wmi_handle, void *evt_buf,
16531 struct p2p_lo_event *param)
16532{
16533 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
16534 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
16535
16536 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
16537 evt_buf;
16538 if (!param_tlvs) {
16539 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16540 return QDF_STATUS_E_INVAL;
16541 }
16542
16543 if (!param) {
16544 WMI_LOGE("lo stop event param is null");
16545 return QDF_STATUS_E_INVAL;
16546 }
16547
16548 lo_param = param_tlvs->fixed_param;
16549 param->vdev_id = lo_param->vdev_id;
16550 param->reason_code = lo_param->reason;
16551 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16552 param->vdev_id, param->reason_code);
16553
16554 return QDF_STATUS_SUCCESS;
16555}
16556#endif /* End of CONVERGED_P2P_ENABLE */
16557
Govind Singhe7f2f342016-05-23 12:12:52 +053016558/**
16559 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16560 * @wmi_handle: wmi handle
16561 * @param evt_buf: pointer to event buffer
16562 * @param ev: Pointer to hold peer param
16563 *
16564 * Return: QDF_STATUS_SUCCESS for success or error code
16565 */
16566static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16567 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16568{
16569 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16570 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16571
16572 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16573 kickout_event = param_buf->fixed_param;
16574
16575 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16576 ev->peer_macaddr);
16577
16578 ev->reason = kickout_event->reason;
16579 ev->rssi = kickout_event->rssi;
16580
16581 return QDF_STATUS_SUCCESS;
16582}
16583
16584/**
16585 * extract_all_stats_counts_tlv() - extract all stats count from event
16586 * @wmi_handle: wmi handle
16587 * @param evt_buf: pointer to event buffer
16588 * @param stats_param: Pointer to hold stats count
16589 *
16590 * Return: QDF_STATUS_SUCCESS for success or error code
16591 */
16592static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16593 void *evt_buf, wmi_host_stats_event *stats_param)
16594{
16595 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16596 wmi_stats_event_fixed_param *ev;
16597
16598 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16599
16600 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16601 if (!ev) {
16602 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16603 return QDF_STATUS_E_FAILURE;
16604 }
16605
16606 switch (ev->stats_id) {
16607 case WMI_REQUEST_PEER_STAT:
16608 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16609 break;
16610
16611 case WMI_REQUEST_AP_STAT:
16612 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16613 break;
16614
16615 case WMI_REQUEST_PDEV_STAT:
16616 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16617 break;
16618
16619 case WMI_REQUEST_VDEV_STAT:
16620 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16621 break;
16622
16623 case WMI_REQUEST_BCNFLT_STAT:
16624 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16625 break;
16626
16627 case WMI_REQUEST_VDEV_RATE_STAT:
16628 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16629 break;
16630
16631 default:
16632 stats_param->stats_id = 0;
16633 break;
16634
16635 }
16636
16637 stats_param->num_pdev_stats = ev->num_pdev_stats;
16638 stats_param->num_pdev_ext_stats = 0;
16639 stats_param->num_vdev_stats = ev->num_vdev_stats;
16640 stats_param->num_peer_stats = ev->num_peer_stats;
16641 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16642 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016643 stats_param->pdev_id = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016644
16645 return QDF_STATUS_SUCCESS;
16646}
16647
16648/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016649 * extract_pdev_tx_stats() - extract pdev tx stats from event
16650 */
16651static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
16652{
16653 /* Tx Stats */
16654 tx->comp_queued = tx_stats->comp_queued;
16655 tx->comp_delivered = tx_stats->comp_delivered;
16656 tx->msdu_enqued = tx_stats->msdu_enqued;
16657 tx->mpdu_enqued = tx_stats->mpdu_enqued;
16658 tx->wmm_drop = tx_stats->wmm_drop;
16659 tx->local_enqued = tx_stats->local_enqued;
16660 tx->local_freed = tx_stats->local_freed;
16661 tx->hw_queued = tx_stats->hw_queued;
16662 tx->hw_reaped = tx_stats->hw_reaped;
16663 tx->underrun = tx_stats->underrun;
16664 tx->tx_abort = tx_stats->tx_abort;
16665 tx->mpdus_requed = tx_stats->mpdus_requed;
16666 tx->data_rc = tx_stats->data_rc;
16667 tx->self_triggers = tx_stats->self_triggers;
16668 tx->sw_retry_failure = tx_stats->sw_retry_failure;
16669 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
16670 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
16671 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
16672 tx->pdev_resets = tx_stats->pdev_resets;
16673 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
16674 tx->phy_underrun = tx_stats->phy_underrun;
16675 tx->txop_ovf = tx_stats->txop_ovf;
16676
16677 return;
16678}
16679
16680
16681/**
16682 * extract_pdev_rx_stats() - extract pdev rx stats from event
16683 */
16684static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
16685{
16686 /* Rx Stats */
16687 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
16688 rx->status_rcvd = rx_stats->status_rcvd;
16689 rx->r0_frags = rx_stats->r0_frags;
16690 rx->r1_frags = rx_stats->r1_frags;
16691 rx->r2_frags = rx_stats->r2_frags;
16692 /* Only TLV */
16693 rx->r3_frags = 0;
16694 rx->htt_msdus = rx_stats->htt_msdus;
16695 rx->htt_mpdus = rx_stats->htt_mpdus;
16696 rx->loc_msdus = rx_stats->loc_msdus;
16697 rx->loc_mpdus = rx_stats->loc_mpdus;
16698 rx->oversize_amsdu = rx_stats->oversize_amsdu;
16699 rx->phy_errs = rx_stats->phy_errs;
16700 rx->phy_err_drop = rx_stats->phy_err_drop;
16701 rx->mpdu_errs = rx_stats->mpdu_errs;
16702
16703 return;
16704}
16705
16706/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016707 * extract_pdev_stats_tlv() - extract pdev stats from event
16708 * @wmi_handle: wmi handle
16709 * @param evt_buf: pointer to event buffer
16710 * @param index: Index into pdev stats
16711 * @param pdev_stats: Pointer to hold pdev stats
16712 *
16713 * Return: QDF_STATUS_SUCCESS for success or error code
16714 */
16715static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16716 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16717{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053016718 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16719 wmi_stats_event_fixed_param *ev_param;
16720 uint8_t *data;
16721
16722 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16723 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16724
16725 data = param_buf->data;
16726
16727 if (index < ev_param->num_pdev_stats) {
16728 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
16729 (index * sizeof(wmi_pdev_stats)));
16730
16731 pdev_stats->chan_nf = ev->chan_nf;
16732 pdev_stats->tx_frame_count = ev->tx_frame_count;
16733 pdev_stats->rx_frame_count = ev->rx_frame_count;
16734 pdev_stats->rx_clear_count = ev->rx_clear_count;
16735 pdev_stats->cycle_count = ev->cycle_count;
16736 pdev_stats->phy_err_count = ev->phy_err_count;
16737 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
16738
16739 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
16740 &(ev->pdev_stats.tx));
16741 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
16742 &(ev->pdev_stats.rx));
16743 }
16744
Govind Singhe7f2f342016-05-23 12:12:52 +053016745 return QDF_STATUS_SUCCESS;
16746}
16747
16748/**
16749 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
16750 * @wmi_handle: wmi handle
16751 * @param evt_buf: pointer to event buffer
16752 * @param index: Index into extended pdev stats
16753 * @param pdev_ext_stats: Pointer to hold extended pdev stats
16754 *
16755 * Return: QDF_STATUS_SUCCESS for success or error code
16756 */
16757static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
16758 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
16759{
16760 return QDF_STATUS_SUCCESS;
16761}
16762
16763/**
16764 * extract_vdev_stats_tlv() - extract vdev stats from event
16765 * @wmi_handle: wmi handle
16766 * @param evt_buf: pointer to event buffer
16767 * @param index: Index into vdev stats
16768 * @param vdev_stats: Pointer to hold vdev stats
16769 *
16770 * Return: QDF_STATUS_SUCCESS for success or error code
16771 */
16772static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
16773 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
16774{
16775 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16776 wmi_stats_event_fixed_param *ev_param;
16777 uint8_t *data;
16778
16779 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16780 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16781 data = (uint8_t *) param_buf->data;
16782
16783 if (index < ev_param->num_vdev_stats) {
16784 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
16785 ((ev_param->num_pdev_stats) *
16786 sizeof(wmi_pdev_stats)) +
16787 (index * sizeof(wmi_vdev_stats)));
16788
16789 vdev_stats->vdev_id = ev->vdev_id;
16790 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
16791 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
16792
16793 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
16794 sizeof(ev->tx_frm_cnt));
16795 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
16796 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
16797 ev->multiple_retry_cnt,
16798 sizeof(ev->multiple_retry_cnt));
16799 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
16800 sizeof(ev->fail_cnt));
16801 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
16802 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
16803 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
16804 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
16805 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
16806 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
16807 sizeof(ev->tx_rate_history));
16808 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
16809 sizeof(ev->bcn_rssi_history));
16810
16811 }
16812
16813 return QDF_STATUS_SUCCESS;
16814}
16815
16816/**
16817 * extract_peer_stats_tlv() - extract peer stats from event
16818 * @wmi_handle: wmi handle
16819 * @param evt_buf: pointer to event buffer
16820 * @param index: Index into peer stats
16821 * @param peer_stats: Pointer to hold peer stats
16822 *
16823 * Return: QDF_STATUS_SUCCESS for success or error code
16824 */
16825static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
16826 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
16827{
16828 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16829 wmi_stats_event_fixed_param *ev_param;
16830 uint8_t *data;
16831
16832 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16833 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16834 data = (uint8_t *) param_buf->data;
16835
16836 if (index < ev_param->num_peer_stats) {
16837 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
16838 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16839 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16840 (index * sizeof(wmi_peer_stats)));
16841
16842 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
16843
16844 OS_MEMCPY(&(peer_stats->peer_macaddr),
16845 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
16846
16847 peer_stats->peer_rssi = ev->peer_rssi;
16848 peer_stats->peer_tx_rate = ev->peer_tx_rate;
16849 peer_stats->peer_rx_rate = ev->peer_rx_rate;
16850 }
16851
16852 return QDF_STATUS_SUCCESS;
16853}
16854
16855/**
16856 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
16857 * @wmi_handle: wmi handle
16858 * @param evt_buf: pointer to event buffer
16859 * @param index: Index into bcn fault stats
16860 * @param bcnflt_stats: Pointer to hold bcn fault stats
16861 *
16862 * Return: QDF_STATUS_SUCCESS for success or error code
16863 */
16864static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
16865 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
16866{
16867 return QDF_STATUS_SUCCESS;
16868}
16869
16870/**
16871 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
16872 * @wmi_handle: wmi handle
16873 * @param evt_buf: pointer to event buffer
16874 * @param index: Index into extended peer stats
16875 * @param peer_extd_stats: Pointer to hold extended peer stats
16876 *
16877 * Return: QDF_STATUS_SUCCESS for success or error code
16878 */
16879static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
16880 void *evt_buf, uint32_t index,
16881 wmi_host_peer_extd_stats *peer_extd_stats)
16882{
16883 return QDF_STATUS_SUCCESS;
16884}
16885
16886/**
16887 * extract_chan_stats_tlv() - extract chan stats from event
16888 * @wmi_handle: wmi handle
16889 * @param evt_buf: pointer to event buffer
16890 * @param index: Index into chan stats
16891 * @param vdev_extd_stats: Pointer to hold chan stats
16892 *
16893 * Return: QDF_STATUS_SUCCESS for success or error code
16894 */
16895static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
16896 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
16897{
16898 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16899 wmi_stats_event_fixed_param *ev_param;
16900 uint8_t *data;
16901
16902 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16903 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16904 data = (uint8_t *) param_buf->data;
16905
16906 if (index < ev_param->num_chan_stats) {
16907 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
16908 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16909 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16910 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
16911 (index * sizeof(wmi_chan_stats)));
16912
16913
16914 /* Non-TLV doesnt have num_chan_stats */
16915 chan_stats->chan_mhz = ev->chan_mhz;
16916 chan_stats->sampling_period_us = ev->sampling_period_us;
16917 chan_stats->rx_clear_count = ev->rx_clear_count;
16918 chan_stats->tx_duration_us = ev->tx_duration_us;
16919 chan_stats->rx_duration_us = ev->rx_duration_us;
16920 }
16921
16922 return QDF_STATUS_SUCCESS;
16923}
16924
16925/**
16926 * extract_profile_ctx_tlv() - extract profile context from event
16927 * @wmi_handle: wmi handle
16928 * @param evt_buf: pointer to event buffer
16929 * @idx: profile stats index to extract
16930 * @param profile_ctx: Pointer to hold profile context
16931 *
16932 * Return: QDF_STATUS_SUCCESS for success or error code
16933 */
16934static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
16935 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
16936{
16937 return QDF_STATUS_SUCCESS;
16938}
16939
16940/**
16941 * extract_profile_data_tlv() - extract profile data from event
16942 * @wmi_handle: wmi handle
16943 * @param evt_buf: pointer to event buffer
16944 * @param profile_data: Pointer to hold profile data
16945 *
16946 * Return: QDF_STATUS_SUCCESS for success or error code
16947 */
16948static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
16949 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
16950{
16951
16952 return QDF_STATUS_SUCCESS;
16953}
16954
16955/**
16956 * extract_chan_info_event_tlv() - extract chan information from event
16957 * @wmi_handle: wmi handle
16958 * @param evt_buf: pointer to event buffer
16959 * @param chan_info: Pointer to hold chan information
16960 *
16961 * Return: QDF_STATUS_SUCCESS for success or error code
16962 */
16963static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
16964 void *evt_buf, wmi_host_chan_info_event *chan_info)
16965{
16966 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
16967 wmi_chan_info_event_fixed_param *ev;
16968
16969 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
16970
16971 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
16972 if (!ev) {
16973 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
16974 return QDF_STATUS_E_FAILURE;
16975 }
16976
16977 chan_info->err_code = ev->err_code;
16978 chan_info->freq = ev->freq;
16979 chan_info->cmd_flags = ev->cmd_flags;
16980 chan_info->noise_floor = ev->noise_floor;
16981 chan_info->rx_clear_count = ev->rx_clear_count;
16982 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053016983 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
16984 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
16985 ev->vdev_id, WLAN_SCAN_ID);
Govind Singhe7f2f342016-05-23 12:12:52 +053016986
16987 return QDF_STATUS_SUCCESS;
16988}
16989
16990/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016991 * extract_pdev_utf_event_tlv() - extract UTF data info from event
16992 * @wmi_handle: WMI handle
16993 * @param evt_buf: Pointer to event buffer
16994 * @param param: Pointer to hold data
16995 *
16996 * Return : QDF_STATUS_SUCCESS for success or error code
16997 */
16998static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16999 uint8_t *evt_buf,
17000 struct wmi_host_pdev_utf_event *event)
17001{
17002 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017003 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017004
17005 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
17006 event->data = param_buf->data;
17007 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017008 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053017009 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017010 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053017011 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017012
17013 return QDF_STATUS_SUCCESS;
17014}
Govind Singhe7f2f342016-05-23 12:12:52 +053017015
Kiran Venkatappa06520822016-08-10 23:55:40 +053017016/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017017 * extract_chainmask_tables_tlv() - extract chain mask tables from event
17018 * @wmi_handle: wmi handle
17019 * @param evt_buf: pointer to event buffer
17020 * @param param: Pointer to hold evt buf
17021 *
17022 * Return: QDF_STATUS_SUCCESS for success or error code
17023 */
17024static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
17025 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
17026{
17027 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17028 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
17029 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17030 uint8_t i = 0, j = 0;
17031
17032 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17033 if (!param_buf)
17034 return QDF_STATUS_E_INVAL;
17035
17036 hw_caps = param_buf->soc_hw_mode_caps;
17037 if (!hw_caps)
17038 return QDF_STATUS_E_INVAL;
17039
17040 if (!hw_caps->num_chainmask_tables)
17041 return QDF_STATUS_E_INVAL;
17042
17043 chainmask_caps = param_buf->mac_phy_chainmask_caps;
17044
17045 if (chainmask_caps == NULL)
17046 return QDF_STATUS_E_INVAL;
17047
17048 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
17049
17050 qdf_print("Dumping chain mask combo data for table : %d\n", i);
17051 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
17052
17053 chainmask_table[i].cap_list[j].chainmask =
17054 chainmask_caps->chainmask;
17055
17056 chainmask_table[i].cap_list[j].supports_chan_width_20 =
17057 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
17058
17059 chainmask_table[i].cap_list[j].supports_chan_width_40 =
17060 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
17061
17062 chainmask_table[i].cap_list[j].supports_chan_width_80 =
17063 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
17064
17065 chainmask_table[i].cap_list[j].supports_chan_width_160 =
17066 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
17067
17068 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
17069 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
17070
17071 chainmask_table[i].cap_list[j].chain_mask_2G =
17072 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
17073
17074 chainmask_table[i].cap_list[j].chain_mask_5G =
17075 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
17076
17077 chainmask_table[i].cap_list[j].chain_mask_tx =
17078 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
17079
17080 chainmask_table[i].cap_list[j].chain_mask_rx =
17081 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
17082
17083 chainmask_table[i].cap_list[j].supports_aDFS =
17084 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
17085
17086 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
17087 chainmask_caps->supported_flags,
17088 chainmask_caps->chainmask
17089 );
17090 chainmask_caps++;
17091 }
17092 }
17093
17094 return QDF_STATUS_SUCCESS;
17095}
17096
17097/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053017098 * extract_service_ready_ext_tlv() - extract basic extended service ready params
17099 * from event
17100 * @wmi_handle: wmi handle
17101 * @param evt_buf: pointer to event buffer
17102 * @param param: Pointer to hold evt buf
17103 *
17104 * Return: QDF_STATUS_SUCCESS for success or error code
17105 */
17106static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017107 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017108{
17109 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17110 wmi_service_ready_ext_event_fixed_param *ev;
17111 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17112 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017113 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
17114 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017115
17116 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17117 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017118 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017119
17120 ev = param_buf->fixed_param;
17121 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017122 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017123
17124 /* Move this to host based bitmap */
17125 param->default_conc_scan_config_bits =
17126 ev->default_conc_scan_config_bits;
17127 param->default_fw_config_bits = ev->default_fw_config_bits;
17128 param->he_cap_info = ev->he_cap_info;
17129 param->mpdu_density = ev->mpdu_density;
17130 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
17131 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
17132
17133 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017134 if (hw_caps)
17135 param->num_hw_modes = hw_caps->num_hw_modes;
17136 else
17137 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017138
17139 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017140 if (reg_caps)
17141 param->num_phy = reg_caps->num_phy;
17142 else
17143 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017144
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017145 if (hw_caps) {
17146 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
17147 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
17148 } else
17149 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017150
17151 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
17152
17153 if (chain_mask_combo == NULL)
17154 return QDF_STATUS_SUCCESS;
17155
17156 qdf_print("Dumping chain mask combo data\n");
17157
Kapil Gupta0692a1a2017-05-15 15:57:36 +053017158 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017159
17160 qdf_print("table_id : %d Num valid chainmasks: %d\n",
17161 chain_mask_combo->chainmask_table_id,
17162 chain_mask_combo->num_valid_chainmask
17163 );
17164
17165 param->chainmask_table[i].table_id =
17166 chain_mask_combo->chainmask_table_id;
17167 param->chainmask_table[i].num_valid_chainmasks =
17168 chain_mask_combo->num_valid_chainmask;
17169 chain_mask_combo++;
17170 }
17171 qdf_print("chain mask combo end\n");
17172
Kiran Venkatappa06520822016-08-10 23:55:40 +053017173 return QDF_STATUS_SUCCESS;
17174}
17175
17176/**
17177 * extract_hw_mode_cap_service_ready_ext_tlv() -
17178 * extract HW mode cap from service ready event
17179 * @wmi_handle: wmi handle
17180 * @param evt_buf: pointer to event buffer
17181 * @param param: Pointer to hold evt buf
17182 * @param hw_mode_idx: hw mode idx should be less than num_mode
17183 *
17184 * Return: QDF_STATUS_SUCCESS for success or error code
17185 */
17186static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
17187 wmi_unified_t wmi_handle,
17188 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017189 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017190{
17191 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17192 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17193
17194 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17195 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017196 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017197
17198 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017199 if (!hw_caps)
17200 return QDF_STATUS_E_INVAL;
17201
Kiran Venkatappa06520822016-08-10 23:55:40 +053017202 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017203 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017204
17205 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
17206 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
17207
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017208 param->hw_mode_config_type =
17209 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
17210
Kiran Venkatappa06520822016-08-10 23:55:40 +053017211 return QDF_STATUS_SUCCESS;
17212}
17213
17214/**
17215 * extract_mac_phy_cap_service_ready_ext_tlv() -
17216 * extract MAC phy cap from service ready event
17217 * @wmi_handle: wmi handle
17218 * @param evt_buf: pointer to event buffer
17219 * @param param: Pointer to hold evt buf
17220 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017221 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053017222 *
17223 * Return: QDF_STATUS_SUCCESS for success or error code
17224 */
17225static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
17226 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017227 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017228 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017229{
17230 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017231 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017232 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
17233 uint32_t phy_map;
17234 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017235
17236 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17237 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017238 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017239
17240 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017241 if (!hw_caps)
17242 return QDF_STATUS_E_INVAL;
17243
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017244 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
17245 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
17246 break;
17247
17248 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
17249 while (phy_map) {
17250 phy_map >>= 1;
17251 phy_idx++;
17252 }
17253 }
17254
17255 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017256 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017257
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017258 phy_idx += phy_id;
17259 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017260 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017261
17262 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053017263
17264 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017265 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17266 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017267 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053017268 param->supports_11b =
17269 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
17270 param->supports_11g =
17271 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
17272 param->supports_11a =
17273 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
17274 param->supports_11n =
17275 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
17276 param->supports_11ac =
17277 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
17278 param->supports_11ax =
17279 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017280
17281 param->supported_bands = mac_phy_caps->supported_bands;
17282 param->ampdu_density = mac_phy_caps->ampdu_density;
17283 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
17284 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
17285 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
17286 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
17287 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
17288 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
17289 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
17290 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
17291 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
17292 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
17293 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
17294 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
17295 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
17296 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
17297 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
17298 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080017299 qdf_mem_copy(&param->he_cap_phy_info_2G,
17300 &mac_phy_caps->he_cap_phy_info_2G,
17301 sizeof(param->he_cap_phy_info_2G));
17302 qdf_mem_copy(&param->he_cap_phy_info_5G,
17303 &mac_phy_caps->he_cap_phy_info_5G,
17304 sizeof(param->he_cap_phy_info_5G));
17305 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
17306 sizeof(param->he_ppet2G));
17307 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
17308 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017309 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017310
17311 return QDF_STATUS_SUCCESS;
17312}
17313
17314/**
17315 * extract_reg_cap_service_ready_ext_tlv() -
17316 * extract REG cap from service ready event
17317 * @wmi_handle: wmi handle
17318 * @param evt_buf: pointer to event buffer
17319 * @param param: Pointer to hold evt buf
17320 * @param phy_idx: phy idx should be less than num_mode
17321 *
17322 * Return: QDF_STATUS_SUCCESS for success or error code
17323 */
17324static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
17325 wmi_unified_t wmi_handle,
17326 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017327 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053017328{
17329 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
17330 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
17331 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
17332
17333 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
17334 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017335 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017336
17337 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017338 if (!reg_caps)
17339 return QDF_STATUS_E_INVAL;
17340
Kiran Venkatappa06520822016-08-10 23:55:40 +053017341 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017342 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053017343
17344 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
17345
17346 param->phy_id = ext_reg_cap->phy_id;
17347 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
17348 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
17349 param->regcap1 = ext_reg_cap->regcap1;
17350 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017351 param->wireless_modes = convert_wireless_modes_tlv(
17352 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053017353 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
17354 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
17355 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
17356 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
17357
17358 return QDF_STATUS_SUCCESS;
17359}
17360
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017361/**
17362 * extract_dcs_interference_type_tlv() - extract dcs interference type
17363 * from event
17364 * @wmi_handle: wmi handle
17365 * @param evt_buf: pointer to event buffer
17366 * @param param: Pointer to hold dcs interference param
17367 *
17368 * Return: 0 for success or error code
17369 */
17370static QDF_STATUS extract_dcs_interference_type_tlv(
17371 wmi_unified_t wmi_handle,
17372 void *evt_buf, struct wmi_host_dcs_interference_param *param)
17373{
17374 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17375
17376 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17377 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017378 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017379
17380 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017381 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17382 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017383
17384 return QDF_STATUS_SUCCESS;
17385}
17386
17387/*
17388 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
17389 * @wmi_handle: wmi handle
17390 * @param evt_buf: pointer to event buffer
17391 * @param cw_int: Pointer to hold cw interference
17392 *
17393 * Return: 0 for success or error code
17394 */
17395static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
17396 void *evt_buf,
17397 wmi_host_ath_dcs_cw_int *cw_int)
17398{
17399 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17400 wlan_dcs_cw_int *ev;
17401
17402 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17403 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017404 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017405
17406 ev = param_buf->cw_int;
17407
17408 cw_int->channel = ev->channel;
17409
17410 return QDF_STATUS_SUCCESS;
17411}
17412
17413/**
17414 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
17415 * @wmi_handle: wmi handle
17416 * @param evt_buf: pointer to event buffer
17417 * @param wlan_stat: Pointer to hold wlan stats
17418 *
17419 * Return: 0 for success or error code
17420 */
17421static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
17422 void *evt_buf,
17423 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
17424{
17425 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
17426 wlan_dcs_im_tgt_stats_t *ev;
17427
17428 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
17429 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053017430 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017431
17432 ev = param_buf->wlan_stat;
17433 wlan_stat->reg_tsf32 = ev->reg_tsf32;
17434 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
17435 wlan_stat->tx_waste_time = ev->tx_waste_time;
17436 wlan_stat->rx_time = ev->rx_time;
17437 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
17438 wlan_stat->mib_stats.listen_time = ev->listen_time;
17439 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
17440 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
17441 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
17442 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
17443 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
17444 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
17445 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
17446 wlan_stat->chan_nf = ev->chan_nf;
17447 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
17448
17449 return QDF_STATUS_SUCCESS;
17450}
17451
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017452/**
17453 * extract_thermal_stats_tlv() - extract thermal stats from event
17454 * @wmi_handle: wmi handle
17455 * @param evt_buf: Pointer to event buffer
17456 * @param temp: Pointer to hold extracted temperature
17457 * @param level: Pointer to hold extracted level
17458 *
17459 * Return: 0 for success or error code
17460 */
17461static QDF_STATUS
17462extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
17463 void *evt_buf, uint32_t *temp,
17464 uint32_t *level, uint32_t *pdev_id)
17465{
17466 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17467 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
17468
17469 param_buf =
17470 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17471 if (!param_buf)
17472 return QDF_STATUS_E_INVAL;
17473
17474 tt_stats_event = param_buf->fixed_param;
17475
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017476 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17477 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017478 *temp = tt_stats_event->temp;
17479 *level = tt_stats_event->level;
17480
17481 return QDF_STATUS_SUCCESS;
17482}
17483
17484/**
17485 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
17486 * @wmi_handle: wmi handle
17487 * @param evt_buf: pointer to event buffer
17488 * @param idx: Index to level stats
17489 * @param levelcount: Pointer to hold levelcount
17490 * @param dccount: Pointer to hold dccount
17491 *
17492 * Return: 0 for success or error code
17493 */
17494static QDF_STATUS
17495extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
17496 void *evt_buf, uint8_t idx, uint32_t *levelcount,
17497 uint32_t *dccount)
17498{
17499 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
17500 wmi_therm_throt_level_stats_info *tt_level_info;
17501
17502 param_buf =
17503 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
17504 if (!param_buf)
17505 return QDF_STATUS_E_INVAL;
17506
17507 tt_level_info = param_buf->therm_throt_level_stats_info;
17508
17509 if (idx < THERMAL_LEVELS) {
17510 *levelcount = tt_level_info[idx].level_count;
17511 *dccount = tt_level_info[idx].dc_count;
17512 return QDF_STATUS_SUCCESS;
17513 }
17514
17515 return QDF_STATUS_E_FAILURE;
17516}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017517#ifdef BIG_ENDIAN_HOST
17518/**
17519 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
17520 * @param data_len - data length
17521 * @param data - pointer to data
17522 *
17523 * Return: QDF_STATUS - success or error status
17524 */
17525static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17526{
17527 uint8_t *data_aligned = NULL;
17528 int c;
17529 unsigned char *data_unaligned;
17530
17531 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
17532 FIPS_ALIGN));
17533 /* Assigning unaligned space to copy the data */
17534 /* Checking if kmalloc does succesful allocation */
17535 if (data_unaligned == NULL)
17536 return QDF_STATUS_E_FAILURE;
17537
17538 /* Checking if space is alligned */
17539 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
17540 /* align the data space */
17541 data_aligned =
17542 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
17543 } else {
17544 data_aligned = (u_int8_t *)data_unaligned;
17545 }
17546
17547 /* memset and copy content from data to data aligned */
17548 OS_MEMSET(data_aligned, 0, data_len);
17549 OS_MEMCPY(data_aligned, data, data_len);
17550 /* Endianness to LE */
17551 for (c = 0; c < data_len/4; c++) {
17552 *((u_int32_t *)data_aligned + c) =
17553 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
17554 }
17555
17556 /* Copy content to event->data */
17557 OS_MEMCPY(data, data_aligned, data_len);
17558
17559 /* clean up allocated space */
17560 qdf_mem_free(data_unaligned);
17561 data_aligned = NULL;
17562 data_unaligned = NULL;
17563
17564 /*************************************************************/
17565
17566 return QDF_STATUS_SUCCESS;
17567}
17568#else
17569/**
17570 * fips_conv_data_be() - DUMMY for LE platform
17571 *
17572 * Return: QDF_STATUS - success
17573 */
17574static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
17575{
17576 return QDF_STATUS_SUCCESS;
17577}
17578#endif
17579
17580/**
17581 * extract_fips_event_data_tlv() - extract fips event data
17582 * @wmi_handle: wmi handle
17583 * @param evt_buf: pointer to event buffer
17584 * @param param: pointer FIPS event params
17585 *
17586 * Return: 0 for success or error code
17587 */
17588static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
17589 void *evt_buf, struct wmi_host_fips_event_param *param)
17590{
17591 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
17592 wmi_pdev_fips_event_fixed_param *event;
17593
17594 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
17595 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
17596
17597 if (fips_conv_data_be(event->data_len, param_buf->data) !=
17598 QDF_STATUS_SUCCESS)
17599 return QDF_STATUS_E_FAILURE;
17600
17601 param->data = (uint32_t *)param_buf->data;
17602 param->data_len = event->data_len;
17603 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017604 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17605 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017606
17607 return QDF_STATUS_SUCCESS;
17608}
17609
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017610/*
17611 * extract_peer_delete_response_event_tlv() - extract peer delete response event
17612 * @wmi_handle: wmi handle
17613 * @param evt_buf: pointer to event buffer
17614 * @param vdev_id: Pointer to hold vdev_id
17615 * @param mac_addr: Pointer to hold peer mac address
17616 *
17617 * Return: QDF_STATUS_SUCCESS for success or error code
17618 */
17619static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
17620 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
17621{
17622 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17623 wmi_peer_delete_resp_event_fixed_param *ev;
17624
17625 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
17626
17627 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17628 if (!ev) {
17629 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17630 return QDF_STATUS_E_FAILURE;
17631 }
17632
17633 param->vdev_id = ev->vdev_id;
17634 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17635 &param->mac_address.bytes[0]);
17636
17637 return QDF_STATUS_SUCCESS;
17638}
17639
Govind Singhecf03cd2016-05-12 12:45:51 +053017640static bool is_management_record_tlv(uint32_t cmd_id)
17641{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017642 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017643 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017644
Govind Singhecf03cd2016-05-12 12:45:51 +053017645 return false;
17646}
17647
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017648static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17649{
17650 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17651
17652 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17653
17654 switch (set_cmd->param_id) {
17655 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17656 case WMI_VDEV_PARAM_DTIM_POLICY:
17657 return HTC_TX_PACKET_TAG_AUTO_PM;
17658 default:
17659 break;
17660 }
17661
17662 return 0;
17663}
17664
17665static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17666{
17667 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17668
17669 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17670
17671 switch (ps_cmd->param) {
17672 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17673 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17674 case WMI_STA_PS_ENABLE_QPOWER:
17675 return HTC_TX_PACKET_TAG_AUTO_PM;
17676 default:
17677 break;
17678 }
17679
17680 return 0;
17681}
17682
17683static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17684 uint32_t cmd_id)
17685{
17686 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17687 return 0;
17688
17689 switch (cmd_id) {
17690 case WMI_VDEV_SET_PARAM_CMDID:
17691 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17692 case WMI_STA_POWERSAVE_PARAM_CMDID:
17693 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17694 default:
17695 break;
17696 }
17697
17698 return 0;
17699}
17700
17701static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17702{
17703 uint16_t tag = 0;
17704
17705 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17706 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17707 __func__);
17708 return tag;
17709 }
17710
17711 if (wmi_handle->tag_crash_inject)
17712 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17713
17714 wmi_handle->tag_crash_inject = false;
17715 return tag;
17716}
17717
17718/**
17719 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17720 * @wmi_handle: WMI handle
17721 * @buf: WMI buffer
17722 * @cmd_id: WMI command Id
17723 *
17724 * Return htc_tx_tag
17725 */
17726static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17727 wmi_buf_t buf,
17728 uint32_t cmd_id)
17729{
17730 uint16_t htc_tx_tag = 0;
17731
17732 switch (cmd_id) {
17733 case WMI_WOW_ENABLE_CMDID:
17734 case WMI_PDEV_SUSPEND_CMDID:
17735 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
17736 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
17737 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
17738 case WMI_PDEV_RESUME_CMDID:
17739 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
17740 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
17741#ifdef FEATURE_WLAN_D0WOW
17742 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
17743#endif
17744 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
17745 break;
17746 case WMI_FORCE_FW_HANG_CMDID:
17747 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
17748 break;
17749 case WMI_VDEV_SET_PARAM_CMDID:
17750 case WMI_STA_POWERSAVE_PARAM_CMDID:
17751 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
17752 default:
17753 break;
17754 }
17755
17756 return htc_tx_tag;
17757}
17758
Sathish Kumard3ab1002017-02-07 17:10:59 +053017759/**
17760 * extract_channel_hopping_event_tlv() - extract channel hopping param
17761 * from event
17762 * @wmi_handle: wmi handle
17763 * @param evt_buf: pointer to event buffer
17764 * @param ch_hopping: Pointer to hold channel hopping param
17765 *
17766 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17767 */
17768static QDF_STATUS extract_channel_hopping_event_tlv(
17769 wmi_unified_t wmi_handle, void *evt_buf,
17770 wmi_host_pdev_channel_hopping_event *ch_hopping)
17771{
17772 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
17773 wmi_pdev_channel_hopping_event_fixed_param *event;
17774
17775 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
17776 event = (wmi_pdev_channel_hopping_event_fixed_param *)
17777 param_buf->fixed_param;
17778
17779 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
17780 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017781 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17782 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017783
17784 return QDF_STATUS_SUCCESS;
17785}
17786
17787/**
17788 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
17789 * @wmi_handle: wmi handle
17790 * @param evt_buf: pointer to event buffer
17791 * @param param: Pointer to hold tpc param
17792 *
17793 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17794 */
17795static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
17796 void *evt_buf,
17797 wmi_host_pdev_tpc_event *param)
17798{
17799 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
17800 wmi_pdev_tpc_event_fixed_param *event;
17801
17802 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
17803 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
17804
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017805 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17806 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017807 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
17808
17809 return QDF_STATUS_SUCCESS;
17810}
17811
17812
17813#ifdef BIG_ENDIAN_HOST
17814/**
17815 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
17816 * @param data_len - data length
17817 * @param data - pointer to data
17818 *
17819 * Return: QDF_STATUS - success or error status
17820 */
17821static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
17822{
17823 uint8_t *datap = (uint8_t *)ev;
17824 /* Skip swapping the first word */
17825 datap += sizeof(uint32_t);
17826 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
17827 i++, datap += sizeof(uint32_t)) {
17828 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
17829 }
17830
17831 return QDF_STATUS_SUCCESS;
17832}
17833#else
17834/**
17835 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
17836 * @param data_len - data length
17837 * @param data - pointer to data
17838 *
17839 * Return: QDF_STATUS - success or error status
17840 */
17841static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
17842{
17843 return QDF_STATUS_SUCCESS;
17844}
17845#endif
17846
17847/**
17848 * extract_wds_addr_event_tlv() - extract wds address from event
17849 * @wmi_handle: wmi handle
17850 * @param evt_buf: pointer to event buffer
17851 * @param wds_ev: Pointer to hold wds address
17852 *
17853 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17854 */
17855static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
17856 void *evt_buf,
17857 uint16_t len, wds_addr_event_t *wds_ev)
17858{
17859 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
17860 wmi_wds_addr_event_fixed_param *ev;
17861 int i;
17862
17863 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
17864 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
17865
17866 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
17867 return QDF_STATUS_E_FAILURE;
17868
17869 qdf_mem_copy(wds_ev->event_type, ev->event_type,
17870 sizeof(wds_ev->event_type));
17871 for (i = 0; i < 4; i++) {
17872 wds_ev->peer_mac[i] =
17873 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
17874 wds_ev->dest_mac[i] =
17875 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
17876 }
17877 for (i = 0; i < 2; i++) {
17878 wds_ev->peer_mac[4+i] =
17879 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
17880 wds_ev->dest_mac[4+i] =
17881 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
17882 }
17883 return QDF_STATUS_SUCCESS;
17884}
17885
17886/**
17887 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
17888 * from event
17889 * @wmi_handle: wmi handle
17890 * @param evt_buf: pointer to event buffer
17891 * @param ev: Pointer to hold peer param and ps state
17892 *
17893 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17894 */
17895static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
17896 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
17897{
17898 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
17899 wmi_peer_sta_ps_statechange_event_fixed_param *event;
17900
17901 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
17902 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
17903 param_buf->fixed_param;
17904
17905 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
17906 ev->peer_ps_state = event->peer_ps_state;
17907
17908 return QDF_STATUS_SUCCESS;
17909}
17910
17911/**
17912 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
17913 * @wmi_handle: wmi handle
17914 * @param evt_buf: pointer to event buffer
17915 * @param inst_rssi_resp: Pointer to hold inst rssi response
17916 *
17917 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17918 */
17919static QDF_STATUS extract_inst_rssi_stats_event_tlv(
17920 wmi_unified_t wmi_handle, void *evt_buf,
17921 wmi_host_inst_stats_resp *inst_rssi_resp)
17922{
17923 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
17924 wmi_inst_rssi_stats_resp_fixed_param *event;
17925
17926 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
17927 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
17928
17929 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
17930 &(event->peer_macaddr), sizeof(wmi_mac_addr));
17931 inst_rssi_resp->iRSSI = event->iRSSI;
17932
17933 return QDF_STATUS_SUCCESS;
17934}
17935
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017936static struct cur_reg_rule
17937*create_reg_rules_from_wmi(uint32_t num_reg_rules,
17938 wmi_regulatory_rule_struct *wmi_reg_rule)
17939{
17940 struct cur_reg_rule *reg_rule_ptr;
17941 uint32_t count;
17942
17943 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
17944
17945 if (NULL == reg_rule_ptr) {
17946 WMI_LOGE("memory allocation failure");
17947 return NULL;
17948 }
17949
17950 for (count = 0; count < num_reg_rules; count++) {
17951 reg_rule_ptr[count].start_freq =
17952 WMI_REG_RULE_START_FREQ_GET(
17953 wmi_reg_rule[count].freq_info);
17954 reg_rule_ptr[count].end_freq =
17955 WMI_REG_RULE_END_FREQ_GET(
17956 wmi_reg_rule[count].freq_info);
17957 reg_rule_ptr[count].max_bw =
17958 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017959 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017960 reg_rule_ptr[count].reg_power =
17961 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017962 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053017963 reg_rule_ptr[count].ant_gain =
17964 WMI_REG_RULE_ANTENNA_GAIN_GET(
17965 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017966 reg_rule_ptr[count].flags =
17967 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017968 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017969 }
17970
17971 return reg_rule_ptr;
17972}
17973
17974static QDF_STATUS extract_reg_chan_list_update_event_tlv(
17975 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17976 struct cur_regulatory_info *reg_info, uint32_t len)
17977{
17978 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
17979 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
17980 wmi_regulatory_rule_struct *wmi_reg_rule;
17981 uint32_t num_2g_reg_rules, num_5g_reg_rules;
17982
17983 WMI_LOGD("processing regulatory channel list");
17984
17985 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
17986 if (!param_buf) {
17987 WMI_LOGE("invalid channel list event buf");
17988 return QDF_STATUS_E_FAILURE;
17989 }
17990
17991 chan_list_event_hdr = param_buf->fixed_param;
17992
17993 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
17994 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
17995 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053017996 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017997 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
17998 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070017999 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070018000 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053018001 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070018002 reg_info->ctry_code = chan_list_event_hdr->country_id;
18003 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
18004 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
18005 reg_info->status_code = REG_SET_CC_STATUS_PASS;
18006 else if (chan_list_event_hdr->status_code ==
18007 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
18008 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
18009 else if (chan_list_event_hdr->status_code ==
18010 WMI_REG_INIT_ALPHA2_NOT_FOUND)
18011 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
18012 else if (chan_list_event_hdr->status_code ==
18013 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
18014 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
18015 else if (chan_list_event_hdr->status_code ==
18016 WMI_REG_SET_CC_STATUS_NO_MEMORY)
18017 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
18018 else if (chan_list_event_hdr->status_code ==
18019 WMI_REG_SET_CC_STATUS_FAIL)
18020 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
18021
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018022 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
18023 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
18024 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
18025 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
18026
18027 num_2g_reg_rules = reg_info->num_2g_reg_rules;
18028 num_5g_reg_rules = reg_info->num_5g_reg_rules;
18029
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018030 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
18031 __func__, reg_info->alpha2, reg_info->dfs_region,
18032 reg_info->min_bw_2g, reg_info->max_bw_2g,
18033 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018034
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018035 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
18036 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070018037 wmi_reg_rule =
18038 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
18039 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
18040 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018041 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
18042 wmi_reg_rule);
18043 wmi_reg_rule += num_2g_reg_rules;
18044
18045 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
18046 wmi_reg_rule);
18047
18048 WMI_LOGD("processed regulatory channel list");
18049
18050 return QDF_STATUS_SUCCESS;
18051}
18052
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018053static QDF_STATUS extract_reg_11d_new_country_event_tlv(
18054 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18055 struct reg_11d_new_country *reg_11d_country, uint32_t len)
18056{
18057 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
18058 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
18059
18060 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
18061 if (!param_buf) {
18062 WMI_LOGE("invalid 11d country event buf");
18063 return QDF_STATUS_E_FAILURE;
18064 }
18065
18066 reg_11d_country_event = param_buf->fixed_param;
18067
18068 qdf_mem_copy(reg_11d_country->alpha2,
18069 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
18070
18071 WMI_LOGD("processed 11d country event, new cc %s",
18072 reg_11d_country->alpha2);
18073
18074 return QDF_STATUS_SUCCESS;
18075}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070018076
18077static QDF_STATUS extract_reg_ch_avoid_event_tlv(
18078 wmi_unified_t wmi_handle, uint8_t *evt_buf,
18079 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
18080{
18081 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
18082 wmi_avoid_freq_range_desc *afr_desc;
18083 uint32_t num_freq_ranges, freq_range_idx;
18084 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
18085 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
18086
18087 if (!param_buf) {
18088 WMI_LOGE("Invalid channel avoid event buffer");
18089 return QDF_STATUS_E_INVAL;
18090 }
18091
18092 afr_fixed_param = param_buf->fixed_param;
18093 if (!afr_fixed_param) {
18094 WMI_LOGE("Invalid channel avoid event fixed param buffer");
18095 return QDF_STATUS_E_INVAL;
18096 }
18097
18098 if (!ch_avoid_ind) {
18099 WMI_LOGE("Invalid channel avoid indication buffer");
18100 return QDF_STATUS_E_INVAL;
18101 }
18102 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
18103 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
18104 afr_fixed_param->num_freq_ranges;
18105
18106 WMI_LOGD("Channel avoid event received with %d ranges",
18107 num_freq_ranges);
18108
18109 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
18110 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
18111 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
18112 freq_range_idx++) {
18113 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
18114 afr_desc->start_freq;
18115 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
18116 afr_desc->end_freq;
18117 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
18118 freq_range_idx, afr_desc->tlv_header,
18119 afr_desc->start_freq, afr_desc->end_freq);
18120 afr_desc++;
18121 }
18122
18123 return QDF_STATUS_SUCCESS;
18124}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018125#ifdef DFS_COMPONENT_ENABLE
18126/**
18127 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
18128 * @wmi_handle: wma handle
18129 * @evt_buf: event buffer
18130 * @vdev_id: vdev id
18131 * @len: length of buffer
18132 *
18133 * Return: 0 for success or error code
18134 */
18135static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
18136 uint8_t *evt_buf,
18137 uint32_t *vdev_id,
18138 uint32_t len)
18139{
18140 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
18141 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
18142
18143 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
18144 if (!param_tlvs) {
18145 WMI_LOGE("invalid cac complete event buf");
18146 return QDF_STATUS_E_FAILURE;
18147 }
18148
18149 cac_event = param_tlvs->fixed_param;
18150 *vdev_id = cac_event->vdev_id;
18151 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
18152
18153 return QDF_STATUS_SUCCESS;
18154}
18155
18156/**
18157 * extract_dfs_radar_detection_event_tlv() - extract radar found event
18158 * @wmi_handle: wma handle
18159 * @evt_buf: event buffer
18160 * @radar_found: radar found event info
18161 * @len: length of buffer
18162 *
18163 * Return: 0 for success or error code
18164 */
18165static QDF_STATUS extract_dfs_radar_detection_event_tlv(
18166 wmi_unified_t wmi_handle,
18167 uint8_t *evt_buf,
18168 struct radar_found_info *radar_found,
18169 uint32_t len)
18170{
18171 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
18172 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
18173
18174 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
18175 if (!param_tlv) {
18176 WMI_LOGE("invalid radar detection event buf");
18177 return QDF_STATUS_E_FAILURE;
18178 }
18179
18180 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018181 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18182 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018183 radar_found->detection_mode = radar_event->detection_mode;
18184 radar_found->freq_offset = radar_event->chan_freq;
18185 radar_found->chan_width = radar_event->chan_width;
18186 radar_found->detector_id = radar_event->detector_id;
18187 radar_found->segment_id = radar_event->segment_id;
18188 radar_found->timestamp = radar_event->timestamp;
18189 radar_found->is_chirp = radar_event->is_chirp;
18190
18191 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
18192
18193 return QDF_STATUS_SUCCESS;
18194}
18195#endif
18196
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018197/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018198 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
18199 * host to target defines. For legacy there is not conversion
18200 * required. Just return pdev_id as it is.
18201 * @param pdev_id: host pdev_id to be converted.
18202 * Return: target pdev_id after conversion.
18203 */
18204static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
18205 uint32_t pdev_id)
18206{
18207 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
18208 return WMI_PDEV_ID_SOC;
18209
18210 /*No conversion required*/
18211 return pdev_id;
18212}
18213
18214/**
18215 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
18216 * target to host defines. For legacy there is not conversion
18217 * required. Just return pdev_id as it is.
18218 * @param pdev_id: target pdev_id to be converted.
18219 * Return: host pdev_id after conversion.
18220 */
18221static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
18222 uint32_t pdev_id)
18223{
18224 /*No conversion required*/
18225 return pdev_id;
18226}
18227
18228/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018229 * send_set_country_cmd_tlv() - WMI scan channel list function
18230 * @param wmi_handle : handle to WMI.
18231 * @param param : pointer to hold scan channel list parameter
18232 *
18233 * Return: 0 on success and -ve on failure.
18234 */
18235static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
18236 struct set_country *params)
18237{
18238 wmi_buf_t buf;
18239 QDF_STATUS qdf_status;
18240 wmi_set_current_country_cmd_fixed_param *cmd;
18241 uint16_t len = sizeof(*cmd);
18242
18243 buf = wmi_buf_alloc(wmi_handle, len);
18244 if (!buf) {
18245 WMI_LOGE("Failed to allocate memory");
18246 qdf_status = QDF_STATUS_E_NOMEM;
18247 goto end;
18248 }
18249
18250 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
18251 WMITLV_SET_HDR(&cmd->tlv_header,
18252 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
18253 WMITLV_GET_STRUCT_TLVLEN
18254 (wmi_set_current_country_cmd_fixed_param));
18255
18256 WMI_LOGD("setting cuurnet country to %s", params->country);
18257
18258 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
18259
18260 cmd->pdev_id = params->pdev_id;
18261
18262 qdf_status = wmi_unified_cmd_send(wmi_handle,
18263 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
18264
18265 if (QDF_IS_STATUS_ERROR(qdf_status)) {
18266 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
18267 wmi_buf_free(buf);
18268 }
18269
18270end:
18271 return qdf_status;
18272}
18273
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018274#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
18275 WMI_SET_BITS(alpha, 0, 8, val0); \
18276 WMI_SET_BITS(alpha, 8, 8, val1); \
18277 WMI_SET_BITS(alpha, 16, 8, val2); \
18278 } while (0)
18279
18280static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
18281 uint8_t pdev_id, struct cc_regdmn_s *rd)
18282{
18283 wmi_set_init_country_cmd_fixed_param *cmd;
18284 uint16_t len;
18285 wmi_buf_t buf;
18286 int ret;
18287
18288 len = sizeof(wmi_set_init_country_cmd_fixed_param);
18289 buf = wmi_buf_alloc(wmi_handle, len);
18290 if (!buf) {
18291 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
18292 return QDF_STATUS_E_NOMEM;
18293 }
18294 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
18295 WMITLV_SET_HDR(&cmd->tlv_header,
18296 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
18297 WMITLV_GET_STRUCT_TLVLEN
18298 (wmi_set_init_country_cmd_fixed_param));
18299
18300 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
18301
18302 if (rd->flags == CC_IS_SET) {
18303 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
18304 cmd->country_code.country_id = rd->cc.country_code;
18305 } else if (rd->flags == ALPHA_IS_SET) {
18306 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
18307 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
18308 rd->cc.alpha[0],
18309 rd->cc.alpha[1],
18310 rd->cc.alpha[2]);
18311 } else if (rd->flags == REGDMN_IS_SET) {
18312 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
18313 cmd->country_code.domain_code = rd->cc.regdmn_id;
18314 }
18315
18316 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
18317 WMI_SET_INIT_COUNTRY_CMDID);
18318 if (ret) {
18319 WMI_LOGE("Failed to config wow wakeup event");
18320 wmi_buf_free(buf);
18321 return QDF_STATUS_E_FAILURE;
18322 }
18323
18324 return QDF_STATUS_SUCCESS;
18325}
18326
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053018327/**
18328 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
18329 * configuration params
18330 * @wmi_handle: wmi handler
18331 * @limit_off_chan_param: pointer to wmi_off_chan_param
18332 *
18333 * Return: 0 for success and non zero for failure
18334 */
18335static
18336QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
18337 struct wmi_limit_off_chan_param *limit_off_chan_param)
18338{
18339 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
18340 wmi_buf_t buf;
18341 uint32_t len = sizeof(*cmd);
18342 int err;
18343
18344 buf = wmi_buf_alloc(wmi_handle, len);
18345 if (!buf) {
18346 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
18347 __func__);
18348 return QDF_STATUS_E_NOMEM;
18349 }
18350
18351 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
18352
18353 WMITLV_SET_HDR(&cmd->tlv_header,
18354 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
18355 WMITLV_GET_STRUCT_TLVLEN(
18356 wmi_vdev_limit_offchan_cmd_fixed_param));
18357
18358 cmd->vdev_id = limit_off_chan_param->vdev_id;
18359
18360 cmd->flags &= 0;
18361 if (limit_off_chan_param->status)
18362 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
18363 if (limit_off_chan_param->skip_dfs_chans)
18364 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
18365
18366 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
18367 cmd->rest_time = limit_off_chan_param->rest_time;
18368
18369 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
18370 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
18371 cmd->rest_time);
18372
18373 err = wmi_unified_cmd_send(wmi_handle, buf,
18374 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
18375 if (QDF_IS_STATUS_ERROR(err)) {
18376 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
18377 wmi_buf_free(buf);
18378 return QDF_STATUS_E_FAILURE;
18379 }
18380
18381 return QDF_STATUS_SUCCESS;
18382}
18383
Govind Singh5eb51532016-03-09 11:34:12 +053018384struct wmi_ops tlv_ops = {
18385 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
18386 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
18387 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053018388 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
18389 .send_hidden_ssid_vdev_restart_cmd =
18390 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018391 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
18392 .send_peer_param_cmd = send_peer_param_cmd_tlv,
18393 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018394 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018395 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018396 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070018397 .send_peer_rx_reorder_queue_setup_cmd =
18398 send_peer_rx_reorder_queue_setup_cmd_tlv,
18399 .send_peer_rx_reorder_queue_remove_cmd =
18400 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053018401 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
18402 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
18403 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018404 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
18405 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
18406 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
18407 .send_suspend_cmd = send_suspend_cmd_tlv,
18408 .send_resume_cmd = send_resume_cmd_tlv,
18409 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
18410 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
18411 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
18412 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
18413 .send_dbglog_cmd = send_dbglog_cmd_tlv,
18414 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
18415 .send_stats_request_cmd = send_stats_request_cmd_tlv,
18416 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
18417 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018418 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018419 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
18420 .send_scan_start_cmd = send_scan_start_cmd_tlv,
18421 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
18422 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018423 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018424 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018425 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
18426 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018427 .send_set_sta_uapsd_auto_trig_cmd =
18428 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053018429 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
18430 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
18431 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018432#ifdef CONVERGED_P2P_ENABLE
18433 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
18434 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
18435#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053018436 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
18437 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053018438 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
18439 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
18440 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
18441 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
18442 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
18443 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
18444 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018445 .send_ocb_start_timing_advert_cmd =
18446 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053018447 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
18448 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
18449 .send_set_mcc_channel_time_latency_cmd =
18450 send_set_mcc_channel_time_latency_cmd_tlv,
18451 .send_set_mcc_channel_time_quota_cmd =
18452 send_set_mcc_channel_time_quota_cmd_tlv,
18453 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
18454 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053018455 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018456 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
18457 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
18458 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018459 .send_probe_rsp_tmpl_send_cmd =
18460 send_probe_rsp_tmpl_send_cmd_tlv,
18461 .send_p2p_go_set_beacon_ie_cmd =
18462 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053018463 .send_setup_install_key_cmd =
18464 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018465 .send_set_gateway_params_cmd =
18466 send_set_gateway_params_cmd_tlv,
18467 .send_set_rssi_monitoring_cmd =
18468 send_set_rssi_monitoring_cmd_tlv,
18469 .send_scan_probe_setoui_cmd =
18470 send_scan_probe_setoui_cmd_tlv,
18471 .send_reset_passpoint_network_list_cmd =
18472 send_reset_passpoint_network_list_cmd_tlv,
18473 .send_set_passpoint_network_list_cmd =
18474 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053018475 .send_roam_scan_offload_rssi_thresh_cmd =
18476 send_roam_scan_offload_rssi_thresh_cmd_tlv,
18477 .send_roam_scan_filter_cmd =
18478 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053018479 .send_set_epno_network_list_cmd =
18480 send_set_epno_network_list_cmd_tlv,
18481 .send_ipa_offload_control_cmd =
18482 send_ipa_offload_control_cmd_tlv,
18483 .send_extscan_get_capabilities_cmd =
18484 send_extscan_get_capabilities_cmd_tlv,
18485 .send_extscan_get_cached_results_cmd =
18486 send_extscan_get_cached_results_cmd_tlv,
18487 .send_extscan_stop_change_monitor_cmd =
18488 send_extscan_stop_change_monitor_cmd_tlv,
18489 .send_extscan_start_change_monitor_cmd =
18490 send_extscan_start_change_monitor_cmd_tlv,
18491 .send_extscan_stop_hotlist_monitor_cmd =
18492 send_extscan_stop_hotlist_monitor_cmd_tlv,
18493 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
18494 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
18495 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
18496 .send_plm_start_cmd = send_plm_start_cmd_tlv,
18497 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
18498 .send_pno_start_cmd = send_pno_start_cmd_tlv,
18499 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
18500 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
18501 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
18502 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
18503 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053018504 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018505 .send_snr_request_cmd = send_snr_request_cmd_tlv,
18506 .send_snr_cmd = send_snr_cmd_tlv,
18507 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018508#ifdef WLAN_PMO_ENABLE
18509 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
18510 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
18511 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
18512 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070018513 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018514 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
18515 .send_process_gtk_offload_getinfo_cmd =
18516 send_process_gtk_offload_getinfo_cmd_tlv,
18517 .send_enable_enhance_multicast_offload_cmd =
18518 send_enable_enhance_multicast_offload_tlv,
18519 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
18520#ifdef FEATURE_WLAN_RA_FILTERING
18521 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
18522#endif
18523 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018524 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
18525 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018526 .send_lphb_config_tcp_pkt_filter_cmd =
18527 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018528 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
18529 .send_lphb_config_udp_pkt_filter_cmd =
18530 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053018531 .send_enable_disable_packet_filter_cmd =
18532 send_enable_disable_packet_filter_cmd_tlv,
18533 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053018534#endif /* End of WLAN_PMO_ENABLE */
18535#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053018536 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
18537 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
18538 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053018539 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
18540 .send_process_update_edca_param_cmd =
18541 send_process_update_edca_param_cmd_tlv,
18542 .send_roam_scan_offload_mode_cmd =
18543 send_roam_scan_offload_mode_cmd_tlv,
18544 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
18545 .send_roam_scan_offload_ap_profile_cmd =
18546 send_roam_scan_offload_ap_profile_cmd_tlv,
18547#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018548 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
18549 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018550 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
18551 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070018552#ifdef WLAN_FEATURE_CIF_CFR
18553 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
18554#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053018555 .send_dfs_phyerr_filter_offload_en_cmd =
18556 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018557 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
18558 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
18559 .send_del_ts_cmd = send_del_ts_cmd_tlv,
18560 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
18561 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018562 .send_process_add_periodic_tx_ptrn_cmd =
18563 send_process_add_periodic_tx_ptrn_cmd_tlv,
18564 .send_process_del_periodic_tx_ptrn_cmd =
18565 send_process_del_periodic_tx_ptrn_cmd_tlv,
18566 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
18567 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
18568 .send_set_app_type2_params_in_fw_cmd =
18569 send_set_app_type2_params_in_fw_cmd_tlv,
18570 .send_set_auto_shutdown_timer_cmd =
18571 send_set_auto_shutdown_timer_cmd_tlv,
18572 .send_nan_req_cmd = send_nan_req_cmd_tlv,
18573 .send_process_dhcpserver_offload_cmd =
18574 send_process_dhcpserver_offload_cmd_tlv,
18575 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
18576 .send_process_ch_avoid_update_cmd =
18577 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053018578 .send_pdev_set_regdomain_cmd =
18579 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053018580 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
18581 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
18582 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
18583 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
18584 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
18585 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018586#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053018587 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053018588#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053018589 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018590 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053018591 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053018592 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018593 .send_set_base_macaddr_indicate_cmd =
18594 send_set_base_macaddr_indicate_cmd_tlv,
18595 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
18596 .send_enable_specific_fw_logs_cmd =
18597 send_enable_specific_fw_logs_cmd_tlv,
18598 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053018599 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053018600 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053018601 .send_pdev_set_dual_mac_config_cmd =
18602 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018603 .send_app_type1_params_in_fw_cmd =
18604 send_app_type1_params_in_fw_cmd_tlv,
18605 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
18606 .send_process_roam_synch_complete_cmd =
18607 send_process_roam_synch_complete_cmd_tlv,
18608 .send_unit_test_cmd = send_unit_test_cmd_tlv,
18609 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
18610 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053018611 .send_roam_scan_offload_scan_period_cmd =
18612 send_roam_scan_offload_scan_period_cmd_tlv,
18613 .send_roam_scan_offload_chan_list_cmd =
18614 send_roam_scan_offload_chan_list_cmd_tlv,
18615 .send_roam_scan_offload_rssi_change_cmd =
18616 send_roam_scan_offload_rssi_change_cmd_tlv,
18617 .send_get_buf_extscan_hotlist_cmd =
18618 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080018619 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053018620 .send_adapt_dwelltime_params_cmd =
18621 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053018622 .send_dbs_scan_sel_params_cmd =
18623 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018624 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053018625 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
18626 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
18627 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
18628 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
18629 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
18630 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
18631 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
18632 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
18633 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053018634 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
18635 .send_smart_ant_set_training_info_cmd =
18636 send_smart_ant_set_training_info_cmd_tlv,
18637 .send_smart_ant_set_node_config_cmd =
18638 send_smart_ant_set_node_config_cmd_tlv,
18639 .send_set_atf_cmd = send_set_atf_cmd_tlv,
18640 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
18641 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053018642 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
18643 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
18644 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
18645 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
18646 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
18647 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
18648 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018649 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
18650 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
18651 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
18652 .send_vdev_spectral_configure_cmd =
18653 send_vdev_spectral_configure_cmd_tlv,
18654 .send_vdev_spectral_enable_cmd =
18655 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018656 .send_thermal_mitigation_param_cmd =
18657 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053018658 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
18659 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053018660 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070018661 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018662 .get_target_cap_from_service_ready = extract_service_ready_tlv,
18663 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
18664 .extract_host_mem_req = extract_host_mem_req_tlv,
18665 .save_service_bitmap = save_service_bitmap_tlv,
18666 .is_service_enabled = is_service_enabled_tlv,
18667 .save_fw_version = save_fw_version_in_service_ready_tlv,
18668 .ready_extract_init_status = ready_extract_init_status_tlv,
18669 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
18670 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
18671 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
18672 .extract_tbttoffset_update_params =
18673 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018674 .extract_ext_tbttoffset_update_params =
18675 extract_ext_tbttoffset_update_params_tlv,
18676 .extract_tbttoffset_num_vdevs =
18677 extract_tbttoffset_num_vdevs_tlv,
18678 .extract_ext_tbttoffset_num_vdevs =
18679 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018680 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
18681 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
18682 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
18683 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080018684#ifdef CONVERGED_TDLS_ENABLE
18685 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
18686#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053018687 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018688 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018689 .extract_swba_tim_info = extract_swba_tim_info_tlv,
18690 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080018691#ifdef CONVERGED_P2P_ENABLE
18692 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
18693 .extract_p2p_lo_stop_ev_param =
18694 extract_p2p_lo_stop_ev_param_tlv,
18695#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018696 .extract_offchan_data_tx_compl_param =
18697 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053018698 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
18699 .extract_all_stats_count = extract_all_stats_counts_tlv,
18700 .extract_pdev_stats = extract_pdev_stats_tlv,
18701 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
18702 .extract_vdev_stats = extract_vdev_stats_tlv,
18703 .extract_peer_stats = extract_peer_stats_tlv,
18704 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
18705 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
18706 .extract_chan_stats = extract_chan_stats_tlv,
18707 .extract_profile_ctx = extract_profile_ctx_tlv,
18708 .extract_profile_data = extract_profile_data_tlv,
18709 .extract_chan_info_event = extract_chan_info_event_tlv,
18710 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053018711 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053018712 .send_encrypt_decrypt_send_cmd =
18713 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080018714 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053018715 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018716 .send_multiple_vdev_restart_req_cmd =
18717 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053018718 .extract_service_ready_ext = extract_service_ready_ext_tlv,
18719 .extract_hw_mode_cap_service_ready_ext =
18720 extract_hw_mode_cap_service_ready_ext_tlv,
18721 .extract_mac_phy_cap_service_ready_ext =
18722 extract_mac_phy_cap_service_ready_ext_tlv,
18723 .extract_reg_cap_service_ready_ext =
18724 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018725 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053018726 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053018727 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
18728 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
18729 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053018730 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018731 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018732 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018733 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018734 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053018735 .extract_pdev_csa_switch_count_status =
18736 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053018737 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
18738 .extract_wds_addr_event = extract_wds_addr_event_tlv,
18739 .extract_peer_sta_ps_statechange_ev =
18740 extract_peer_sta_ps_statechange_ev_tlv,
18741 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053018742 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080018743 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
18744 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018745 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053018746 extract_reg_chan_list_update_event_tlv,
18747 .extract_chainmask_tables =
18748 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018749 .extract_thermal_stats = extract_thermal_stats_tlv,
18750 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018751#ifdef DFS_COMPONENT_ENABLE
18752 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
18753 .extract_dfs_radar_detection_event =
18754 extract_dfs_radar_detection_event_tlv,
18755#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018756 .convert_pdev_id_host_to_target =
18757 convert_host_pdev_id_to_target_pdev_id_legacy,
18758 .convert_pdev_id_target_to_host =
18759 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070018760
18761 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
18762 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
18763 .extract_reg_11d_new_country_event =
18764 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053018765 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053018766 .send_limit_off_chan_cmd =
18767 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070018768 .extract_reg_ch_avoid_event =
18769 extract_reg_ch_avoid_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053018770};
18771
Govind Singhe7f2f342016-05-23 12:12:52 +053018772/**
18773 * populate_tlv_event_id() - populates wmi event ids
18774 *
18775 * @param event_ids: Pointer to hold event ids
18776 * Return: None
18777 */
18778static void populate_tlv_events_id(uint32_t *event_ids)
18779{
18780 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
18781 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
18782 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
18783 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18784 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
18785 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
18786 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
18787 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
18788 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
18789 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
18790 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
18791 event_ids[wmi_service_ready_ext_event_id] =
18792 WMI_SERVICE_READY_EXT_EVENTID;
18793 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
18794 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
18795 event_ids[wmi_vdev_install_key_complete_event_id] =
18796 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
18797 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
18798 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
18799
18800 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
18801 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
18802 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
18803 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
18804 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
18805 event_ids[wmi_peer_estimated_linkspeed_event_id] =
18806 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
18807 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053018808 event_ids[wmi_peer_delete_response_event_id] =
18809 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018810 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
18811 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
18812 event_ids[wmi_tbttoffset_update_event_id] =
18813 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018814 event_ids[wmi_ext_tbttoffset_update_event_id] =
18815 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018816 event_ids[wmi_offload_bcn_tx_status_event_id] =
18817 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
18818 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
18819 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
18820 event_ids[wmi_mgmt_tx_completion_event_id] =
18821 WMI_MGMT_TX_COMPLETION_EVENTID;
18822
18823 event_ids[wmi_tx_delba_complete_event_id] =
18824 WMI_TX_DELBA_COMPLETE_EVENTID;
18825 event_ids[wmi_tx_addba_complete_event_id] =
18826 WMI_TX_ADDBA_COMPLETE_EVENTID;
18827 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
18828
18829 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
18830
18831 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
18832 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
18833
18834 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
18835
18836 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
18837
18838 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080018839 event_ids[wmi_p2p_lo_stop_event_id] =
18840 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018841 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
18842 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
18843 event_ids[wmi_do_wow_disable_ack_event_id] =
18844 WMI_D0_WOW_DISABLE_ACK_EVENTID;
18845 event_ids[wmi_wow_initial_wakeup_event_id] =
18846 WMI_WOW_INITIAL_WAKEUP_EVENTID;
18847
18848 event_ids[wmi_rtt_meas_report_event_id] =
18849 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
18850 event_ids[wmi_tsf_meas_report_event_id] =
18851 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
18852 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
18853 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
18854 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
18855 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
18856 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
18857 event_ids[wmi_update_fw_mem_dump_event_id] =
18858 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
18859 event_ids[wmi_diag_event_id_log_supported_event_id] =
18860 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
18861 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
18862 event_ids[wmi_nlo_scan_complete_event_id] =
18863 WMI_NLO_SCAN_COMPLETE_EVENTID;
18864 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
18865 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
18866
18867 event_ids[wmi_gtk_offload_status_event_id] =
18868 WMI_GTK_OFFLOAD_STATUS_EVENTID;
18869 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
18870 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
18871 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
18872
18873 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
18874
18875 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
18876
18877 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
18878 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
18879 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
18880 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
18881 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
18882 event_ids[wmi_wlan_profile_data_event_id] =
18883 WMI_WLAN_PROFILE_DATA_EVENTID;
18884 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
18885 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
18886 event_ids[wmi_vdev_get_keepalive_event_id] =
18887 WMI_VDEV_GET_KEEPALIVE_EVENTID;
18888 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
18889
18890 event_ids[wmi_diag_container_event_id] =
18891 WMI_DIAG_DATA_CONTAINER_EVENTID;
18892
18893 event_ids[wmi_host_auto_shutdown_event_id] =
18894 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
18895
18896 event_ids[wmi_update_whal_mib_stats_event_id] =
18897 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
18898
18899 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
18900 event_ids[wmi_update_vdev_rate_stats_event_id] =
18901 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
18902
18903 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
18904
18905 /** Set OCB Sched Response, deprecated */
18906 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
18907
18908 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
18909 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
18910 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
18911
18912 /* GPIO Event */
18913 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
18914 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
18915
18916 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
18917 event_ids[wmi_rfkill_state_change_event_id] =
18918 WMI_RFKILL_STATE_CHANGE_EVENTID;
18919
18920 /* TDLS Event */
18921 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
18922
18923 event_ids[wmi_batch_scan_enabled_event_id] =
18924 WMI_BATCH_SCAN_ENABLED_EVENTID;
18925 event_ids[wmi_batch_scan_result_event_id] =
18926 WMI_BATCH_SCAN_RESULT_EVENTID;
18927 /* OEM Event */
18928 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
18929 event_ids[wmi_oem_meas_report_event_id] =
18930 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
18931 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
18932
18933 /* NAN Event */
18934 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
18935
18936 /* LPI Event */
18937 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
18938 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
18939 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
18940
18941 /* ExtScan events */
18942 event_ids[wmi_extscan_start_stop_event_id] =
18943 WMI_EXTSCAN_START_STOP_EVENTID;
18944 event_ids[wmi_extscan_operation_event_id] =
18945 WMI_EXTSCAN_OPERATION_EVENTID;
18946 event_ids[wmi_extscan_table_usage_event_id] =
18947 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
18948 event_ids[wmi_extscan_cached_results_event_id] =
18949 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
18950 event_ids[wmi_extscan_wlan_change_results_event_id] =
18951 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
18952 event_ids[wmi_extscan_hotlist_match_event_id] =
18953 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
18954 event_ids[wmi_extscan_capabilities_event_id] =
18955 WMI_EXTSCAN_CAPABILITIES_EVENTID;
18956 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
18957 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
18958
18959 /* mDNS offload events */
18960 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
18961
18962 /* SAP Authentication offload events */
18963 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
18964 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
18965
18966 /** Out-of-context-of-bss (OCB) events */
18967 event_ids[wmi_ocb_set_config_resp_event_id] =
18968 WMI_OCB_SET_CONFIG_RESP_EVENTID;
18969 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
18970 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
18971 event_ids[wmi_dcc_get_stats_resp_event_id] =
18972 WMI_DCC_GET_STATS_RESP_EVENTID;
18973 event_ids[wmi_dcc_update_ndl_resp_event_id] =
18974 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
18975 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
18976 /* System-On-Chip events */
18977 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
18978 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
18979 event_ids[wmi_soc_hw_mode_transition_event_id] =
18980 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
18981 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
18982 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018983 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053018984 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
18985 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018986 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053018987 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
18988 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18989 event_ids[wmi_peer_sta_ps_statechg_event_id] =
18990 WMI_PEER_STA_PS_STATECHG_EVENTID;
18991 event_ids[wmi_pdev_channel_hopping_event_id] =
18992 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018993 event_ids[wmi_offchan_data_tx_completion_event] =
18994 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018995 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
18996 event_ids[wmi_dfs_radar_detection_event_id] =
18997 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018998 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070018999 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019000}
19001
Soumya Bhat488092d2017-03-22 14:41:01 +053019002#ifndef CONFIG_MCL
19003/**
19004 * populate_tlv_service() - populates wmi services
19005 *
19006 * @param wmi_service: Pointer to hold wmi_service
19007 * Return: None
19008 */
19009static void populate_tlv_service(uint32_t *wmi_service)
19010{
19011 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
19012 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
19013 wmi_service[wmi_service_roam_scan_offload] =
19014 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
19015 wmi_service[wmi_service_bcn_miss_offload] =
19016 WMI_SERVICE_BCN_MISS_OFFLOAD;
19017 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
19018 wmi_service[wmi_service_sta_advanced_pwrsave] =
19019 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
19020 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
19021 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
19022 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
19023 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
19024 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
19025 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
19026 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
19027 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
19028 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
19029 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
19030 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
19031 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
19032 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
19033 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
19034 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
19035 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
19036 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
19037 wmi_service[wmi_service_packet_power_save] =
19038 WMI_SERVICE_PACKET_POWER_SAVE;
19039 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
19040 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
19041 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
19042 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
19043 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
19044 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
19045 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
19046 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
19047 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
19048 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
19049 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
19050 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
19051 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
19052 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
19053 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
19054 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
19055 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
19056 wmi_service[wmi_service_mcc_bcn_interval_change] =
19057 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
19058 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
19059 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
19060 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
19061 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
19062 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
19063 wmi_service[wmi_service_lte_ant_share_support] =
19064 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
19065 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
19066 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
19067 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
19068 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
19069 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
19070 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
19071 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
19072 wmi_service[wmi_service_bcn_txrate_override] =
19073 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
19074 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
19075 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
19076 wmi_service[wmi_service_estimate_linkspeed] =
19077 WMI_SERVICE_ESTIMATE_LINKSPEED;
19078 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
19079 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
19080 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
19081 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
19082 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
19083 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
19084 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
19085 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
19086 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
19087 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
19088 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
19089 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
19090 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
19091 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
19092 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
19093 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
19094 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
19095 wmi_service[wmi_service_sap_auth_offload] =
19096 WMI_SERVICE_SAP_AUTH_OFFLOAD;
19097 wmi_service[wmi_service_dual_band_simultaneous_support] =
19098 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
19099 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
19100 wmi_service[wmi_service_ap_arpns_offload] =
19101 WMI_SERVICE_AP_ARPNS_OFFLOAD;
19102 wmi_service[wmi_service_per_band_chainmask_support] =
19103 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
19104 wmi_service[wmi_service_packet_filter_offload] =
19105 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
19106 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
19107 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
19108 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
19109 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
19110 wmi_service[wmi_service_multiple_vdev_restart] =
19111 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
19112
19113 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
19114 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
19115 wmi_service[wmi_service_smart_antenna_sw_support] =
19116 WMI_SERVICE_UNAVAILABLE;
19117 wmi_service[wmi_service_smart_antenna_hw_support] =
19118 WMI_SERVICE_UNAVAILABLE;
19119 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
19120 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019121 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053019122 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
19123 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
19124 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
19125 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
19126 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
19127 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
19128 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
19129 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053019130 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
19131 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
19132 wmi_service[wmi_service_periodic_chan_stat_support] =
19133 WMI_SERVICE_UNAVAILABLE;
19134 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
19135 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
19136 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
19137 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
19138 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
19139 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053019140 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
19141 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
19142 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
19143 wmi_service[wmi_service_unified_wow_capability] =
19144 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
19145 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
19146 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
19147 wmi_service[wmi_service_sync_delete_cmds] =
19148 WMI_SERVICE_SYNC_DELETE_CMDS;
19149 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
19150 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
19151 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
19152 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
19153 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
19154 wmi_service[wmi_service_deprecated_replace] =
19155 WMI_SERVICE_DEPRECATED_REPLACE;
19156 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
19157 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
19158 wmi_service[wmi_service_enhanced_mcast_filter] =
19159 WMI_SERVICE_ENHANCED_MCAST_FILTER;
19160 wmi_service[wmi_service_half_rate_quarter_rate_support] =
19161 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
19162 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
19163 wmi_service[wmi_service_p2p_listen_offload_support] =
19164 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
19165 wmi_service[wmi_service_mark_first_wakeup_packet] =
19166 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
19167 wmi_service[wmi_service_multiple_mcast_filter_set] =
19168 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
19169 wmi_service[wmi_service_host_managed_rx_reorder] =
19170 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
19171 wmi_service[wmi_service_flash_rdwr_support] =
19172 WMI_SERVICE_FLASH_RDWR_SUPPORT;
19173 wmi_service[wmi_service_wlan_stats_report] =
19174 WMI_SERVICE_WLAN_STATS_REPORT;
19175 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
19176 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
19177 wmi_service[wmi_service_dfs_phyerr_offload] =
19178 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
19179 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
19180 wmi_service[wmi_service_fw_mem_dump_support] =
19181 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
19182 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
19183 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
19184 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
19185 wmi_service[wmi_service_hw_data_filtering] =
19186 WMI_SERVICE_HW_DATA_FILTERING;
19187 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
19188 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053019189 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat488092d2017-03-22 14:41:01 +053019190}
19191
Govind Singhe7f2f342016-05-23 12:12:52 +053019192/**
19193 * populate_pdev_param_tlv() - populates pdev params
19194 *
19195 * @param pdev_param: Pointer to hold pdev params
19196 * Return: None
19197 */
19198static void populate_pdev_param_tlv(uint32_t *pdev_param)
19199{
19200 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
19201 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
19202 pdev_param[wmi_pdev_param_txpower_limit2g] =
19203 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
19204 pdev_param[wmi_pdev_param_txpower_limit5g] =
19205 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
19206 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
19207 pdev_param[wmi_pdev_param_beacon_gen_mode] =
19208 WMI_PDEV_PARAM_BEACON_GEN_MODE;
19209 pdev_param[wmi_pdev_param_beacon_tx_mode] =
19210 WMI_PDEV_PARAM_BEACON_TX_MODE;
19211 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
19212 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
19213 pdev_param[wmi_pdev_param_protection_mode] =
19214 WMI_PDEV_PARAM_PROTECTION_MODE;
19215 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
19216 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
19217 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
19218 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
19219 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
19220 pdev_param[wmi_pdev_param_sta_kickout_th] =
19221 WMI_PDEV_PARAM_STA_KICKOUT_TH;
19222 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
19223 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
19224 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
19225 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
19226 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
19227 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
19228 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
19229 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
19230 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
19231 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
19232 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
19233 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
19234 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
19235 pdev_param[wmi_pdev_param_ltr_sleep_override] =
19236 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
19237 pdev_param[wmi_pdev_param_ltr_rx_override] =
19238 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
19239 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
19240 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
19241 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
19242 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
19243 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
19244 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
19245 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
19246 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
19247 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
19248 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
19249 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
19250 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
19251 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
19252 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
19253 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
19254 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
19255 pdev_param[wmi_pdev_param_peer_stats_update_period] =
19256 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
19257 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
19258 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
19259 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
19260 pdev_param[wmi_pdev_param_arp_ac_override] =
19261 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
19262 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
19263 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
19264 pdev_param[wmi_pdev_param_ani_poll_period] =
19265 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
19266 pdev_param[wmi_pdev_param_ani_listen_period] =
19267 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
19268 pdev_param[wmi_pdev_param_ani_ofdm_level] =
19269 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
19270 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
19271 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
19272 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
19273 pdev_param[wmi_pdev_param_idle_ps_config] =
19274 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
19275 pdev_param[wmi_pdev_param_power_gating_sleep] =
19276 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
19277 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
19278 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
19279 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
19280 pdev_param[wmi_pdev_param_hw_rfkill_config] =
19281 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
19282 pdev_param[wmi_pdev_param_low_power_rf_enable] =
19283 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
19284 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
19285 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
19286 pdev_param[wmi_pdev_param_power_collapse_enable] =
19287 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
19288 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
19289 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
19290 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
19291 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
19292 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
19293 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
19294 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
19295 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
19296 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
19297 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
19298 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
19299 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
19300 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
19301 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
19302 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
19303 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
19304 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
19305 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
19306 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
19307 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
19308 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
19309 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
19310 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
19311 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
19312 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
19313 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
19314 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
19315 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
19316 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
19317 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
19318 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
19319 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
19320 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
19321 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
19322 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
19323 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
19324 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
19325 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
19326 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
19327 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
19328 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
19329 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
19330 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
19331 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
19332 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
19333 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumard99852a2017-07-08 12:32:27 +053019334 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
19335 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053019336 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
19337 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
19338 WMI_UNAVAILABLE_PARAM;
19339 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
19340 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
19341 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
19342 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
19343 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
19344 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019345 pdev_param[wmi_pdev_param_atf_strict_sch] =
19346 WMI_PDEV_PARAM_ATF_STRICT_SCH;
19347 pdev_param[wmi_pdev_param_atf_sched_duration] =
19348 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053019349 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
19350 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
19351 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
19352 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
19353 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
19354 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
19355 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
19356 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
19357 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
19358 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
19359 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
19360 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
19361 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
19362 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
19363 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
19364 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019365 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
19366 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053019367 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019368 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053019369 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053019370 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
19371 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019372 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
19373 WMI_UNAVAILABLE_PARAM;
19374 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
19375 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
19376 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
19377 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
19378 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
19379 WMI_UNAVAILABLE_PARAM;
19380 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
19381 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
19382 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019383 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
19384 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053019385 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053019386 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
19387 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053019388 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
19389 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
19390 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
19391 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
19392 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
19393 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
19394 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
19395 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
19396 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
19397 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
19398 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
19399 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
19400 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
19401 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
19402 pdev_param[wmi_pdev_param_fast_channel_reset] =
19403 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
19404 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053019405}
19406
19407/**
19408 * populate_vdev_param_tlv() - populates vdev params
19409 *
19410 * @param vdev_param: Pointer to hold vdev params
19411 * Return: None
19412 */
19413static void populate_vdev_param_tlv(uint32_t *vdev_param)
19414{
19415 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
19416 vdev_param[wmi_vdev_param_fragmentation_threshold] =
19417 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
19418 vdev_param[wmi_vdev_param_beacon_interval] =
19419 WMI_VDEV_PARAM_BEACON_INTERVAL;
19420 vdev_param[wmi_vdev_param_listen_interval] =
19421 WMI_VDEV_PARAM_LISTEN_INTERVAL;
19422 vdev_param[wmi_vdev_param_multicast_rate] =
19423 WMI_VDEV_PARAM_MULTICAST_RATE;
19424 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
19425 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
19426 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
19427 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
19428 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
19429 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
19430 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
19431 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
19432 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
19433 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
19434 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
19435 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
19436 vdev_param[wmi_vdev_param_bmiss_count_max] =
19437 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
19438 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
19439 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
19440 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
19441 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
19442 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
19443 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
19444 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
19445 vdev_param[wmi_vdev_param_disable_htprotection] =
19446 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
19447 vdev_param[wmi_vdev_param_sta_quickkickout] =
19448 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
19449 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
19450 vdev_param[wmi_vdev_param_protection_mode] =
19451 WMI_VDEV_PARAM_PROTECTION_MODE;
19452 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
19453 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
19454 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
19455 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
19456 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
19457 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
19458 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
19459 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
19460 vdev_param[wmi_vdev_param_bcast_data_rate] =
19461 WMI_VDEV_PARAM_BCAST_DATA_RATE;
19462 vdev_param[wmi_vdev_param_mcast_data_rate] =
19463 WMI_VDEV_PARAM_MCAST_DATA_RATE;
19464 vdev_param[wmi_vdev_param_mcast_indicate] =
19465 WMI_VDEV_PARAM_MCAST_INDICATE;
19466 vdev_param[wmi_vdev_param_dhcp_indicate] =
19467 WMI_VDEV_PARAM_DHCP_INDICATE;
19468 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
19469 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
19470 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
19471 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
19472 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
19473 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
19474 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
19475 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
19476 vdev_param[wmi_vdev_param_ap_enable_nawds] =
19477 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
19478 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
19479 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
19480 vdev_param[wmi_vdev_param_packet_powersave] =
19481 WMI_VDEV_PARAM_PACKET_POWERSAVE;
19482 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
19483 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
19484 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
19485 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
19486 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
19487 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
19488 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
19489 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
19490 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
19491 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
19492 vdev_param[wmi_vdev_param_early_rx_slop_step] =
19493 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
19494 vdev_param[wmi_vdev_param_early_rx_init_slop] =
19495 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
19496 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
19497 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
19498 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
19499 vdev_param[wmi_vdev_param_snr_num_for_cal] =
19500 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
19501 vdev_param[wmi_vdev_param_roam_fw_offload] =
19502 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
19503 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
19504 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
19505 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
19506 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
19507 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
19508 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
19509 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
19510 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
19511 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
19512 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
19513 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
19514 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
19515 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
19516 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
19517 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
19518 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
19519 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
19520 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
19521 vdev_param[wmi_vdev_param_inactivity_cnt] =
19522 WMI_VDEV_PARAM_INACTIVITY_CNT;
19523 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
19524 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
19525 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
19526 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
19527 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
19528 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
19529 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
19530 vdev_param[wmi_vdev_param_rx_leak_window] =
19531 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
19532 vdev_param[wmi_vdev_param_stats_avg_factor] =
19533 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
19534 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
19535 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
19536 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
19537 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
19538 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
19539 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053019540 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
19541 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053019542 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080019543 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
19544 vdev_param[wmi_vdev_param_he_range_ext_enable] =
19545 WMI_VDEV_PARAM_HE_RANGE_EXT;
19546 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
19547 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053019548 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
19549 vdev_param[wmi_vdev_param_dtim_enable_cts] =
19550 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
19551 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
19552 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
19553 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
19554 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053019555 vdev_param[wmi_vdev_param_mcast2ucast_set] =
19556 WMI_VDEV_PARAM_MCAST2UCAST_SET;
19557 vdev_param[wmi_vdev_param_rc_num_retries] =
19558 WMI_VDEV_PARAM_RC_NUM_RETRIES;
19559 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
19560 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
19561 vdev_param[wmi_vdev_param_rts_fixed_rate] =
19562 WMI_VDEV_PARAM_RTS_FIXED_RATE;
19563 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
19564 vdev_param[wmi_vdev_param_vht80_ratemask] =
19565 WMI_VDEV_PARAM_VHT80_RATEMASK;
19566 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
19567 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
19568 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053019569}
19570#endif
19571
Govind Singh5eb51532016-03-09 11:34:12 +053019572/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019573 * populate_target_defines_tlv() - Populate target defines and params
19574 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053019575 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019576 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053019577 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053019578#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019579static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053019580{
Govind Singhe7f2f342016-05-23 12:12:52 +053019581 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053019582 populate_pdev_param_tlv(wmi_handle->pdev_param);
19583 populate_vdev_param_tlv(wmi_handle->vdev_param);
19584}
19585#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019586static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
19587{ }
19588#endif
19589
19590/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019591 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
19592 * host to target defines.
19593 * @param pdev_id: host pdev_id to be converted.
19594 * Return: target pdev_id after conversion.
19595 */
19596static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
19597{
19598 switch (pdev_id) {
19599 case WMI_HOST_PDEV_ID_SOC:
19600 return WMI_PDEV_ID_SOC;
19601 case WMI_HOST_PDEV_ID_0:
19602 return WMI_PDEV_ID_1ST;
19603 case WMI_HOST_PDEV_ID_1:
19604 return WMI_PDEV_ID_2ND;
19605 case WMI_HOST_PDEV_ID_2:
19606 return WMI_PDEV_ID_3RD;
19607 }
19608
19609 QDF_ASSERT(0);
19610
19611 return WMI_PDEV_ID_SOC;
19612}
19613
19614/**
19615 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
19616 * target to host defines.
19617 * @param pdev_id: target pdev_id to be converted.
19618 * Return: host pdev_id after conversion.
19619 */
19620static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
19621{
19622 switch (pdev_id) {
19623 case WMI_PDEV_ID_SOC:
19624 return WMI_HOST_PDEV_ID_SOC;
19625 case WMI_PDEV_ID_1ST:
19626 return WMI_HOST_PDEV_ID_0;
19627 case WMI_PDEV_ID_2ND:
19628 return WMI_HOST_PDEV_ID_1;
19629 case WMI_PDEV_ID_3RD:
19630 return WMI_HOST_PDEV_ID_2;
19631 }
19632
19633 QDF_ASSERT(0);
19634
19635 return WMI_HOST_PDEV_ID_SOC;
19636}
19637
19638/**
19639 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
19640 *
19641 * Return None.
19642 */
19643void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
19644{
19645 wmi_handle->ops->convert_pdev_id_host_to_target =
19646 convert_host_pdev_id_to_target_pdev_id;
19647 wmi_handle->ops->convert_pdev_id_target_to_host =
19648 convert_target_pdev_id_to_host_pdev_id;
19649}
19650/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019651 * wmi_tlv_attach() - Attach TLV APIs
19652 *
19653 * Return: None
19654 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019655void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053019656{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053019657 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053019658#ifdef WMI_INTERFACE_EVENT_LOGGING
19659 wmi_handle->log_info.buf_offset_command = 2;
19660 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053019661#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053019662 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053019663 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053019664}